Jac Grammar Documentation Analysis#
Section 1: Base Module structure#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/base_module_structure.md - Findings:
- Inconsistency in
with entryrequirement:- Documentation states: "Moreover, Jac requires that any standalone, module-level code be encapsulated within a
with entry {}block." - Grammar allows:
toplevel_stmt(which includesglobal_var,archetype,ability,test,impl_def,import_stmt,py_code_block) to appear directly within amodulewithout being wrapped infree_code(which is thewith entry {}construct). Thefree_coderule is just one of the options for atoplevel_stmt. - Issue: The documentation's statement about
with entry {}being required for any standalone module-level code is an oversimplification and conflicts with the broader capabilities defined in the grammar formoduleandtoplevel_stmt.
- Documentation states: "Moreover, Jac requires that any standalone, module-level code be encapsulated within a
- Inconsistency in
Section 2: Import/Include Statements#
- Grammar Rules from
jac.lark:import_stmt: KW_IMPORT KW_FROM from_path LBRACE import_items RBRACE | KW_IMPORT import_path (COMMA import_path)* SEMI | KW_INCLUDE import_path SEMI from_path: (DOT | ELLIPSIS)* import_path | (DOT | ELLIPSIS)+ import_path: dotted_name (KW_AS NAME)? import_items: (import_item COMMA)* import_item COMMA? import_item: named_ref (KW_AS NAME)? dotted_name: named_ref (DOT named_ref)* - Corresponding Markdown File:
jac/examples/reference/import_include_statements.md - Findings:
from_pathdetails not fully covered:- Grammar allows:
from_pathto be(DOT | ELLIPSIS)* import_pathor(DOT | ELLIPSIS)+. - Documentation mentions: Relative paths but doesn't explicitly detail the syntax using
.orELLIPSIS(...) in thefrom_pathfor selective imports. - Issue: The documentation could be more explicit about using
.and...infrom_path.
- Grammar allows:
import_itemstrailing comma:- Grammar allows: A trailing comma in
import_items. - Documentation example: Does not show an example with a trailing comma.
- Issue: Minor omission; an example or note about the optional trailing comma would be beneficial.
- Grammar allows: A trailing comma in
- Multiple
import_pathin standard import:- Grammar allows: Importing multiple modules in a single standard
importstatement (e.g.,import mod1, mod2;). - Documentation examples: Show single module imports per statement.
- Issue: Documentation does not cover importing multiple modules in one standard
importstatement.
- Grammar allows: Importing multiple modules in a single standard
Section 3: Archetypes#
- Grammar Rules from
jac.lark:archetype: decorators? KW_ASYNC? archetype_decl | enum archetype_decl: arch_type access_tag? NAME inherited_archs? (member_block | SEMI) decorators: (DECOR_OP atomic_chain)+ access_tag: COLON ( KW_PROT | KW_PUB | KW_PRIV ) inherited_archs: LPAREN (atomic_chain COMMA)* atomic_chain RPAREN arch_type: KW_WALKER | KW_OBJECT | KW_EDGE | KW_NODE | KW_CLASS - Corresponding Markdown File:
jac/examples/reference/archetypes.md - Findings:
- Omission of Empty/Forward Declaration:
- Grammar allows:
archetype_declto end withSEMI(e.g.,node MyNode;). - Documentation: Does not mention or provide examples for this.
- Issue: Capability to define archetypes with empty bodies using a semicolon is not documented.
- Grammar allows:
- Omission of
KW_ASYNCfor Archetypes:- Grammar allows:
archetypeto beasync(e.g.,async walker MyAsyncWalker {...}). - Documentation: Does not mention
asyncarchetypes. - Issue: The
asynckeyword applicability to the archetype declaration itself is not documented.
- Grammar allows:
enumas anarchetypeform:- Grammar states:
archetype: ... | enum. - Documentation:
archetypes.mddoes not mention thatenumis a type ofarchetype. - Issue: Lack of mention or cross-reference to
enumas a form ofarchetype.
- Grammar states:
- Omission of Empty/Forward Declaration:
Section 4: Archetype bodies#
- Grammar Rules from
jac.lark:member_block: LBRACE member_stmt* RBRACE member_stmt: STRING? (py_code_block | ability | archetype | impl_def | has_stmt | free_code) has_stmt: KW_STATIC? (KW_LET | KW_HAS) access_tag? has_assign_list SEMI has_assign_list: (has_assign_list COMMA)? typed_has_clause typed_has_clause: named_ref type_tag (EQ expression | KW_BY KW_POST_INIT)? type_tag: COLON expression - Corresponding Markdown File:
jac/examples/reference/archetype_bodies.md - Findings:
member_stmtoptions not fully detailed/exemplified:- Grammar for
member_stmt:STRING? (py_code_block | ability | archetype | impl_def | has_stmt | free_code) - Documentation (
archetype_bodies.md):- Covers
has_stmtandabilitywell. - Shows docstrings (
STRING?). - Mentions
implblocks but not explicitly thatimpl_defcan be nested inside an archetype. - Does not explicitly cover nesting
archetype,py_code_block, orfree_codewithin an archetype.
- Covers
- Issue: Documentation should list all
member_stmttypes and provide examples/references for nestingarchetype,py_code_block,impl_def, andfree_code.
- Grammar for
has_stmtusingKW_LET:- Grammar for
has_stmt:KW_STATIC? (KW_LET | KW_HAS) .... - Documentation: Consistently uses
has.KW_LETalternative is not mentioned. - Issue: Use of
letfor member declarations is not documented in this file.
- Grammar for
typed_has_clausewithKW_BY KW_POST_INIT:- Grammar:
... (EQ expression | KW_BY KW_POST_INIT)? - Documentation: Covered in
archetypes.md(has id: str by postinit;). - Status: Covered in a related file.
- Grammar:
has_assign_listwith multiple assignments:- Grammar for
has_assign_list:(has_assign_list COMMA)? typed_has_clause, implying multiple comma-separated declarations. - Documentation: Examples show one variable per
hasstatement. - Issue: Declaring multiple variables in a single
hasstatement (e.g.,has name: str, age: int;) is not documented.
- Grammar for
Section 5: Enumerations#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/enumerations.md - Findings:
inherited_archsinenum_decl:- Grammar allows: Enums to use
inherited_archs(e.g.,enum MyEnum(Parent) {...}). - Documentation: Does not mention or exemplify enum inheritance.
- Issue: Enum inheritance is not documented.
- Grammar allows: Enums to use
- Empty Enum Declaration with
SEMI:- Grammar allows:
enum MyEnum;. - Documentation: Shows
enum Day;with animpl Day {}block. - Status: Covered in the context of
implblocks.
- Grammar allows:
py_code_blockandfree_codeinenum_block:- Grammar allows:
py_code_block(::py::...::py::) orfree_code(with entry {}) within anenum {}body. - Documentation: Examples focus on assignments in
enum {}and methods inimpl {}. - Issue: Direct inclusion of
py_code_blockorfree_codeinenum {}is not documented.
- Grammar allows:
- Nature of
assignment_listin Enums:- Grammar uses a general
assignment_listrule. - Documentation shows: Typical enum assignments (
NAME = valueorNAME). - Question/Potential Minor Issue: The documentation doesn't clarify if the full range of complex
assignmentsyntax is applicable or idiomatic within enums, or if it's restricted to simpler forms. - Status: Core enum assignment is covered; scope of complex assignments within enums is not detailed.
- Grammar uses a general
Section 6: Functions and Abilities#
- Grammar Rules from
jac.lark:ability: decorators? KW_ASYNC? (ability_decl | function_decl) function_decl: KW_OVERRIDE? KW_STATIC? KW_DEF access_tag? named_ref func_decl? (block_tail | KW_ABSTRACT? SEMI) ability_decl: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? named_ref event_clause (block_tail | KW_ABSTRACT? SEMI) block_tail: code_block | KW_BY atomic_call SEMI event_clause: KW_WITH expression? (KW_EXIT | KW_ENTRY) (RETURN_HINT expression)? func_decl: (LPAREN func_decl_params? RPAREN) (RETURN_HINT expression)? | (RETURN_HINT expression) func_decl_params: (param_var COMMA)* param_var COMMA? param_var: (STAR_POW | STAR_MUL)? named_ref type_tag (EQ expression)? - Corresponding Markdown File:
jac/examples/reference/functions_and_abilities.md - Findings:
function_declwithout parentheses:- Grammar for
func_declallows:(RETURN_HINT expression)directly (e.g.,def my_func -> int { ... }). - Documentation: Examples use parentheses. The variant without
()for no-parameter functions is not shown. - Issue: Undocumented shorthand for no-parameter functions.
- Grammar for
block_tailwithKW_BY atomic_call SEMI(Delegation):- Grammar allows: Implementation delegation (e.g.,
def my_func by other_func;). - Documentation: Does not cover the
bydelegation syntax. - Issue: Delegation of implementation is not documented.
- Grammar allows: Implementation delegation (e.g.,
event_clausewith return type:- Grammar for
event_clauseallows:(RETURN_HINT expression)?(e.g.,can my_ability with node entry -> bool { ... }). - Documentation: Does not show abilities with event clauses having explicit return types.
- Issue: Return types on event-claused abilities are not documented.
- Grammar for
KW_OVERRIDEfor functions/abilities:- Grammar allows:
KW_OVERRIDE?. - Documentation:
overridekeyword is not mentioned or exemplified. - Issue:
overridekeyword is not documented.
- Grammar allows:
KW_ABSTRACTwithSEMI:- Grammar allows:
KW_ABSTRACT? SEMI. - Documentation: Shows
def area() -> float abs;. - Status: Covered.
- Grammar allows:
param_var(parameter definitions):- Grammar covers:
*args,**kwargs, typed params, default values. - Documentation: Shows these patterns.
- Status: Covered.
- Grammar covers:
decoratorsonability/function_decl:- Grammar allows: Decorators on abilities and functions.
- Documentation: No specific example in
functions_and_abilities.md, though decorators are a general feature. - Issue: Minor; a direct example would be beneficial for completeness.
KW_STATICfor abilities:- Grammar allows:
KW_STATIC? KW_CAN ...(static abilities). - Documentation: Examples show
static def, but notstatic can. - Issue: Static abilities are not explicitly documented.
- Grammar allows:
Section 7: Implementations#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/implementations.md -
Findings:
-
Modern
implSyntax vs. Grammarimpl_def:- Documentation shows:
impl foo() -> str { ... },impl vehicle { ... },impl Size { ... }. - Grammar:
KW_IMPL dotted_name impl_spec? impl_tail. - Status: Documented "Modern
implSyntax" aligns well with the grammar.
- Documentation shows:
-
Legacy Colon Syntax:
- Documentation covers:
:can:foo(),:obj:vehicle,:enum:Size,:test:check_vehicle. - Grammar
jac.lark: Does not define this colon-prefixed syntax for implementations directly inimpl_def. - Issue: Significant inconsistency. The legacy colon syntax is not in the provided
impl_defgrammar.
- Documentation covers:
-
impl_specwithinherited_archsorevent_clause:- Grammar for
impl_spec:inherited_archs | func_decl | event_clause. - Documentation covers:
impl_specasfunc_decl(e.g.,impl foo() -> str { ... }). - Documentation does not cover:
impl_specasinherited_archs(e.g.,impl MyType(Parent) { ... }) orevent_clause(e.g.,impl MyAbility with node entry { ... }). - Issue: Using
inherited_archsorevent_clauseinimpl_specis not documented.
- Grammar for
-
decoratorsonimpl_def:- Grammar allows:
decorators? KW_IMPL .... - Documentation: No examples show decorators on
implblocks. - Issue: Decorating
implblocks is not documented.
- Grammar allows:
-
impl_tailwithKW_BY atomic_call SEMI(Delegation):- Grammar allows:
impl_tailto beblock_tail, which can delegate (e.g.,impl foo() -> str by other_call;). - Documentation: Does not cover
bydelegation for implementations. - Issue: Delegating an entire
implblock is not documented.
- Grammar allows:
-
Implementing
test:- Documentation shows:
test check_vehicle;and:test:check_vehicle { ... }(legacy). - Grammar
testrule:KW_TEST NAME? code_block(defines test with body). - Grammar
impl_defsuggests modern form:impl check_vehicle { ... }. - Issue: The "Modern
implSyntax" for tests (KW_IMPL test_name) is not explicitly shown. Clarity is needed on howtest Name;declaration andimpl Name { ... }interact versus the directtest Name { ... }grammar.
- Documentation shows:
-
Section 8: Global variables#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/global_variables.md -
Findings:
-
Keywords
letandglob:- Grammar:
KW_LET,KW_GLOBAL. - Documentation: Explains
letandglobwith examples. - Status: Covered.
- Grammar:
-
access_tag:- Grammar:
access_tag?(optional). - Documentation: Explains
:priv,:pub,:protectand default visibility. Examples provided. - Status: Covered.
- Grammar:
-
assignment_listfor multiple declarations:- Grammar allows: Multiple comma-separated assignments (e.g.,
glob a = 1, b = 2;). - Documentation: Examples show single declarations per statement.
- Issue: Declaring multiple global variables in a single statement is not documented.
- Grammar allows: Multiple comma-separated assignments (e.g.,
-
assignment_listwithnamed_refonly (declaration without assignment):- Grammar allows: Declaration without explicit assignment (e.g.,
glob my_var;). - Documentation: Examples show variables with initial assignments.
- Issue: Declaration of global variables without an initial assignment is not documented.
- Grammar allows: Declaration without explicit assignment (e.g.,
-
Full complexity of
assignmentrule inglobal_var:- Grammar uses a general
assignmentrule. - Documentation shows: Simple
name = expressionform. - Question/Potential Minor Issue: Applicability of more complex assignment forms (e.g., with explicit type tags, augmented assignments) within
global_varis not explored. - Status: Basic global variable assignment covered; complex forms not detailed.
- Grammar uses a general
-
Section 9: Free code#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/free_code.md -
Findings:
-
Basic Syntax
with entry { ... }:- Grammar:
KW_WITH KW_ENTRY code_block. - Documentation: Shows
with entry { ... }. - Status: Covered.
- Grammar:
-
Named Entry Points
with entry:name { ... }:- Grammar:
KW_WITH KW_ENTRY COLON NAME code_block. - Documentation: Shows
with entry:name { ... }. - Status: Covered.
- Grammar:
-
Content of
code_block(Statements withinfree_code):- Grammar:
code_blockcan contain anystatement*. - Documentation: Focuses on executable statements (assignments, function calls). It does not explicitly discuss or exemplify the use of declarative statements (like defining archetypes, abilities, or imports) inside a
with entryblock. - Issue/Clarification Needed: The documentation should clarify the intended scope and limitations of statements within
free_code. While grammatically flexible, practical or idiomatic usage might be more restricted than the grammar implies. For example, is defining an archetype insidewith entryallowed and meaningful?
- Grammar:
-
Section 10: Inline python#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/inline_python.md -
Findings:
-
Syntax
::py:: ... ::py:::- Grammar: Defines the
PYNLINEterminal. - Documentation: Correctly shows
::py:: ... ::py::. - Status: Covered.
- Grammar: Defines the
-
Placement of
py_code_block:- Grammar: Allows
py_code_blockat module level, within archetypes, and within general code blocks (e.g., function bodies). - Documentation: Primarily shows module-level
py_code_block. It does not explicitly exemplify or discuss its use inside archetypes or other Jac statement blocks (like function bodies). - Issue: The documentation could be more comprehensive by illustrating the use of
py_code_blockin different scopes permitted by the grammar (e.g., inside acanblock or anobjblock).
- Grammar: Allows
-
Section 11: Tests#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/tests.md -
Findings:
-
Anonymous Test
test { ... }:- Grammar:
KW_TEST code_block(NAME is absent). - Documentation: Shows
test { ... }. - Status: Covered.
- Grammar:
-
Named Test Syntax (Identifier vs. String Literal):
- Grammar:
KW_TEST NAME code_block(whereNAMEis an identifier). - Documentation: Primarily shows test names as string literals (e.g.,
test "descriptive test name" { ... }). - Inconsistency/Clarification Needed: The grammar specifies
NAME(identifier) for test names, but documentation uses string literals. This needs clarification. If string literals are just descriptions and the actual name is different or optional, this should be explained. Theimplementations.mdimplies modern form:**impl check_vehicle { ... }. - Issue: The "Modern
implSyntax" for tests (KW_IMPL test_name) is not explicitly shown. Clarity is needed on howtest Name;declaration andimpl Name { ... }interact versus the directtest Name { ... }grammar.
- Grammar:
-
Content of
code_blockwithintest:- Grammar: Allows any valid
statement*. - Documentation: Examples show a wide variety of Jac statements, including assignments, calls, assertions, loops, try/except, etc.
- Status: Well covered through examples.
- Grammar: Allows any valid
-
Separation of Test Declaration and Implementation:
- Grammar
testrule: Defines a test with its body directly. - Documentation (
tests.md): Shows tests defined with their bodies. - Documentation (
implementations.md): Discusses declaring tests (e.g.,test my_test_name;) and implementing them separately. - Issue (Cross-file Context):
tests.mditself does not mention or cross-reference the declaration/implementation separation for tests. A brief note could improve clarity on how thetest Name;(declaration) relates totest Name {body}(direct definition) orimpl Name {body}(implementation).
- Grammar
-
Section 12: Codeblocks and Statements#
- Grammar Rules from
jac.lark:code_block: LBRACE statement* RBRACE statement: import_stmt | ability | has_stmt | archetype | impl_def | if_stmt | while_stmt | for_stmt | try_stmt | match_stmt | with_stmt | global_ref SEMI | nonlocal_ref SEMI | typed_ctx_block | return_stmt SEMI | (yield_expr | KW_YIELD) SEMI | raise_stmt SEMI | assert_stmt SEMI | check_stmt SEMI | assignment SEMI | delete_stmt SEMI | report_stmt SEMI | expression SEMI | ctrl_stmt SEMI | py_code_block | spatial_stmt | SEMI - Corresponding Markdown File:
jac/examples/reference/codeblocks_and_statements.md -
Findings:
-
code_blockStructure:- Grammar:
LBRACE statement* RBRACE. - Documentation: Shows
{ ... }structure. - Status: Covered.
- Grammar:
-
List of
statementtypes (Overview):- Grammar: Provides an exhaustive list of specific statement productions.
- Documentation: Categorizes statements broadly (Declaration, Expression, Control Flow, Object-Spatial) but does not enumerate all specific types from the grammar in this overview file.
- Issue/Nature of Document: This overview could be more comprehensive by listing more specific statement types (e.g.,
import_stmt,archetype(as a statement),global_ref,nonlocal_ref,typed_ctx_block,delete_stmt,report_stmt,ctrl_stmtvariants,SEMI(empty statement),py_code_blockas a statement) or clearly stating that full details are in respective dedicated files. Many specific statement types have their own documentation pages.
-
Statement Termination:
- Documentation: States most statements need semicolons, control/block statements usually don't.
- Grammar: Shows specific
SEMIusage. - Status: Generally covered.
-
Empty Statement
SEMI:- Grammar:
statement: ... | SEMIallows empty statements. - Documentation: Does not explicitly mention the empty statement.
- Issue: The empty statement is not documented in this overview.
- Grammar:
-
Section 13: If statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/if_statements.md -
Findings:
- Basic
if: Covered. if-else: Covered.if-elif: Covered.if-elif-else: Covered.- Multiple
elifstatements: Covered. expressionas condition: Well covered with diverse examples.- Mandatory
code_block: Covered and emphasized.
- Basic
-
Overall: The documentation for
if_stmtappears to be thorough and consistent with the grammar rules.
Section 14: While statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/while_statements.md -
Findings:
- Basic Syntax
while condition { ... }: Covered. expressionas Condition: Well covered with diverse examples.- Mandatory
code_block: Covered. - Absence of
elseclause: Consistent with grammar (correctly omitted).
- Basic Syntax
-
Overall: The documentation for
while_stmtis comprehensive and aligns well with the grammar rule.
Section 15: For statements#
- Grammar Rules from
jac.lark:for_stmt: KW_ASYNC? KW_FOR assignment KW_TO expression KW_BY assignment code_block else_stmt? | KW_ASYNC? KW_FOR atomic_chain KW_IN expression code_block else_stmt? // assignment: KW_LET? (atomic_chain EQ)+ (yield_expr | expression) | atomic_chain type_tag (EQ (yield_expr | expression))? | atomic_chain aug_op (yield_expr | expression) // atomic_chain: can be a simple name or a de-structuring pattern (e.g., x, y) // else_stmt: KW_ELSE code_block - Corresponding Markdown File:
jac/examples/reference/for_statements.md -
Findings:
-
For-In Loop (
for variable in iterable):- Grammar:
KW_FOR atomic_chain KW_IN expression code_block else_stmt?. - Documentation: Covers simple variables and de-structuring (
for index, value in ...). - Status: Well covered.
- Grammar:
-
For-To-By Loop (
for init to condition by increment):- Grammar:
KW_FOR assignment KW_TO expression KW_BY assignment code_block else_stmt?. - Documentation: Shows examples like
for i=0 to i<10 by i+=1. - Status: Well covered.
- Grammar:
-
KW_ASYNCfor For Loops:- Grammar: Allows
KW_ASYNC?on both variants. - Documentation: Shows
async for ... in .... Does not explicitly showasync for ... to ... by .... - Issue:
asyncfor the "for-to-by" variant is not exemplified.
- Grammar: Allows
-
else_stmtfor For Loops:- Grammar: Allows
else_stmt?on both variants. - Documentation: No examples show a
forloop with anelseclause. - Issue: The optional
elseclause forforloops is not documented or exemplified.
- Grammar: Allows
-
Multi-Variable Assignment in For-To-By Initialization/Increment:
- Documentation shows:
for i=0, j=len(array)-1 to i<j by i+=1, j-=1. - Grammar
for_stmtusesassignmentrule: The standardassignmentrule does not directly support multiple comma-separated independent assignments (e.g.,i=0, j=val). This looks more like anassignment_list. - Issue/Inconsistency: The multi-variable example suggests the
assignmentparts infor_stmtmight accept anassignment_listor a special comma-separated form not directly evident from theassignmentrule's definition. This discrepancy needs clarification.
- Documentation shows:
-
Conditional Iteration (filter in for-in):
- Documentation shows:
for item in collection if item.is_valid() { ... }. - Grammar
for_stmt(for-in variant): Does not include syntax for anif conditionfilter as part of the loop definition itself. - Issue: The
if conditionfilter syntax directly in thefor ... in ...statement is not represented in the providedfor_stmtgrammar. This might be syntactic sugar or a higher-level feature.
- Documentation shows:
-
Section 16: Try statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/try_statements.md -
Findings:
-
Basic
try-except(with specific exceptions):- Grammar:
KW_TRY code_block except_listwhereexcept_defisKW_EXCEPT expression (KW_AS NAME)? code_block. - Documentation: Shows examples like
except ValueError as eandexcept IOError. - Status: Covered.
- Grammar:
-
Multiple
exceptblocks:- Grammar:
except_list: except_def+. - Documentation: Examples show multiple
exceptblocks. - Status: Covered.
- Grammar:
-
**Catch-all
except(Bareexceptvs.except Exception):- Documentation Syntax Overview shows:
except { # handle any exception }(bare except). - Documentation Example shows:
except Exception as e { ... }. - Grammar
except_def:KW_EXCEPT expression ...requires anexpression(exception type). - Issue/Inconsistency: The bare
except { ... }syntax from the documentation overview is inconsistent with the grammar ruleexcept_defwhich mandates anexpression. To catch all exceptions per the current grammar,except Exception ...must be used, which is shown in an example.
- Documentation Syntax Overview shows:
-
else_stmt(elseclause fortry):- Grammar:
try_stmt: ... else_stmt? .... - Documentation: Explains and exemplifies the
elseclause. - Status: Covered.
- Grammar:
-
finally_stmt(finallyclause fortry):- Grammar:
try_stmt: ... finally_stmt?. - Documentation: Explains and exemplifies the
finallyclause. - Status: Covered.
- Grammar:
-
Combinations (e.g.,
try-except-else-finally):- Grammar: Allows all optional parts.
- Documentation: Syntax overview implies combinations.
- Status: Generally covered (with the bare
exceptinconsistency noted).
-
-
Overall: Documentation is mostly comprehensive, with the main inconsistency being the syntax for a catch-all
exceptblock.
Section 17: Match statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/match_statements.md -
Findings:
-
Basic
matchstatement structure (match expr { case ... }):- Status: Covered.
-
match_case_blockstructure (case pattern: statements):- Status: Covered.
-
pattern_seq(Top-level pattern in a case, e.g., OR, AS patterns):- Documentation: Shows examples of OR patterns (
case "a" | "b":) and AS patterns (case [x,y] as p:). - Status: Covered.
- Documentation: Shows examples of OR patterns (
-
Guard Condition (
if expressionon a case):- Grammar:
(KW_IF expression)?. - Documentation: Explains and exemplifies guarded cases (
case pattern if condition:). - Status: Covered.
- Grammar:
-
Overview of Pattern Types (Literal, Capture, Sequence, Mapping, Class, Singleton):
- Documentation: Provides a good overview with examples for these common pattern types.
- Status: Good overview. Detailed analysis depends on specific pattern grammar sections.
-
Wildcard
_:- Documentation: Example
case _: ...shows its use as a wildcard. - Grammar:
capture_pattern: NAME. Assumes_is a validNAMEwith special wildcard semantics. - Status: Usage documented.
- Documentation: Example
-
-
Overall: The
match_statements.mdprovides a solid introduction to match statements and seems consistent with the primary grammar rules formatch_stmtandmatch_case_block. Detailed pattern analysis will follow with specific pattern sections.
Section 18: Match patterns (Grammar Details)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File: No dedicated
match_patterns.md. These rules are covered withinmatch_statements.md. -
Findings:
-
pattern_seq(overall pattern structure in acase):- Covered in
match_statements.mdvia "OR Patterns" and "AS Patterns" examples. - Status: Covered.
- Covered in
-
or_pattern(pattern BW_OR pattern ...):- Covered in
match_statements.md("OR Patterns" section). - Status: Covered.
- Covered in
-
as_pattern(or_pattern KW_AS NAME):- Covered in
match_statements.md("AS Patterns" section, e.g.,case [x, y] as point:). - The nuance that the LHS of
KW_ASis anor_pattern(e.g.,case (A | B) as C:) is not explicitly exemplified. - Issue (Minor): An example of
as_patternwith a precedingor_patterninvolving|would offer more clarity. - Status: Generally covered; could be more explicit on
or_patterninteraction.
- Covered in
-
pattern(disjunction of specific pattern types):- The concept that a
patternis one of literal, singleton, capture, sequence, mapping, or class pattern is introduced inmatch_statements.mdunder "Pattern Types". - Status: Covered at a high level. Detailed analysis relies on specific
xxx_pattern.mdfiles.
- The concept that a
-
-
Overall: The structural rules for combining patterns (OR, AS) and the main pattern categories are introduced in
match_statements.md. No separatematch_patterns.mdfile seems to exist or be strictly necessary if specific pattern files are comprehensive.
Section 19: Match literal patterns#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/match_literal_patterns.md -
Findings:
-
Misclassification of
Noneand Booleans:- Documentation (
match_literal_patterns.md): Includestrue,false, andNoneas examples of literal patterns. - Grammar: Defines
literal_patternas(INT | FLOAT | multistring)andsingleton_patternas(NULL | BOOL). - Issue: Major inconsistency.
Noneand booleans are grammaticallysingleton_patterns and should be documented there, not under literal patterns.
- Documentation (
-
Coverage of
INT,FLOAT,STRING:- Numeric Literals (
INT,FLOAT): Documented examples cover decimal integers, floats, and different integer bases (hex, binary, octal), aligning with the grammar. - Status: Covered.
- String Literals (
multistring):- Documentation shows simple string literals (e.g.,
case "hello":). - The grammar
multistring: (fstring | STRING)+allows for f-strings or concatenated strings. The behavior/validity of f-strings (which usually involve runtime interpolation) or concatenated strings as patterns is not clarified in this document. - Issue (Minor/Clarification): The documentation should clarify if
fstringor concatenated strings are valid inliteral_patternand how they are treated (e.g., if f-strings must resolve to constants at compile time). - Status (Simple Strings): Covered.
- Documentation shows simple string literals (e.g.,
- Numeric Literals (
-
Interaction with OR patterns:
- Documentation correctly shows literal patterns used within OR patterns (e.g.,
case 400 | 401:). - Status: Covered.
- Documentation correctly shows literal patterns used within OR patterns (e.g.,
-
-
Overall: The primary issue is the miscategorization of
Noneand booleans. Coverage for true literals (numbers, simple strings) is good, but clarity on advancedmultistringfeatures as patterns is needed.
Section 20: Match singleton patterns#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/match_singleton_patterns.md -
Findings:
-
Matching
None(NULLtoken):- Grammar:
NULLis part ofsingleton_pattern. - Documentation: Shows
case None: .... - Status: Covered.
- Grammar:
-
Matching Booleans (
BOOLtoken):- Grammar:
BOOLis part ofsingleton_pattern. - Documentation: Shows
case True: ...andcase False: .... - Status: Covered.
- Grammar:
-
Correct Scope:
- The documentation correctly focuses only on
None,True, andFalsefor singleton patterns, aligning with the grammar. - Status: Correct.
- The documentation correctly focuses only on
-
-
Overall: The documentation for
match_singleton_patterns.mdis accurate and consistent with the grammar.
Section 21: Match capture patterns#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/match_capture_patterns.md -
Findings:
-
Basic Capture (
NAMEas pattern):- Grammar:
capture_pattern: NAME. - Documentation: Shows examples like
case username: ...andcase temp: ...where an identifier captures the matched value. - Status: Covered.
- Grammar:
-
Wildcard
_as a Capture Pattern:- Documentation (
match_statements.md): Showscase _: .... - Grammar: If
_is a validNAMEtoken, this is consistent._as a capture pattern for unused values is a common convention. - Status: Covered (assuming
_is aNAME).
- Documentation (
-
Role in Complex Patterns:
NAME(as a capture mechanism) is also a fundamental part ofsequence_pattern,mapping_pattern, andclass_patternfor binding parts of those structures.- Documentation: Examples in this file and
match_statements.mdillustrate this (e.g.,case [x,y]:,case {"key": val}:). - Status: The broader role of
NAMEin destructuring is implicitly covered by examples of those more complex patterns.
-
-
Overall: The documentation accurately reflects the use of a simple
NAMEas a capture pattern and its basic behavior. Its role within more complex patterns is also shown through examples.
Section 22: Match sequence patterns#
- Grammar Rules from
jac.lark:sequence_pattern: LSQUARE list_inner_pattern (COMMA list_inner_pattern)* RSQUARE | LPAREN list_inner_pattern (COMMA list_inner_pattern)* RPAREN list_inner_pattern: (pattern_seq | STAR_MUL NAME) // pattern_seq -> or_pattern | as_pattern -> pattern -> specific_patterns // STAR_MUL NAME is for *rest type captures. - Corresponding Markdown File: No dedicated
match_sequence_patterns.md. Overview inmatch_statements.md("Sequence Patterns" section). -
Findings (based on
match_statements.md):-
List
[...]and Tuple(...)Patterns:- Grammar: Defines
LSQUARE ... RSQUAREandLPAREN ... RPAREN. - Documentation (
match_statements.md): Shows list patterns (case [x,y]:). Tuple patterns are mentioned as similar but not explicitly exemplified with(...)in that section. - Status: List patterns covered. Tuple patterns implicitly covered but could have a direct example.
- Grammar: Defines
-
list_inner_pattern(elements within the sequence):- Grammar: Each element can be a
pattern_seq(complex pattern) orSTAR_MUL NAME(*rest). - Documentation (
match_statements.md): Examplescase [x,y]:(elements are capture patterns) andcase [first, *rest]:(capture and star expression) cover basic cases. - The ability for an inner element to be a more complex
pattern_seq(e.g.,case [val1 | val2, another_val]:orcase [[a,b], c]:) is not explicitly shown in the overview. - Status: Basic inner elements (captures, star expressions) are covered. Complex nested patterns as elements are not explicitly detailed in the overview.
- Grammar: Each element can be a
-
Matching Empty Sequences (
[],()):- Grammar:
list_inner_pattern (COMMA list_inner_pattern)*implies at least one item is required in the pattern. - Documentation (
match_statements.md): Examples show patterns with one or more elements. Matching empty lists/tuples (e.g.,case []:) is not shown or discussed. - Issue/Clarification Needed: The grammar seems to require at least one element in sequence patterns. If matching empty sequences like
[]or()is supported, the mechanism (whether by this rule through some interpretation or a different rule) needs to be clarified in grammar or documentation.
- Grammar:
-
-
Overall:
match_statements.mdintroduces basic list sequence patterns, capture of elements, and star expressions. Tuple patterns are less explicitly shown. The full recursive power oflist_inner_patternand matching of empty sequences are areas needing more detailed documentation or clarification against the grammar.
Section 23: Match mapping patterns#
-
Grammar Rules from
jac.lark(relevant):(Note: Amapping_pattern: LBRACE (dict_inner_pattern (COMMA dict_inner_pattern)*)? RBRACE dict_inner_pattern: (literal_pattern COLON pattern_seq | STAR_POW NAME) // literal_pattern for key: (INT | FLOAT | multistring) // pattern_seq for value: or_pattern | as_pattern -> pattern -> specific_patterns // STAR_POW NAME is for **rest captures.list_inner_patternrule appears under this heading injac.larkbut seems misplaced and is ignored for this section.) -
Corresponding Markdown File: No dedicated
match_mapping_patterns.md. Overview inmatch_statements.md("Mapping Patterns" section). -
Findings (based on
match_statements.md):-
Dictionary/Mapping Pattern
{...}:- Grammar:
LBRACE (dict_inner_pattern (COMMA dict_inner_pattern)*)? RBRACE. The trailing?on the group allows for empty mapping patterns ({}). - Documentation (
match_statements.md): Shows examples likecase {"host": host, "port": port}:. Does not explicitly show matching an empty dictionarycase {}:. - Status: Non-empty mapping patterns covered. Empty mapping pattern
{}is allowed by grammar but not explicitly documented in the overview.
- Grammar:
-
dict_inner_pattern(key-value or**rest):- Key-Value Pair (
literal_pattern COLON pattern_seq):- Documentation shows simple string literal keys and capture patterns for values (e.g.,
{"host": host}). - The use of more complex
pattern_seqfor values (e.g.,{"data": [x,y]}) is implied by grammar but not explicitly shown in this section's examples. - Status: Basic key-value matching covered.
- Documentation shows simple string literal keys and capture patterns for values (e.g.,
- Star-Star Expression (
STAR_POW NAMEfor**rest):- Documentation shows
case {"url": url, **options}:. - Status: Covered.
- Documentation shows
- Key-Value Pair (
-
Multiple Key-Value Pairs / Optional Content:
- Grammar:
(dict_inner_pattern (COMMA dict_inner_pattern)*)?allows zero or more elements. - Documentation: Examples show multiple elements. The case of zero elements (empty map
{}) is not explicitly shown. - Status: Covered for non-empty. Empty map matching implied by grammar but not shown.
- Grammar:
-
Keys as
literal_pattern(Non-string keys):- Grammar: Keys are
literal_pattern(INT | FLOAT | multistring). - Documentation: All examples use string literal keys.
- Issue (Minor/Clarification): Use of non-string literal keys (e.g.,
case {10: val}:) is grammatically possible but not documented in the overview. This is a less common case.
- Grammar: Keys are
-
-
Overall:
match_statements.mdintroduces basic mapping patterns well. Matching empty dictionaries and using non-string literal keys are grammatically allowed but not explicitly shown in the overview. The full power ofpattern_seqfor matching values is also implied rather than exhaustively demonstrated in this section.
Section 24: Match class patterns#
- Grammar Rules from
jac.lark:class_pattern: NAME (DOT NAME)* LPAREN kw_pattern_list? RPAREN // Variant 1: Only keyword patterns | NAME (DOT NAME)* LPAREN pattern_list (COMMA kw_pattern_list)? RPAREN // Variant 2: Positional and optional keyword pattern_list: (pattern_list COMMA)? pattern_seq // For positional argument patterns kw_pattern_list: (kw_pattern_list COMMA)? named_ref EQ pattern_seq // For keyword argument patterns (attr_name = value_pattern) // NAME (DOT NAME)* is the class type (e.g., MyClass, module.MyClass). // pattern_seq for values can be complex. - Corresponding Markdown File: No dedicated
match_class_patterns.md. Overview inmatch_statements.md("Class Patterns" section). -
Findings (based on
match_statements.md):-
Basic Class Pattern Syntax
ClassName(...):- Documentation (
match_statements.md): Showscase Circle(radius=r):. Covers simple class names. - Qualified class names (e.g.,
module.ClassName) are allowed byNAME (DOT NAME)*in grammar but not explicitly shown in this overview. - Status: Basic structure with simple names covered.
- Documentation (
-
Keyword Argument Patterns (
attr=pattern):- Grammar: Covered by
kw_pattern_list. - Documentation (
match_statements.md): Examples likeCircle(radius=r)andRectangle(width=w, height=h)clearly demonstrate this. - Status: Covered.
- Grammar: Covered by
-
Positional Argument Patterns:
- Grammar: Covered by
pattern_listin the second variant ofclass_pattern. - Documentation (
match_statements.md): This overview does not show examples of positional patterns (e.g.,case MyClass(pattern_for_arg1, pattern_for_arg2):). - Issue: Positional patterns in class matching are not documented in the overview.
- Grammar: Covered by
-
Combination of Positional and Keyword Patterns:
- Grammar: Allowed by the second variant of
class_pattern. - Documentation: Not shown, as positional patterns themselves are not shown.
- Issue: Not documented.
- Grammar: Allowed by the second variant of
-
Matching Type Only (
ClassName()):- Grammar: Seems possible via the first
class_patternvariant ifkw_pattern_listis omitted (due to?). - Documentation (
match_statements.md): Does not show an example likecase MyClass():for type-only matching. - Issue (Minor/Clarification): Type-only matching is a common use case and an explicit example would be beneficial.
- Grammar: Seems possible via the first
-
Complex
pattern_seqfor Attribute Values:- Grammar: Allows complex patterns for attribute values (e.g.,
radius=(val1 | val2)ordata=[x,y]). - Documentation (
match_statements.md): Examples use simple capture patterns (e.g.,radius=r). Matching attributes against more complex nested patterns is not explicitly shown in the overview. - Status: Basic capture of attribute values covered. Complex patterns for attribute values implied by grammar but not detailed in overview.
- Grammar: Allows complex patterns for attribute values (e.g.,
-
-
Overall: The
match_statements.mdoverview introduces class patterns focusing on keyword-based attribute matching. Positional attribute matching, type-only matching, and matching attributes against more complex patterns are not explicitly covered in this overview but are allowed by the grammar.
Section 25: Context managers#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/context_managers.md -
Findings:
-
Basic
withstatement (with expr as varandwith expr):- Grammar:
KW_WITH expr_as_list code_block.expr_ascan optionally haveKW_AS expression. - Documentation: Shows both
with open(...) as file:andwith self.lock:. Covers cases with and withoutas var. - Status: Covered.
- Grammar:
-
KW_ASYNCwithwithstatement:- Grammar:
KW_ASYNC? KW_WITH .... - Documentation: Shows
async with ... as .... - Status: Covered.
- Grammar:
-
Multiple context managers (
with expr1 as var1, expr2 as var2):- Grammar:
expr_as_list: (expr_as COMMA)* expr_as. - Documentation: Shows examples with multiple context managers in one
withstatement. - Status: Covered.
- Grammar:
-
Variable in
expr_as(Target ofKW_AS expression):- Grammar:
KW_AS expression. Allows the target to be anexpression. - Documentation: All examples show
... as variable_name(a simpleNAME). - Issue/Clarification: The grammar is broader, potentially allowing targets like
my_obj.attror even de-structuring assignments if theexpressionrule and semantic analysis permit. The documentation only shows simple name targets. If only simple names are intended or idiomatic, this could be clarified, or the grammar for the target ofKW_ASmight be more specific in practice.
- Grammar:
-
Custom Context Managers (Defining
__enter__,__exit__):- Documentation: Provides good examples of creating custom context manager objects.
- Status: Well covered.
-
-
Overall: The documentation aligns well with the grammar for common uses. The main point needing potential clarification is the scope of the
expressionallowed as the target variable afterKW_AS.
Section 26: Global and nonlocal statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/global_and_nonlocal_statements.md -
Findings:
-
Global Statement Syntax (
:g:,:global:):- Grammar:
GLOBAL_OP name_list. - Documentation: Shows syntax with
:g:and:global:, and examples with single and multiple variables. - Status: Covered.
- Grammar:
-
Nonlocal Statement Syntax (
:nl:,:nonlocal:):- Grammar:
NONLOCAL_OP name_list. - Documentation: Shows syntax with
:nl:and:nonlocal:, and examples with single and multiple variables. - Status: Covered.
- Grammar:
-
name_list(List of variables):- Grammar:
(named_ref COMMA)* named_ref. - Documentation: Examples use simple variable names, which is typical.
- Status: Covered for typical usage.
- Grammar:
-
Statement Termination (Semicolon):
- Grammar: Requires a
SEMIas these are statements (global_ref SEMI,nonlocal_ref SEMI). - Documentation: The syntax overview correctly includes semicolons (e.g.,
:g: counter, total;). However, some inline code examples in the text body occasionally omit the semicolon. - Issue (Minor Inconsistency): Some examples in the text body should be updated to consistently include the trailing semicolon for these statements.
- Grammar: Requires a
-
-
Overall: The documentation accurately describes the global and nonlocal statements. The primary minor issue is the inconsistent presence of semicolons in some textual examples, which should be rectified for grammatical accuracy.
Section 27: Data spatial typed context blocks#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/data_spatial_typed_context_blocks.md -
Findings:
-
Syntax
-> type_expression { ... }:- Grammar:
RETURN_HINT expression code_block. - Documentation: Correctly shows the syntax
-> type_expression { ... }and provides examples like-> dict[str, any] { ... }. - Status: Covered.
- Grammar:
-
Purpose and Usage (Type-Constrained Scope):
- Documentation: Explains its use for compile-time and runtime type assertions within the block, especially for object-spatial operations (e.g., constraining
here.data). - Status: Well-explained.
- Documentation: Explains its use for compile-time and runtime type assertions within the block, especially for object-spatial operations (e.g., constraining
-
As a Statement:
- Grammar:
typed_ctx_blockis astatement. - Documentation: Examples show its use within ability bodies. Its ability to be used in other nested contexts (e.g., inside an
if) is implied by its nature as a statement. - Status: Primary usage covered.
- Grammar:
-
Interaction with Ability Return Types:
- Documentation: The section "Return Type Enforcement" shows a
typed_ctx_blockwithin an ability that has a return type, with thereturnstatement inside the typed block. - Clarification Needed: The phrasing about the block "guaranteeing" the return type might be slightly imprecise. The block enforces type constraints on the code within it. If a
returnstatement is inside this block, the returned value will be checked against the block's type. The block itself isn't a return mechanism but a type-constrained scope. - Status: Example is valid; explanation could be more precise about the mechanism of enforcement.
- Documentation: The section "Return Type Enforcement" shows a
-
-
Overall: The documentation clearly explains the syntax and primary purpose. The explanation of its role in return type enforcement is understandable through the example but could be refined for precision.
Section 28: Return statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/return_statements.md -
Findings:
-
Return with an expression (
return expression;):- Grammar Form:
KW_RETURN expression SEMI. - Documentation: Shows
return expression;and provides numerous examples. - Status: Covered.
- Grammar Form:
-
Return without an expression (
return;for void functions/abilities):- Grammar Form:
KW_RETURN SEMI. - Documentation: Shows
return;and explains it yieldsNone. - Status: Covered.
- Grammar Form:
-
Statement Termination (Semicolon):
- Grammar: Requires a
SEMIwhen used as a statement. - Documentation: Syntax overview and most examples correctly include the semicolon.
- Status: Covered.
- Grammar: Requires a
-
Nature of
expression:- Grammar:
expressioncan be any valid Jac expression. - Documentation: Examples show various types of expressions being returned (literals, variables, calculations, tuples, dictionaries).
- Status: Well covered.
- Grammar:
-
-
Overall: The documentation for
return_stmtis comprehensive and accurately reflects the grammar and common usage patterns.
Section 29: Yield statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/yield_statements.md -
Findings:
-
Yield an expression (
yield expression;):- Grammar Form:
KW_YIELD expression SEMI. - Documentation: Shows
yield expression;and provides numerous examples. - Status: Covered.
- Grammar Form:
-
Bare yield / Yield None (
yield;):- Grammar Form:
KW_YIELD SEMI. - Documentation: Shows
yield;and explains it yieldsNone. - Status: Covered.
- Grammar Form:
-
Yield from an iterable (
yield from expression;):- Grammar Form:
KW_YIELD KW_FROM expression SEMI. - Documentation: Shows
yield from iterable;and provides examples with other generators and collections. - Status: Covered.
- Grammar Form:
-
Statement Termination (Semicolon):
- Grammar: All forms require a
SEMIwhen used as a statement. - Documentation: Syntax overview and most examples correctly include the semicolon.
- Status: Generally covered.
- Grammar: All forms require a
-
Generator Function Characteristics:
- Documentation: Accurately describes how functions with
yieldbecome generators, their execution model, and state persistence. - Status: Well explained.
- Documentation: Accurately describes how functions with
-
-
Overall: The documentation for yield statements and generator functions is comprehensive and aligns accurately with the grammar rules.
Section 30: Raise statements#
- Grammar Rules from
jac.lark:raise_stmt: KW_RAISE (expression (KW_FROM expression)?)? // Used in statement rule as: raise_stmt SEMI // This resolves to three forms for statements: // 1. KW_RAISE expression SEMI (raise new/specific exception) // 2. KW_RAISE SEMI (re-raise current exception) // 3. KW_RAISE expression KW_FROM expression SEMI (raise new with cause) - Corresponding Markdown File:
jac/examples/reference/raise_statements.md -
Findings:
-
Raise a specific exception (
raise expression;):- Grammar Form:
KW_RAISE expression SEMI. - Documentation: Shows
raise exception_expression;and provides examples likeraise ValueError(...). - Status: Covered.
- Grammar Form:
-
Re-raise current exception (
raise;):- Grammar Form:
KW_RAISE SEMI. - Documentation: Shows
raise;and explains its use inexceptblocks. - Status: Covered.
- Grammar Form:
-
Raise with cause (
raise expression from cause_expression;):- Grammar Form:
KW_RAISE expression KW_FROM expression SEMI. - Documentation: Shows
raise exception_expression from cause;and examples with an exception variable orNoneas the cause. - Status: Covered.
- Grammar Form:
-
Statement Termination (Semicolon):
- Grammar: All forms require a
SEMIwhen used as a statement. - Documentation: Syntax overview and most examples correctly include the semicolon.
- Status: Generally covered.
- Grammar: All forms require a
-
Nature of
expressionfor exception/cause:- Documentation: Examples show instantiation of exception classes or existing exception variables, which is standard.
- Status: Well covered.
-
-
Overall: The documentation for raise statements is comprehensive and accurately reflects the grammar and common usage patterns for all three forms of the raise statement.
Section 31: Assert statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/assert_statements.md -
Findings:
-
Assert with condition only (
assert condition;):- Grammar Form:
KW_ASSERT expression SEMI. - Documentation: Shows
assert condition;. - Status: Covered.
- Grammar Form:
-
Assert with condition and message (
assert condition, message_expr;):- Grammar Form:
KW_ASSERT expression COMMA expression SEMI. - Documentation: Shows
assert condition, "Custom error message";. - Status: Covered.
- Grammar Form:
-
Statement Termination (Semicolon):
- Grammar: Requires a
SEMIwhen used as a statement. - Documentation: Syntax examples correctly include the semicolon.
- Status: Covered.
- Grammar: Requires a
-
Nature of
expressionfor condition and message:- Documentation: Condition is shown as a boolean expression; message is shown as a string literal. This is typical.
- Status: Covered for typical usage.
-
-
Overall: The documentation for assert statements is clear, concise, and accurately aligns with the grammar and common usage.
Section 32: Check statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/check_statements.md -
Findings:
-
Basic Syntax (
check expression;):- Grammar Form:
KW_CHECK expression SEMI. - Documentation: Shows
check expression;. - Status: Covered.
- Grammar Form:
-
Nature of
expression:- Documentation: Explains the expression should be truthy. Examples show various boolean conditions.
- Status: Well covered.
-
Integration with Test Blocks:
- Documentation: Emphasizes use within
testblocks. - Status: Contextual usage well explained.
- Documentation: Emphasizes use within
-
Statement Termination (Semicolon):
- Grammar: Requires a
SEMI. - Documentation: Syntax and examples correctly include the semicolon.
- Status: Covered.
- Grammar: Requires a
-
-
Overall: The documentation for
check_stmtis clear and aligns well with the grammar, properly explaining its use in testing.
Section 33: Delete statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/delete_statements.md -
Findings:
-
Basic Syntax (
del expression;):- Grammar:
KW_DELETE expression SEMI. - Documentation: Shows
del expression;. - Status: Covered.
- Grammar:
-
Nature of
expression(What can be deleted):- Documentation: Provides good examples for deleting variables, object properties, list elements/slices, dictionary entries, and nodes.
- Status: Well covered for many common cases.
-
Deleting Multiple Variables (
del a, b, c;):- Documentation shows:
del a, b, c;. - Grammar
delete_stmt:KW_DELETE expressionexpects a single expression. - Issue/Inconsistency: The example
del a, b, c;doesn't directly map toKW_DELETE expressionifexpressiondoesn't support a top-level comma-separated list of deletable items. Python'sdeldoes support this. This might implyexpressioncan be a tuple of references or a special parsing fordel.
- Documentation shows:
-
Deleting Edges (Specific Syntaxes):
- Documentation shows:
del source_node -->:EdgeType:--> target_node;anddel node [-->];. - Grammar: These edge specifications are forms of
edge_ref_chain(an expression). Sodel <edge_ref_chain_expr>;would fit thedelete_stmtrule. - The grammar also has
disconnect_op: KW_DELETE edge_op_refused withinconnectexpressions, which is different. The documentation examples appear to be standalone statements, fittingdelete_stmt. - Status: Likely covered by
delete_stmtif the edge specification is a validexpressionyielding the edge(s) to delete. Clarity on whether these specific syntaxes always resolve to an expression suitable for the generaldel expressionstatement would be good.
- Documentation shows:
-
Statement Termination (Semicolon):
- Grammar: Requires
SEMI. - Documentation: Syntax overview and most examples include the semicolon.
- Status: Generally covered.
- Grammar: Requires
-
-
Overall: The documentation covers many uses of
del. The main ambiguity lies in thedel a, b, c;syntax relative to the grammar and how specific edge deletion syntaxes are parsed as theexpressionindel expression.
Section 35: Control statements#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/control_statements.md -
Findings:
-
KW_BREAK(break statement):- Grammar:
KW_BREAK SEMI. - Documentation: Explains usage and provides examples.
- Status: Covered.
- Grammar:
-
KW_CONTINUE(continue statement):- Grammar:
KW_CONTINUE SEMI. - Documentation: Explains usage and provides examples.
- Status: Covered.
- Grammar:
-
KW_SKIP(skip statement):- Grammar:
KW_SKIP SEMI. Listed as a generalctrl_stmt. - Documentation (
control_statements.md): Statesskipis a "Data spatial equivalent for walker traversal control (covered in walker statements documentation)" and does not detail it further in this file. - Issue/Clarification Needed: If
KW_SKIPis a general control statement (likebreak/continue), its documentation is missing here. If it's exclusively for walker contexts, its placement in the grammar under the generalctrl_stmt(rather than a more walker-specific rule) could be refined for clarity. The current documentation defers its explanation.
- Grammar:
-
Statement Termination (Semicolon):
- Grammar: Requires
SEMIforctrl_stmt. - Documentation: Examples for
break;andcontinue;correctly include the semicolon. - Status: Covered for
breakandcontinue.
- Grammar: Requires
-
-
Overall:
breakandcontinueare well-documented. The documentation forskipis deferred. The main point is ensuring its grammatical classification aligns with its intended scope of use (general control flow vs. walker-specific).
Section 36: Data spatial Walker statements#
- Grammar Rules from
jac.lark:spatial_stmt: visit_stmt | ignore_stmt | disenage_stmt // Likely typo for disengage_stmt // These are then defined as: // visit_stmt: KW_VISIT (COLON expression COLON)? expression (else_stmt | SEMI) // ignore_stmt: KW_IGNORE expression SEMI // disenage_stmt: KW_DISENGAGE SEMI // KW_DISENGAGE is "disengage" // spatial_stmt is a type of statement, implying it uses SEMI if not ending in a block. - Corresponding Markdown File:
jac/examples/reference/data_spatial_walker_statements.md -
Findings:
-
General Overview: The document correctly introduces
visit,ignore, anddisengageas key walker control statements. -
visit_stmt:- Grammar:
KW_VISIT (COLON expression COLON)? expression (else_stmt | SEMI). - Documentation Syntax shows:
visit expression;(matches grammar: no filter, withSEMI).visit :expression: expression;(matches grammar: with filter, withSEMI).visit expression else { ... }(matches grammar: no filter, withelse_stmt).
- Missing Combination: An example combining the edge filter and an
elseclause (e.g.,visit :filter_expr: target_expr else { ... };) is not explicitly shown, though allowed by grammar. - Status: Mostly covered. Semicolons should be explicit in syntax definitions.
- Grammar:
-
ignore_stmt:- Grammar:
KW_IGNORE expression SEMI. - Documentation Syntax:
ignore expression;(semicolon is appropriate). - Status: Covered.
- Grammar:
-
disengage_stmt(Grammar typodisenage_stmt):- Grammar:
disenage_stmt: KW_DISENGAGE SEMI. Assumingdisenage_stmtis a typo fordisengage_stmt. - Documentation Syntax:
disengage;(semicolon is appropriate). - Keyword: Documentation
disengagematchesKW_DISENGAGEtoken. - Status: Covered (assuming grammar rule name typo is fixed).
- Grammar:
-
Statement Termination (Semicolon):
- The individual grammar rules for
ignore_stmtanddisengage_stmtcorrectly includeSEMI.visit_stmtcan end inSEMIor anelse_stmt(block). - Documentation: Generally reflects this, though syntax summaries could be more explicit about semicolons for
ignoreand filteredvisitif not ending inelse. - Status: Generally correct.
- The individual grammar rules for
-
-
Overall: The documentation aligns well with the individual grammar rules for
visit,ignore, anddisengage(assuming thedisenage_stmttypo correction). The purpose of these statements in walker control is clearly explained.
Section 37: Visit statements#
- Grammar Rule:
visit_stmt: KW_VISIT (COLON expression COLON)? expression (else_stmt | SEMI) - Corresponding Markdown File:
jac/examples/reference/visit_statements.md - Findings:
- This statement was analyzed as part of Section 36: Data spatial Walker statements.
- The
visit_statements.mdfile reiterates the common forms:visit expression;andvisit expression else { ... }. - It mentions edge filtering but does not prominently feature the
visit :filter_expr: target_expr;syntax in its own syntax block, nor the combination of filtering with anelseclause. - Overall: The specific documentation is consistent with the broader points made in Section 36. The primary uncovered grammatical combination is
visit :filter: target else { ... };.
Section 38: Ignore statements#
- Grammar Rule:
ignore_stmt: KW_IGNORE expression SEMI - Corresponding Markdown File:
jac/examples/reference/ignore_statements.md - Findings:
- This statement was analyzed as part of Section 36: Data spatial Walker statements.
- The
ignore_statements.mdfile is consistent with the grammar, showingignore expression;. - Overall: Consistent with Section 36 and the grammar.
Section 39: Disengage statements#
- Grammar Rule:
disenage_stmt: KW_DISENGAGE SEMI(Assumingdisenage_stmtis a typo fordisengage_stmt) - Corresponding Markdown File:
jac/examples/reference/disengage_statements.md - Findings:
- This statement was analyzed as part of Section 36: Data spatial Walker statements.
- The
disengage_statements.mdfile is consistent with the grammar (assuming typo fix), showingdisengage;. - Overall: Consistent with Section 36 and the grammar (with typo assumption).
Section 40: Assignments#
- Grammar Rules from
jac.lark:assignment: KW_LET? (atomic_chain EQ)+ (yield_expr | expression) // Form 1 | atomic_chain type_tag (EQ (yield_expr | expression))? // Form 2 | atomic_chain aug_op (yield_expr | expression) // Form 3 aug_op: RSHIFT_EQ | LSHIFT_EQ | BW_NOT_EQ | BW_XOR_EQ | BW_OR_EQ | BW_AND_EQ | MOD_EQ | DIV_EQ | FLOOR_DIV_EQ | MUL_EQ | SUB_EQ | ADD_EQ | MATMUL_EQ | STAR_POW_EQ // Used in statement rule as: assignment SEMI - Corresponding Markdown File:
jac/examples/reference/assignments.md -
Findings:
-
Form 1 (Basic/Chained Assignment
[let] x = y = z = value):- Basic assignment (
value = 42;): Covered. - Chained assignment (
x = y = z = 0;): Covered. letwith basic assignment (let counter = 0;): Covered.letwith chained assignment (e.g.,let x = y = 0;): Not explicitly shown, though grammatically allowed. Minor omission.
- Basic assignment (
-
Form 2 (Typed Assignment/Declaration
x: type [= value]):- Typed assignment with initialization (
let count: int = 0;): Covered. - Typed declaration without immediate initialization (
let my_var: str;): Not explicitly exemplified, though grammatically allowed by(EQ ...)?. - Issue: Typed declaration without init is not shown.
- Typed assignment with initialization (
-
Form 3 (Augmented Assignment
x += value):- Documentation: Covers Arithmetic, Bitwise, and Matrix augmented assignments with examples.
- Status: Well covered.
-
yield_expron RHS of Assignment:- Grammar: Allows
yield_expr(e.g.,x = yield val;). - Documentation: Does not show examples of assigning
yieldoryield fromexpressions. - Issue: Assignment of
yield_expris not documented.
- Grammar: Allows
-
Destructuring Assignment:
- Documentation shows:
let (x, y) = coordinates;andlet (first, *rest) = items;. These are standard and likely parsable byatomic_chainon LHS. - Documentation also shows:
let (name=user, age=years) = user_data;. This syntax for LHS destructuring is highly unconventional for assignment and resembles keyword argument patterns in calls or match cases. Its parsing viaatomic_chainas an LHS target is unclear. - Issue/Inconsistency: The
(name=user, age=years) = ...destructuring syntax is problematic for assignment and needs clarification or correction in the documentation to align with typical LHS assignment capabilities or Jac-specific rules if it is indeed valid.
- Documentation shows:
-
Statement Termination (Semicolon):
- Grammar:
assignment SEMI. - Documentation: Examples correctly include semicolons.
- Status: Covered.
- Grammar:
-
-
Overall: Common assignments are well-documented. Areas for improvement include:
letwith chained assignment, typed declaration without init, assignment ofyield_expr, and significant clarification/correction for the(name=user, age=years)destructuring assignment example.
Section 41: Expressions (Top-Level Rule)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/expressions.md -
Findings:
-
Conditional Expression (Ternary
... if ... else ...):- Grammar:
concurrent_expr (KW_IF expression KW_ELSE expression)?. - Documentation: Lists and exemplifies conditional expressions (
result = value if condition else alternative;). - Status: Covered.
- Grammar:
-
Lambda Expression (
lambda_expr):- Grammar:
lambda_expris an alternative forexpression. - Documentation: Mentions lambda expressions. The example syntax
lambda n: Node : n.is_active()needs to be compared with the specificlambda_exprgrammar rule and its documentation. - Status: Mentioned; specific syntax example needs cross-verification.
- Grammar:
-
Delegation to
concurrent_exprand Hierarchy:- Grammar: If not a conditional or lambda, an
expressionis aconcurrent_expr, which then cascades to other expression types. - Documentation: The "Expression Hierarchy" list correctly reflects this delegation to more specific expression forms.
- Status: Hierarchical nature outlined.
- Grammar: If not a conditional or lambda, an
-
Nature of
expressions.mdDocument:- Provides a high-level overview, lists precedence categories, and gives basic examples. It defers detailed explanations of specific expression types to their own sections/documents.
- Status: Serves as a suitable introduction.
-
-
Overall: The
expressions.mdfile correctly introduces the top-level structure of Jac expressions and the hierarchy. Detailed analysis of each expression type will follow in subsequent sections based on their specific grammar rules and documentation.
Section 42: Concurrent expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/concurrent_expressions.md -
Findings:
-
KW_FLOWmodifier (flow expression):- Grammar:
KW_FLOW walrus_assign. - Documentation: Explains and shows
flowused to initiate parallel execution of expressions (typically function calls orspawn). - Status: Covered.
- Grammar:
-
KW_WAITmodifier (wait expressionorvar = wait expression):- Grammar:
KW_WAIT walrus_assign. - Documentation: Explains and shows
waitused to synchronize and retrieve results from parallel operations/futures. - Status: Covered.
- Grammar:
-
No modifier (plain
walrus_assign):- Grammar:
concurrent_exprdefaults towalrus_assignif no keyword is present. - Documentation: This is the standard non-concurrent expression path, implicitly covered as the base.
- Status: Implicitly covered.
- Grammar:
-
Nature of
walrus_assignwithflow/wait:- Documentation: Examples focus on applying
flowandwaitto operations like function calls,spawn, or variables holding task/future references, which are sensible uses. - Status: Aligns with practical usage.
- Documentation: Examples focus on applying
-
-
Overall: The documentation for
concurrent_expr, particularly theflowandwaitkeywords, effectively explains their purpose and usage in enabling concurrency, and is consistent with the grammar.
Section 43: Walrus assignments#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/walrus_assignments.md -
Findings:
-
With
named_ref WALRUS_EQ(e.g.,(name := expression)):- Grammar:
named_ref WALRUS_EQ pipe. - Documentation: Clearly shows and explains usage like
if (count := len(items)) > 0 { ... }. - Status: Covered.
- Grammar:
-
Without
named_ref WALRUS_EQ(plainpipeexpression):- Grammar:
walrus_assigndefaults topipeif(named_ref WALRUS_EQ)?is absent. - Documentation: This is the standard expression path, implicitly covered as the base for walrus assignment.
- Status: Implicitly covered.
- Grammar:
-
named_refas target:- Grammar: Target is
named_ref. - Documentation: Examples use simple variable names, which is typical.
- Status: Covered for typical usage.
- Grammar: Target is
-
Scope of Walrus-Assigned Variable:
- Documentation: Correctly states variables extend beyond the immediate expression scope, following standard scoping rules.
- Status: Behavior explained.
-
-
Overall: The documentation for walrus assignments (
:=) is clear, consistent with the grammar, and accurately explains its common use cases and scoping rules.
Section 44: Lambda expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/lambda_expressions.md -
Findings:
-
Basic Syntax (
lambda params : expression):- Documentation: Shows
lambda a: int, b: int : b + a;. This aligns with the grammar where parameters require type annotations (named_ref type_tag). - Status: Covered.
- Documentation: Shows
-
Advanced Parameter Features (
func_decl_params?):- Grammar:
func_decl_params?(andparam_vardetails) allow for:- No parameters (e.g.,
lambda : "value"). *args,**kwargs.- Default parameter values (e.g.,
lambda x: int = 5 : x).
- No parameters (e.g.,
- Documentation (
lambda_expressions.md): Does not exemplify these variations for lambdas. It emphasizes mandatory type annotations for named parameters shown. - Issue: Undocumented features for lambda parameters (no-params, args/*kwargs, default values) if they are intended to be supported as per the shared
func_decl_paramsrule.
- Grammar:
-
Explicit Return Type Annotation (
(RETURN_HINT expression)?):- Grammar: Allows an optional explicit return type (e.g.,
lambda x: int -> int : x * 2). - Documentation (
lambda_expressions.md): States return types are inferred and does not show the syntax for explicit return type annotation on lambdas. - Issue: Explicit return type annotation for lambdas is not documented.
- Grammar: Allows an optional explicit return type (e.g.,
-
Lambda Body (Single
expression):- Grammar:
COLON expression. - Documentation: Correctly states and shows that the lambda body is limited to a single expression.
- Status: Covered.
- Grammar:
-
Inconsistent Lambda Example in
expressions.md:- The example
lambda n: Node : n.is_active()fromexpressions.mduses a syntax (param_name : param_type_name : body) that is inconsistent with theparam_varrule (named_ref type_tag, wheretype_tagis: type_expr) and the examples inlambda_expressions.md(which correctly showlambda name: type : body). - Issue: The lambda example in
expressions.mdneeds correction to align with the formal grammar and the dedicated lambda documentation.
- The example
-
-
Overall:
lambda_expressions.mdcovers basic lambdas with typed parameters. However, it omits several parameter features and explicit return types that the grammar seems to permit. The example inexpressions.mdis also inconsistent.
Section 45: Pipe expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/pipe_expressions.md -
Findings:
-
Forward Pipe Operator
|>(PIPE_FWD):- Grammar:
pipe PIPE_FWD pipe_back(left-recursive structure). - Documentation: Explains it passes the left expression's result as the first argument to the right expression. Numerous examples show chaining
expr |> func1 |> func2. - Status: Covered.
- Grammar:
-
Base of the Pipe (
pipe_back):- Grammar: If no
PIPE_FWDis used,piperesolves topipe_back. - Documentation: The initial data/expression in a pipe chain, or expressions not using pipes, are implicitly this base case.
- Status: Implicitly covered.
- Grammar: If no
-
Associativity and Structure:
- The grammar implies left-associativity for
|>(e.g.,(a |> b) |> c). - Documentation: Examples and textual descriptions align with this left-to-right flow.
- Status: Consistent.
- The grammar implies left-associativity for
-
Operands of
|>:- Documentation: Shows piping into named functions, lambdas, and object methods.
- Status: Common use cases well demonstrated.
-
-
Overall: The documentation for the forward pipe operator
|>is excellent, clearly explaining its syntax, semantics, and benefits with diverse examples. It aligns well with the grammar.
Section 46: Pipe back expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/pipe_back_expressions.md -
Findings:
-
Backward Pipe Operator
<|(PIPE_BKWD):- Grammar:
pipe_back PIPE_BKWD bitwise_or(left-recursive structure for the operator itself). - Documentation: Explains it passes the right expression's result as an argument (conventionally the last) to the left expression/function. Examples show right-to-left data flow:
result = format <| process <| data;. - Status: Covered.
- Grammar:
-
Base of the Pipe Back (
bitwise_or):- Grammar: If no
PIPE_BKWDis used,pipe_backresolves tobitwise_or. - Documentation: The rightmost data/expression in a
<|chain is implicitly this base case. - Status: Implicitly covered.
- Grammar: If no
-
Associativity and Data Flow:
- The grammar implies left-associativity for the
<|operator:( (c <| b) <| a ). - The documented data flow is right-to-left, which is achieved by how the arguments are passed. This is consistent.
- Status: Consistent.
- The grammar implies left-associativity for the
-
Operands of
<|:- Documentation: Examples show callables (functions/methods) on the left and data/results on the right.
- Status: Common use cases demonstrated.
-
Combining with Forward Pipes
|>:- Documentation: Shows examples of combining
<|and|>using parentheses for grouping, e.g.,formatter <| (data |> clean |> transform). - Status: Covered.
- Documentation: Shows examples of combining
-
-
Overall: The documentation for the backward pipe operator
<|effectively explains its syntax, right-to-left data flow semantics, and contrasts it with the forward pipe. It aligns well with the grammar.
Section 47: Bitwise expressions#
- Grammar Rules from
jac.lark:bitwise_or: (bitwise_or BW_OR)? bitwise_xor bitwise_xor: (bitwise_xor BW_XOR)? bitwise_and bitwise_and: (bitwise_and BW_AND)? shift shift: (shift (RSHIFT | LSHIFT))? logical_or // `logical_or` here is likely a placeholder for a higher precedence numerical term. // Unary BW_NOT is in `factor`: (BW_NOT | MINUS | PLUS) factor | connect // BW_OR: "|", BW_XOR: "^", BW_AND: "&", RSHIFT: ">>", LSHIFT: "<<", BW_NOT: "~" - Corresponding Markdown File:
jac/examples/reference/bitwise_expressions.md -
Findings:
-
Binary Bitwise Operators (
&,|,^,<<,>>):- Grammar: Defines rules giving precedence:
shift>&>^>|. - Documentation: Covers all these operators with examples and correct precedence.
- Status: Covered and consistent.
- Grammar: Defines rules giving precedence:
-
Unary Bitwise NOT (
~):- Grammar: Defined in
factorrule, giving it high precedence. - Documentation: Covers
~with an example and places it highest in bitwise precedence. - Status: Covered and consistent.
- Grammar: Defined in
-
Operand for Shift Operators (Grammar's
logical_or):- Grammar:
shift: (shift (RSHIFT | LSHIFT))? logical_or. - The use of
logical_oras the operand forshiftis unusual if it refers to the boolean logical OR operation, due to precedence. It likely refers to a higher-precedence term that evaluates to a number. - Documentation: Examples use integer literals as operands for shifts (e.g.,
5 << 1), which is standard. - Issue (Potential Grammar Ambiguity/Typo): The term
logical_orin theshiftrule definition in the provided grammar snippet is potentially misleading. Assuming it correctly resolves to a numerical operand in the full grammar, the documentation is fine.
- Grammar:
-
-
Overall: The documentation accurately describes the standard bitwise operators and their precedence. The primary point of concern is the potentially misnamed
logical_orrule in theshiftproduction in the grammar, but the documented examples use typical numerical operands.
Section 48: Logical and compare expressions#
- Grammar Rules from
jac.lark:logical_or: logical_and (KW_OR logical_and)* logical_and: logical_not (KW_AND logical_not)* logical_not: NOT logical_not | compare compare: (arithmetic cmp_op)* arithmetic // For chained comparisons like a < b < c cmp_op: KW_ISN | KW_IS | KW_NIN | KW_IN | NE | GTE | LTE | GT | LT | EE // KW_OR: /\|\||or/, KW_AND: /&&|and/, NOT: "not" - Corresponding Markdown File:
jac/examples/reference/logical_and_compare_expressions.md -
Findings:
- Logical OR (
or,||): Covered. - Logical AND (
and,&&): Covered. -
Logical NOT (
not): Covered. -
Comparison Operators (
cmp_op):- Documentation lists:
==,!=,<,<=,>,>=,is,in. - Grammar also includes:
KW_ISN(is not) andKW_NIN(not in). - Issue:
is notandnot inare not explicitly listed as comparison operators in the documentation's summary, though they are in the grammar.
- Documentation lists:
-
Chained Comparisons (e.g.,
0 <= value <= 100):- Grammar:
(arithmetic cmp_op)* arithmeticsupports this. - Documentation: Explains and exemplifies chained comparisons.
- Status: Covered.
- Grammar:
-
Precedence:
- Grammar implies standard precedence:
compare>NOT>AND>OR. - Documentation: Does not explicitly state precedence but examples are consistent.
- Status (Minor): Explicit precedence table could be useful.
- Grammar implies standard precedence:
-
Short-Circuit Evaluation:
- Documentation: Correctly explains for
andandor. - Status: Behavior explained.
- Documentation: Correctly explains for
- Logical OR (
-
Overall: The documentation covers most logical and comparison operations well. The main omission is the explicit listing of
is notandnot inin the comparison operator summary.
Section 49: Arithmetic expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/arithmetic_expressions.md -
Findings:
-
Binary Arithmetic Operators (
+,-,*,/,//,%,**):- Grammar: Defines these with standard precedence:
**> (*,/,//,%,@) > (+,-). - Documentation: Covers all these (except
@) with correct relative precedence. - Status: Covered (except for
@).
- Grammar: Defines these with standard precedence:
-
Unary Plus/Minus (
+x,-x):- Grammar (
factorrule): Places unary+/-(and~) at a very high precedence, effectively making them part of thefactorbeforepower(**) is applied. - Documentation: States unary
+/-have precedence below**but above*//. - Issue/Inconsistency: Discrepancy in precedence of unary
+/-relative to**. Grammar implies(-2)**4, documentation implies-(2**4). Standard behavior is usually-(2**4).
- Grammar (
-
DECOR_OP(@) - Matrix Multiplication:- Grammar: Includes
DECOR_OP(@) in thetermrule, at same precedence as*,/. - Documentation (
arithmetic_expressions.md): Does not list or exemplify the@operator. - Issue: The
@(matrix multiplication) operator is not documented in this file.
- Grammar: Includes
-
Parentheses for Grouping:
- Documentation: Correctly states parentheses have the highest precedence and can be used to override defaults.
- Status: Covered.
-
-
Overall: Common binary arithmetic operators are well-documented. Key issues are the precedence of unary minus/plus with respect to exponentiation, and the omission of the
@(matrix multiplication) operator from the documentation.
Section 50: Connect expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/connect_expressions.md -
Findings:
-
Basic Connection (
source ++> destination):- Grammar:
atomic_pipe connect_op atomic_pipe(whereconnect_opisconnect_tousingCARROW_R). - Documentation: Covers simple connections like
source ++> destination. - Status: Covered.
- Grammar:
-
Typed/Property Connections (
source +>:Type:prop=val:+> dest):- Grammar: Uses detailed forms of
connect_op(e.g.,CARROW_R_P1 expression (COLON kw_expr_list)? CARROW_R_P2). - Documentation: Explains and exemplifies creating typed edges with properties.
- Status: Covered.
- Grammar: Uses detailed forms of
-
Directionality of Connections (
++>,<++,<++>):- Grammar: Handled by
connect_to,connect_from,connect_anyusingCARROW_R,CARROW_L,CARROW_BI. - Documentation: Lists these directionalities.
- Status: Covered.
- Grammar: Handled by
-
disconnect_op(KW_DELETE edge_op_ref) withinconnectexpressions:- Grammar:
disconnect_opis an alternative toconnect_opin theconnectrule, suggesting expressions likenode1 ++> node2 del node2 --> node3might be possible ifconnectexpressions can be chained and have results. - Documentation (
connect_expressions.md): Focuses on creating connections. Does not coverdisconnect_opor usingdelwith edge syntax as part of a connect expression. - Documentation (
delete_statements.md): Coversdel <edge_spec>;as a standalone statement. - Issue/Clarification Needed: The role and behavior of
disconnect_opas part of theconnectexpression rule is undocumented and potentially confusing givendelfor edges is also a standalone statement. It's unclear how an expression likeKW_DELETE edge_op_refwould evaluate or chain within aconnectexpression sequence.
- Grammar:
-
Chaining of Connect/Disconnect Operations:
- Grammar:
connect: (connect (connect_op | disconnect_op))? atomic_pipeimplies left-associative chaining. - Documentation: Shows sequential construction of chains (e.g., in loops) rather than single complex chained expressions involving multiple different operators.
- Status: Basic connection chaining is implicitly shown; complex mixed chains are not detailed.
- Grammar:
-
-
Overall: Documentation for creating connections (
connect_op) is thorough. Thedisconnect_oppart of theconnectexpression grammar is not covered in this file and its interaction as an expression component versus a standalone delete statement needs clarification.
Section 51: Atomic expressions (Atomic Pipe Forward :>)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/atomic_expressions.md -
Findings:
-
Atomic Pipe Forward Operator
:>(A_PIPE_FWD):- Grammar:
atomic_pipe A_PIPE_FWD atomic_pipe_back(left-recursive structure). - Documentation: Explains and shows the
:>operator for chaining operations, e.g.,"Hello world!" :> print;. The semantics (passing LHS as argument to RHS callable) are similar to|>. - Status: Covered.
- Grammar:
-
Base of the Atomic Pipe (
atomic_pipe_back):- Grammar:
atomic_piperesolves toatomic_pipe_backif no:>is used. - Documentation: Initial elements in a
:>chain are implicitly this base. - Status: Implicitly covered.
- Grammar:
-
Associativity:
- Grammar implies left-associativity for
:>. - Documentation: Examples like
"Welcome" :> type :> print;are consistent. - Status: Consistent.
- Grammar implies left-associativity for
-
Documentation Scope vs. Title ("Atomic expressions"):
- Documentation File Title:
atomic_expressions.md. - Content: Primarily describes the
atomic_pipe(:>) operator. - Grammar: The true "atomic" units (literals, names,
(...)) are defined under theatomrule much later in the grammar. The heading "Atomic expressions" injac.larkis immediately followed by theatomic_piperule, not rules for literals/variables directly. - Issue (Documentation Scope/Naming): The file
atomic_expressions.mddocuments the:>operator. The general intro in the doc about "fundamental and indivisible units ... literals, identifiers" better describes what the grammar callsatom. This file focuses on a specific pipe operator rather than the broad category of all atomic/primary expressions.
- Documentation File Title:
-
-
Overall: The
:>operator (atomic pipe forward) is well-documented and aligns with its grammar rule (atomic_pipe). The main point of note is that the documentation file titled "Atomic expressions" describes this specific pipe operator, not the broader category of fundamental atoms like literals or variable names, which appear under a different grammar heading ("Atom").
Section 52: Atomic pipe back expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/atomic_pipe_back_expressions.md -
Findings:
-
Atomic Pipe Back Operator
<:(A_PIPE_BKWD):- Grammar:
atomic_pipe_back A_PIPE_BKWD ds_spawn(left-recursive structure for the operator). - Documentation: Explains it passes the RHS data as an argument to the LHS callable, with right-to-left data flow (e.g.,
print <: "Hello world!";). - Status: Covered.
- Grammar:
-
Base of the Atomic Pipe Back (
ds_spawn):- Grammar:
atomic_pipe_backresolves tods_spawnif no<:is used. - Documentation: The rightmost data/expression in a
<:chain is implicitly this base. - Status: Implicitly covered.
- Grammar:
-
Associativity and Data Flow:
- Grammar implies left-associativity for the
<:operator:(func2 <: func1) <: data. - Documented data flow is right-to-left, which is consistent with evaluation order.
- Status: Consistent.
- Grammar implies left-associativity for the
-
Combining with Atomic Pipe Forward (
:>):- Documentation: Shows examples like
len <: a + b :> len;andresult = function1 <: data :> function2;. - The grammar
atomic_pipe: ... atomic_pipe_backandatomic_pipe_back: ... ds_spawnimplies<:(inatomic_pipe_back) binds tighter than:>(inatomic_pipe). This precedence is consistent with how the examples are likely intended to be parsed. - Status: Covered and consistent with grammar precedence.
- Documentation: Shows examples like
-
-
Overall: The documentation for the atomic pipe back operator
<:clearly explains its syntax and right-to-left data flow, and its interaction with the atomic pipe forward operator. It aligns well with the grammar.
Section 53: Data spatial spawn expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/data_spatial_spawn_expressions.md -
Findings:
-
KW_SPAWNOperator:- Grammar:
ds_spawn KW_SPAWN unpack(left-recursive structure for the operator). - Documentation: Explains
spawnfor activating walkers. Shows bothwalker_instance spawn location;andlocation spawn walker_instance;, stating they achieve the same result. This is consistent withKW_SPAWNas a binary operator. - Status: Covered.
- Grammar:
-
Base of Spawn (
unpack):- Grammar:
ds_spawnresolves tounpackif noKW_SPAWNis used. - Documentation: Operands of
spawn(walker instances, locations) are implicitlyunpackexpressions. - Status: Implicitly covered.
- Grammar:
-
Chaining
spawnOperations:- Grammar: The left-recursive structure
(ds_spawn KW_SPAWN)? unpackallows for chaining (e.g.,a spawn b spawn c). - Documentation: Does not show examples of chaining multiple
spawnkeywords in a single expression. It shows multiple separate spawn statements. - Clarification Needed: The semantic meaning of a chained spawn expression like
(walker1 spawn node1) spawn walker2is not obvious or documented. While grammatically parsable, its practical use is unclear. Thespawnoperation primarily has side effects, and its direct result (if any as an expression) is usually related to collecting reports, not further spawning.
- Grammar: The left-recursive structure
-
-
Overall: The documentation effectively explains the
spawnoperation for activating walkers with either operand order (walker or location first), which aligns with the grammar. The practical application of chainedspawnoperators within a single expression remains undocumented and unclear.
Section 54: Unpack expressions#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/unpack_expressions.md -
Findings:
-
Iterable Unpacking (
*iterable):- Grammar:
unpack: STAR_MUL? refcorrectly defines*ref. - Documentation: Explains and shows examples like
[*items]orfunc(*args). - Status: Covered and consistent with the grammar rule.
- Grammar:
-
Mapping Unpacking (
**mapping):- Documentation (
unpack_expressions.md): Describes and exemplifies mapping unpacking using**(e.g.,{**dict1, **dict2}orfunc(**kwargs)). - Grammar (
unpackrule): The ruleunpack: STAR_MUL? refdoes not include syntax for**(mapping unpacking). Mapping unpacking withSTAR_POWis defined in other specific grammar rules:kw_expr(for function call keyword arguments) andkv_pair(for dictionary literals). - Issue (Major Documentation/Grammar Rule Mismatch): The documentation file
unpack_expressions.mdis titled broadly and includes**mapping unpacking. However, the specific grammar ruleunpackpresented under the same heading injac.larkonly covers*iterable unpacking. This creates a mismatch: the doc is broader than this particular rule. - Clarification: The documentation should clarify that while
*is handled by theunpackexpression rule (which then becomes part of general expressions),**unpacking occurs in specific contexts like dictionary literals and function call arguments, governed by different grammar rules (kv_pair,kw_expr).
- Documentation (
-
Base of Unpack (
ref):- Grammar: If
STAR_MUL?is absent,unpackisref. - Documentation: Operands of
*arerefexpressions. This is implicit. - Status: Implicitly covered.
- Grammar: If
-
-
Overall: The grammar rule
unpack: STAR_MUL? refcorrectly defines*iterableunpacking. The documentation fileunpack_expressions.mdaccurately describes*iterableunpacking. However, this documentation also covers**mappingunpacking, which is grammatically handled by different rules (kv_pair,kw_expr) usingSTAR_POW, not by this specificunpackrule. This makes the scope of theunpackrule versus theunpack_expressions.mddocument inconsistent regarding**.
Section 55: References (unused)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/references_(unused).md -
Findings:
-
refRule andBW_AND(&) Operator:- Grammar: Defines
refas an optional&followed by apipe_call. - Documentation: Explicitly states that this
refrule, particularly the&operator for creating references (e.g.,&value), is "currently defined but not actively utilized in the language implementation" and is "unused". - Status: This is a direct statement about a non-operational grammar feature. This is not an inconsistency but important documentation of the language's current state.
- Grammar: Defines
-
Passthrough to
pipe_call:- Grammar: If the optional
BW_AND?is not used,refsimply becomespipe_call. - Documentation: States, "Current implementation uses
pipe_calldirectly." - Status: Consistent with the
&part being unused. In the expression hierarchy,refeffectively serves as a direct link topipe_call.
- Grammar: If the optional
-
-
Overall: The documentation clearly indicates that the
&(address-of/reference) operator, though defined in therefgrammar rule, is an unused feature in the current Jac language. This is a crucial piece of information for understanding the effective grammar.
Section 56: Data spatial calls#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/data_spatial_calls.md -
Findings: This
pipe_callgrammar rule presents significant inconsistencies with how|>(pipe fwd),:>(atomic pipe fwd), andspawnare defined and used elsewhere in the grammar and documentation.-
Unary Prefix Interpretation vs. Binary Operator Nature:
pipe_callGrammar: Suggests|>atomic_chain,:>atomic_chain, andspawnatomic_chainare valid (treating them as optional unary prefixes).- Contradictory Grammar Rules:
pipe: (pipe PIPE_FWD)? pipe_back(defines|>as binary).atomic_pipe: (atomic_pipe A_PIPE_FWD)? atomic_pipe_back(defines:>as binary).ds_spawn: (ds_spawn KW_SPAWN)? unpack(definesspawnas binary).
- Documentation (
data_spatial_calls.mdand others): Consistently shows|>,:>, andspawnused as binary operators (e.g.,data |> func,walker spawn node). - Issue (Major Grammar Inconsistency): The
pipe_callrule treating|>,:>, andspawnas optional unary prefixes is fundamentally inconsistent with their established binary operator nature in other parts of the grammar and all documentation examples.
-
KW_AWAIT(await):pipe_callGrammar:(KW_AWAIT)? atomic_chainis plausible, asawaitis a unary prefix operator.- Documentation: Standard
await expressionusage is documented elsewhere (e.g.,functions_and_abilities.md).data_spatial_calls.mdmentionsawaitfor synchronization but provides no specific syntax example itself for this rule. - Status for
await: Theawait atomic_chainpart aligns withawaitbeing unary. This is the only part of the optional prefixes inpipe_callthat seems grammatically sound in isolation.
-
atomic_chainas the base:- If no prefix is used,
pipe_callresolves toatomic_chain. This is standard. - Status: Base case is fine.
- If no prefix is used,
-
-
Overall (Major Issues with
pipe_callrule):- The
pipe_callgrammar rule, as written, is largely incorrect or misleading forPIPE_FWD,A_PIPE_FWD, andKW_SPAWNby suggesting they can be unary prefixes toatomic_chain. - This rule seems to be in conflict with the primary definitions and documented usage of these operators.
- The
KW_AWAITprefix is the only one that aligns with standard operator behavior (unary prefix). - The documentation in
data_spatial_calls.mditself describes|>andspawnin their correct binary operator sense, further highlighting the problem with thepipe_callgrammar rule. - This rule likely needs significant revision or clarification on its intended purpose, as it does not reflect the actual usage of these operators.
- The
Section 57: Subscripted and dotted expressions (atomic_chain)#
- Grammar Rules from
jac.lark:atomic_chain: atomic_chain NULL_OK? (filter_compr | assign_compr | index_slice) // Form 1: obj?[...] or obj?(filter/assign) | atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) named_ref // Form 2: obj?.attr, obj?.<attr, obj?.>attr | (atomic_call | atom | edge_ref_chain) // Form 3: Base cases (call, primary, edge_ref) // NULL_OK: "?", DOT: ".", DOT_BKWD: "<.", DOT_FWD: ".>" // index_slice involves [...] for indexing/slicing. // filter_compr and assign_compr are specific (...) forms. - Corresponding Markdown File:
jac/examples/reference/subscripted_and_dotted_expressions.md -
Findings:
-
Dotted Expressions (Attribute Access - Form 2):
- Standard Dot (
.): Covered, including null-safe?.(e.g.,car.model,user?.address). - Directional Dots (
.>,.<): Mentioned for forward/backward piping attribute access, but not deeply exemplified in this document. - Status: Standard dot access well covered. Directional dots mentioned.
- Standard Dot (
-
Subscripted Expressions (
index_slice- Form 1 part):- Grammar:
atomic_chain NULL_OK? index_slice.index_sliceincludesLSQUARE ... RSQUAREfor indexing/slicing and alsolist_val. - Documentation: Covers standard indexing (
letters[0]) and slicing (letters[1:3],letters[::2]) well, including null-safe?.[]. - The
list_valalternative withinindex_slice(e.g., potentially forobj[[1,2]]style indexing) is not documented. - Issue (Minor):
list_valas anindex_sliceform is not covered. - Status: Standard indexing/slicing well covered.
- Grammar:
-
Special Comprehensions (
filter_compr,assign_compr- Form 1 part):- Grammar:
atomic_chain NULL_OK? (filter_compr | assign_compr). These are(...)forms distinct from function calls. - Documentation (
subscripted_and_dotted_expressions.md): Does not cover these. They are expected to be documented under the "Special Comprehensions" grammar heading. - Status: Not covered in this document (deferred).
- Grammar:
-
Base Cases (Form 3 -
atomic_call | atom | edge_ref_chain):- These are the starting points of an
atomic_chain(e.g., a function call, a literal, a variable name, an edge reference). - Documentation: This document focuses on the chaining operators (
.[]) rather than exhaustively detailing the base forms, which have their own grammar sections/documentation. - Status: Implicitly handled as the operands for dot/subscript operations.
- These are the starting points of an
-
-
Overall: This document effectively covers standard attribute access and list/dictionary subscripting, including their null-safe versions. Directional dot operators are mentioned. The special
filter_comprandassign_comprsyntaxes, and thelist_valform ofindex_slice, are not covered here.
Section 58: Index slice (details of the rule)#
- Grammar Rule from
jac.lark: - Corresponding Markdown File: No dedicated file. Discussed under
subscripted_and_dotted_expressions.md. -
Findings (Detailed analysis of the
index_slicerule):-
Basic Indexing and Slicing (Single component):
- The grammar
expression? COLON expression? (COLON expression?)?supports forms like[index],[start:stop],[:stop],[start:],[start:stop:step],[::step],[:]. - Documentation (
subscripted_and_dotted_expressions.md): Covers these 1D indexing and slicing forms well with examples. - Status: Covered.
- The grammar
-
Comma-Separated Multi-Dimensional Indexing/Slicing:
- The grammar part
(COMMA expression? COLON expression? (COLON expression?)?)*allows for multiple comma-separated index/slice components within a single[]pair (e.g.,matrix[row_idx, col_idx],tensor[slice1, slice2, index3]). - Documentation (
subscripted_and_dotted_expressions.md): Does not show or discuss this multi-dimensional access syntax using commas within a single[]. - Issue: Comma-separated multi-dimensional indexing/slicing is a significant capability of the
index_slicegrammar rule that is not documented.
- The grammar part
-
list_valas an Index (Fancy Indexing):- Grammar:
index_slice: ... | list_val. Allows a list literal (e.g.,[idx1, idx2]) to be used as the index itself, e.g.,data[[idx1, idx2, idx3]]. - Documentation (
subscripted_and_dotted_expressions.md): Does not show or discuss using a list literal directly within the square brackets for indexing (often called "fancy indexing" or "advanced indexing"). - Issue: The
list_valalternative forindex_slice, enabling list-based fancy indexing, is not documented.
- Grammar:
-
-
Overall: While basic 1D indexing and slicing are documented, the
index_slicegrammar rule supports more advanced features like comma-separated multi-dimensional access and list-based fancy indexing, which are currently not covered in the documentation.
Section 59: Function calls (atomic_call)#
- Grammar Rules from
jac.lark:atomic_call: atomic_chain LPAREN param_list? (KW_BY atomic_call)? RPAREN param_list: expr_list COMMA kw_expr_list COMMA? // Positional, then keyword | kw_expr_list COMMA? // Only keyword | expr_list COMMA? // Only positional expr_list: (expr_list COMMA)? expression kw_expr_list: (kw_expr_list COMMA)? kw_expr kw_expr: named_ref EQ expression | STAR_POW expression // kw=val or **kwargs // `expression` in `expr_list` can be `unpack` for *args. - Corresponding Markdown File:
jac/examples/reference/function_calls.md -
Findings:
-
Basic Syntax and Callables (
atomic_chain(...)):- Covers calls to simple functions, methods (
obj.method()), and chained calls (obj.meth1().meth2()). - Status: Covered.
- Covers calls to simple functions, methods (
-
Parameter Lists (
param_list?):- Positional Arguments (
expr_list): Documented, including*argsunpacking (though*argsexample often cited fromunpack_expressions.md). - Keyword Arguments (
kw_expr_list): Documented (name=value), including**kwargsunpacking (example often fromunpack_expressions.md). - Mixed Arguments: Documented.
- Trailing Commas: Grammar allows optional trailing commas in
param_listvariants. Not explicitly shown in documentation examples. - Issue (Minor): Optional trailing commas in argument lists are not explicitly documented.
- Status: Argument types (positional, keyword, args, *kwargs) well covered.
- Positional Arguments (
-
KW_BY atomic_callSuffix:- Grammar:
atomic_callcan end with(KW_BY atomic_call)? RPAREN. This suggests a syntax likefunc1(args) by func2(other_args). - Documentation (
function_calls.md): Does not document or exemplify thisby <another_call>feature within a function call. - Issue: The
KW_BY atomic_callpart of the function call syntax is not documented. Its purpose and semantics in this context are unknown from the docs.
- Grammar:
-
-
Overall: Standard function call mechanisms are thoroughly documented. The main omissions are the optional trailing comma in argument lists and the entire
KW_BY atomic_callfeature, which was also seen undocumented inblock_tailfor function/ability definitions.
Section 60: Atom#
- Grammar Rules from
jac.lark:atom: named_ref | LPAREN (expression | yield_expr) RPAREN // Parenthesized expr/yield | atom_collection // List, dict, set, tuple literals/compr | atom_literal // Numeric, string, bool, null, ellipsis literals | type_ref // `type_name or `builtin_type atom_literal: builtin_type | NULL | BOOL | multistring | ELLIPSIS | FLOAT | OCT | BIN | HEX | INT type_ref: TYPE_OP (named_ref | builtin_type) // TYPE_OP is "`" // multistring includes fstring and STRING. - Corresponding Markdown File:
jac/examples/reference/atom.md -
Findings:
named_ref(Identifiers): Covered.- Parenthesized Expressions: Covered.
atom_collection(Collection Literals - basic): Basic list/tuple literals mentioned. Full scope deferred.- Status: Partially covered (overview).
-
atom_literal(Literals - This has several issues in the doc):- String literals & F-strings (
multistring): Covered. - Boolean literals (
BOOL): Covered (True,False). - Numeric literals (
INT,FLOAT,HEX,BIN,OCT):- Documentation Error:
atom.mdshowsbin(12)andhex(78)(function calls) for binary/hex literals instead of the correct literal syntax (e.g.,0b1100,0x4E). - Decimal
INTandFLOATare mentioned generally but not with specific syntax examples in this section. OCT(octal literals, e.g.,0o...) not explicitly shown.- Issue: Major errors and omissions in documenting numeric literal syntax.
- Documentation Error:
NULL(None): Not explicitly listed as a literal inatom.md's literal section, though it's part ofatom_literalgrammar. (Covered elsewhere under singleton patterns).ELLIPSIS(...): Not mentioned inatom.md, though part ofatom_literalgrammar.- Issue:
ELLIPSISliteral missing.
- Issue:
builtin_type(e.g.,int,stras values): Part ofatom_literalgrammar but not clearly explained as a literal value an atom can be inatom.md.- Issue:
builtin_typeas a literal value unclear.
- Issue:
- String literals & F-strings (
-
type_ref(`type):- Grammar:
atom: type_ref. - Documentation: Mentions "Type References ... using the backtick operator (
)", but provides no concrete example (e.g., ``MyType`` or ``int` ``). - Issue (Minor): Lacks an explicit example.
- Grammar:
-
Misplaced Complex Examples in
atom.md:- The document includes examples of string concatenation (
"a" + f"b") and chained attribute access (x.y.value), which are compound expressions (e.g.,arithmetic,atomic_chain), not justatoms. This can be confusing for a document titled "Atom". - Issue: Document scope seems to exceed the strict definition of an
atom.
- The document includes examples of string concatenation (
-
Overall:
atom.mdcorrectly identifies some atomic elements like names, parenthesized expressions, and basic collections. However, its coverage ofatom_literalis poor, with incorrect syntax for some numeric literals and omission of others likeELLIPSIS. The document also mixes in examples of more complex expressions, blurring the definition of an "atom".
Section 61: Multistring and F-string definitions (within atom_literal)#
- Grammar Rules from
jac.lark:multistring: (fstring | STRING)+ fstring: FSTR_START fstr_parts FSTR_END | FSTR_SQ_START fstr_sq_parts FSTR_SQ_END fstr_parts: (FSTR_PIECE | FSTR_BESC | LBRACE expression RBRACE )* fstr_sq_parts: (FSTR_SQ_PIECE | FSTR_BESC | LBRACE expression RBRACE )* // STRING terminal: covers '...', "...", '''...''', """...""", with r/b prefixes. // FSTR_START/END etc. are for f"..." and f'...' parts. - Corresponding Markdown File: No dedicated file. Mentioned in
atom.md. -
Findings:
-
STRING(Regular String Literals):- Grammar: The
STRINGterminal supports various quoting and prefix styles. - Documentation (
atom.md): Shows basic double-quoted strings. Does not detail triple quotes orr/bprefixes, but these are standard Python features usually assumed. - Status: Basic strings covered; advanced forms assumed standard.
- Grammar: The
-
fstring(Formatted String Literals):- Grammar: Defines
f"..."andf'...'with embedded expressions{expression}. - Documentation (
atom.md): Mentions f-strings and shows a simple example:f"b{aa}bbcc". - The full power of embedded
expressions or format specifiers (e.g.,{val:.2f}) is not detailed inatom.mdbut often inherited from Python f-string behavior. - Status: Basic f-strings covered.
- Grammar: Defines
-
multistring: (fstring | STRING)+(Implicit Concatenation):- Grammar: This rule allows implicit concatenation of adjacent string or f-string literals (e.g.,
"abc" "def"orf"a" "b"). - Documentation (
atom.md): Does not document this implicit concatenation feature. It shows explicit concatenation using the+operator ("aaa" + f"b{aa}bbcc"), which is an arithmetic expression, not an atomicmultistringliteral itself. - Issue: Implicit string/f-string literal concatenation via adjacency, as defined by
multistring, is not documented.
- Grammar: This rule allows implicit concatenation of adjacent string or f-string literals (e.g.,
-
-
Overall:
atom.mdcovers the existence of basic string literals and f-strings. The implicit concatenation feature ofmultistringis a notable omission from the documentation. Full details ofSTRINGprefixes/quoting and f-string capabilities are also not inatom.mdbut are often standard language assumptions.
Section 62: Collection values (atom_collection)#
- Grammar Rules from
jac.lark(overview):atom_collection: dict_compr | set_compr | gen_compr | list_compr | dict_val | set_val | tuple_val | list_val // Comprehensions generally: TARGET_EXPR (KW_ASYNC? KW_FOR ... KW_IN ... (KW_IF ...)*)+ // Literals generally: BRACKET (elements COMMA?)? BRACKET_END // dict_compr: LBRACE kv_pair inner_compr+ RBRACE // Grammar has RSQUARE, likely typo - Corresponding Markdown File:
jac/examples/reference/collection_values.md -
Findings: Literal Collections (
dict_val,set_val,tuple_val,list_val):- Dictionary Literal (
dict_val): Doc shows{"a": "b"}. Grammar allows empty{}, unpacking**expr, and trailing comma; these aren't shown in this specific doc.- Status: Basic covered.
- Set Literal (
set_val): Doc shows{"a"}. GrammarLBRACE expr_list COMMA? RBRACEdoesn't easily make empty set{}(that's dict) or distinguish{"a"}from a dict without parser context. Python usesset()for empty. Single item sets usually{ "a" }not{"a":}.- Issue: Syntax for set literals (esp. empty, single-element) and potential ambiguity with dict literals needs clarification in docs and grammar robustness.
- Status: Basic concept mentioned; syntax clarity needed.
- Tuple Literal (
tuple_val): Doc shows("a", )(single element with comma). Grammar allows empty()and multi-element.- Status: Single-element covered; others implied.
- List Literal (
list_val): Doc shows['a']. Grammar allows empty[], multi-element, and trailing comma.- Status: Basic covered; others implied.
Comprehensions (
..._comprrules): 5. General Structure: Docs showTARGET for item in iterable if condition. * Grammar (inner_compr+andKW_ASYNC?): Allows multiplefor/ifclauses (e.g.,for x in X for y in Y if cond1 if cond2) andasynccomprehensions. * Issue: Advanced comprehension features (multiplefor/ifclauses,asynccomprehensions) are not documented incollection_values.md. * Status: Basic comprehensions covered; advanced features undocumented. 6. Dictionary Comprehension Grammar Typo:dict_comprrule ends withRSQUAREinjac.lark, should beRBRACE. * Issue: Grammar typo. - Dictionary Literal (
-
Overall: Basic collection literals and comprehensions are introduced. Key areas for improvement: robust syntax/examples for set literals (empty, single-element), documentation for advanced comprehension features (multiple
for/if,async), and showing features like unpacking in dict literals and trailing commas. Grammar typo indict_comprneeds fixing.
Section 63: Supporting rules for Collection Values (kv_pair, expr_list)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File: No dedicated file; these are components of collection literal rules discussed in
collection_values.md. -
Analysis:
-
kv_pair(for Dictionary Literals):- Grammar: Defines
expression : expressionfor key-value items andSTAR_POW expressionfor dictionary unpacking (**mapping). - Documentation (
collection_values.md): Examples show"key": "value". Dictionary unpacking (**mapping) within literals is not explicitly shown in this document but is a standard feature documented elsewhere (e.g.,unpack_expressions.md). - Status: Standard key-value covered.
**unpackingas akv_pairtype is valid per grammar but not shown incollection_values.mdexamples of dictionary literals.
- Grammar: Defines
-
expr_list(for List/Set Literals, Function Arguments):- Grammar: Defines a comma-separated list of one or more
expressions. - Documentation (
collection_values.md): Examples like['a']useexpr_list. Multi-element lists/sets are implied. - Iterable unpacking (
*iterable) within list/set literals: Anexpressioninexpr_listcan be anunpack(e.g.,*my_items). This specific syntax is not shown incollection_values.mdexamples for list/set literals but is documented inunpack_expressions.md. - Status: Basic
expr_listcovered.*unpackingas part ofexpr_listfor literals is valid per grammar but not shown incollection_values.mdexamples.
- Grammar: Defines a comma-separated list of one or more
-
-
Overall: These grammar rules are fundamental for constructing collection literals. The
collection_values.mdillustrates basic usage but could be more comprehensive by showing howSTAR_POW expression(forkv_pair) andunpackexpressions (forexpr_list) integrate into dictionary and list/set literals respectively, to fully reflect the grammar capabilities.
Section 64: Tuples and Jac Tuples (tuple_list, kw_expr_list, kw_expr)#
- Grammar Rules from
jac.lark:// These rules define the contents within LPAREN ... RPAREN for tuple_val. tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA? // e.g., (p1, p2, kw1=v1) | expression COMMA kw_expr_list COMMA? // e.g., (p1, kw1=v1) | expression COMMA expr_list COMMA? // e.g., (p1, p2, p3) | expression COMMA // e.g., (p1,) | kw_expr_list COMMA? // e.g., (kw1=v1, kw2=v2) kw_expr_list: (kw_expr_list COMMA)? kw_expr kw_expr: named_ref EQ expression | STAR_POW expression // kw=val or **mapping // expr_list for positional elements is defined elsewhere. - Corresponding Markdown File:
jac/examples/reference/tuples_and_jac_tuples.md -
Findings:
-
Positional Tuples (elements are
expressionor fromexpr_list):- Documentation: Covers multi-element positional tuples (e.g.,
(10, 20)) and single-element tuples with a trailing comma (e.g.,(42,)). - Grammar: Supported by
expression COMMA expr_list?andexpression COMMA. - Status: Covered.
- Documentation: Covers multi-element positional tuples (e.g.,
-
Keyword Tuples (Jac-specific, elements from
kw_expr_list):- Documentation: Shows keyword tuples like
(x=3, y=4)usingnamed_ref EQ expression. - Grammar:
kw_expr_listis built fromkw_expr, which includesnamed_ref EQ expressionandSTAR_POW expression(**mapping). - The documentation does not explicitly show
**mappingunpacking within keyword tuple literals (e.g.,config = (**common, port=80);). - Issue (Minor):
**mappingunpacking in keyword tuple literals is not exemplified. - Status: Basic keyword tuples covered.
- Documentation: Shows keyword tuples like
-
Mixed Positional and Keyword Tuples:
- Documentation: Shows
("header", version=2, timestamp=now())and states positional elements must precede keyword elements. - Grammar: Supported by productions like
expression COMMA expr_list COMMA kw_expr_list ...andexpression COMMA kw_expr_list .... - Status: Covered.
- Documentation: Shows
-
Trailing Commas (
COMMA?):- Grammar: Allows optional trailing commas in most
tuple_listvariants and inkw_expr_list. - Documentation: Notes for single-element positional tuples. Not emphasized for other cases but grammatically allowed.
- Status: Partially noted; broadly allowed by grammar.
- Grammar: Allows optional trailing commas in most
-
Empty Tuple
():- This is formed by
tuple_val: LPAREN tuple_list? RPARENwhentuple_listis absent. - Documentation: Not explicitly shown in this document, but is a standard construct.
- Status: Standard, implied by grammar for
tuple_val.
- This is formed by
-
-
Overall: The documentation effectively explains positional, keyword, and mixed tuples. The primary minor omission is an example of
**mappingunpacking within keyword tuple literals. The grammar for these components is also fundamental to function call arguments.
Section 65: Object-Spatial References (edge_ref_chain)#
- Grammar Rules from
jac.lark(overview):edge_ref_chain: LSQUARE (KW_NODE| KW_EDGE)? expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE edge_op_ref: edge_any | edge_from | edge_to // Defines arrow types // edge_to/from/any can be simple (e.g., "-->") or detailed (e.g., "->:EdgeType:filter:->") // (filter_compr | expression)? is an optional filter after an edge operation. - Corresponding Markdown File:
jac/examples/reference/data_spatial_references.md -
Findings:
-
Basic Structure
LSQUARE ... RSQUARE: Covered. -
Initial Context
(KW_NODE| KW_EDGE)? expression?:- Grammar: Allows an optional
node/edgekeyword and an optional startingexpression. - Documentation: Examples often implicitly use
hereas context. The role of this explicit initial part is not clearly explained or extensively exemplified (e.g., how[node_expr --> ...]differs from[-->]fromnode_expr's context). - Issue (Clarification Needed): Documentation for this initial context specifier is sparse.
- Grammar: Allows an optional
-
Edge Operations (
edge_op_ref):- Simple Arrows (
-->,<--,<-->): Documented for directional navigation. - Detailed/Typed Arrows (e.g.,
->:EdgeType:prop_filter:->): Documented, showing typed edge traversal (e.g.,[-->:EdgeType:]). The property filtering part within the detailed arrow syntax (prop_filter) is implicitly part oftyped_filter_compare_list. - Status: Core arrow operations covered.
- Simple Arrows (
-
Optional Filter
(filter_compr | expression)?afteredge_op_ref:- Grammar: Allows a filter to be applied to the result of an edge operation.
- Documentation: "Filtered References" section shows examples like
[-->(weight > threshold)](expression filter) and[-->(?name.startswith("test"))](filter comprehension). - Status: Covered.
-
Chaining of Edge Operations
(edge_op_ref ...)+:- Grammar: Requires at least one, allows multiple chained edge operations within a single
[...]block (e.g.,[--> --> some_prop < 10]if intermediate steps yield nodes). - Documentation: Does not show complex examples of deeply chaining multiple
edge_op_refwithin oneedge_ref_chain. Focuses on single operations or iteration over results of one operation. - Issue (Minor): Deeply chained edge operations within one reference are not exemplified.
- Grammar: Requires at least one, allows multiple chained edge operations within a single
-
Inclusion of Connection/Disconnection Ops in the Document:
- The document
data_spatial_references.mdalso describes connection (++>) and disconnection (del node-->edge) operations. - These are grammatically distinct from
edge_ref_chain(which is for querying/traversing). - Issue (Documentation Structure): Including creation/deletion operations in a document about "references" can be confusing. These belong more to
connect_expressions.mdordelete_statements.mdrespectively.
- The document
-
-
Overall: The document covers the basics of using
edge_ref_chainfor simple traversals and filtering. However, the initial context specifier and advanced chaining within a single reference need more documentation. The inclusion of connection/disconnection syntax in this particular document also blurs its focus.
Section 66: Special Comprehensions#
- Grammar Rules from
jac.lark:// Used in atomic_chain like: atomic_chain NULL_OK? (filter_compr | assign_compr) filter_compr: LPAREN NULL_OK filter_compare_list RPAREN | LPAREN TYPE_OP NULL_OK typed_filter_compare_list RPAREN assign_compr: LPAREN EQ kw_expr_list RPAREN // e.g., (= prop1=val1, prop2=val2) filter_compare_list: (filter_compare_list COMMA)? filter_compare_item typed_filter_compare_list: expression (COLON filter_compare_list)? // expression is TypeName filter_compare_item: named_ref cmp_op expression // e.g., age > 18 // kw_expr_list uses kw_expr: named_ref EQ expression | STAR_POW expression // NULL_OK: "?", TYPE_OP: "`", EQ: "=" - Corresponding Markdown File:
jac/examples/reference/special_comprehensions.md -
Findings:
-
Filter Comprehensions (
filter_compr):- Non-Typed
(? filter_conditions): Documented with examples like(?score > 0.5)and(age > 18, status == "active"). Aligns withLPAREN NULL_OK filter_compare_list RPAREN.- Status: Covered.
- Typed
( `TypeName : ? filter_conditions ): Documented with examples like(`Connection: weight > 10)and`UserNode: (active == True). Aligns withLPAREN TYPE_OP NULL_OK typed_filter_compare_list RPAREN.- Status: Covered.
- Non-Typed
-
Assignment Comprehensions (
assign_compr):- Grammar:
LPAREN EQ kw_expr_list RPAREN.kw_expr_listusesnamed_ref EQ expressionfor items (e.g.,(=prop1=val1, prop2=val2)). - Documentation: Shows syntax like
(=property: new_value)and(=x: 10, y: 20). Uses colons:instead of equals=for assignments within the comprehension. - Issue (Syntax Mismatch): Documentation for assignment items (e.g.,
prop:value) uses colons, while the grammar (viakw_expr_list->kw_expr) specifies equals signs (prop=value). This needs reconciliation. - Status: Concept covered; syntax detail for assignment items mismatched.
- Grammar:
-
Structure of Filter Conditions (
filter_compare_list,typed_filter_compare_list,filter_compare_item):- These grammar rules correctly define how multiple filter conditions (
name op value) are formed and combined, optionally typed with a leadingTypeName:. - Documentation: Examples for these list structures align with the grammar.
- Status: Covered.
- These grammar rules correctly define how multiple filter conditions (
-
Usage Context (Applied to an
atomic_chain, oftenedge_ref_chain):- Documentation: Clearly shows these comprehensions applied to edge references, e.g.,
[-->(?score > 0.5)];or[-->](=visited: True);. Also shows null-safe application[-->(?nested?.property > 0)]. - Status: Covered.
- Documentation: Clearly shows these comprehensions applied to edge references, e.g.,
-
-
Overall: Filter comprehensions are well-documented and align with the grammar. Assignment comprehensions are conceptually covered, but there is a syntax mismatch (colon vs. equals) for the assignment items within them compared to the underlying
kw_expr_listgrammar. The application of these comprehensions to edge references is well illustrated.
Section 67: Names and references (named_ref, special_ref)#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/names_and_references.md -
Findings:
-
NAME(Standard Identifiers):- Grammar:
NAME: /[a-zA-Z_][a-zA-Z0-9_]*/. - Documentation: Correctly describes standard identifier rules and provides valid/invalid examples.
- Status: Covered.
- Grammar:
-
KWESC_NAME(Keyword Escaping):- Grammar:
KWESC_NAME: /<>[a-zA-Z_][a-zA-Z0-9_]*/(e.g.,<>myvar). - Documentation: Explains escaping keywords by wrapping with angle brackets, example
_<>with = 10;. - Clarification on example: The example
_<>withmight be slightly confusing. Ifwithis the keyword to be used as an identifier, the syntax would likely be<>withif the lexer/parser handles<>keywordas a special token, or<>somenameifsomenameis a valid identifier that isn't a keyword but needs escaping for other reasons (less common). The regex/<>[a-zA-Z_][a-zA-Z0-9_]*/suggests<>followed by a standard identifier sequence. - Status: Concept covered. Exact tokenization of example
_<>withvs. regex needs to be precise.
- Grammar:
-
special_ref(Special References):- Grammar: Lists
KW_INIT,KW_POST_INIT,KW_ROOT,KW_SUPER,KW_SELF,KW_HERE,KW_VISITOR. - Documentation: Provides a table and explanations for
self,here,visitor,super,root,init/postinit. All match the grammar keywords. - Status: Covered.
- Grammar: Lists
-
-
Overall: The documentation accurately covers the types of named references: standard identifiers, special built-in references, and the mechanism for escaping keywords. The usage context, especially for special references, is well explained. Minor clarification on the
KWESC_NAMEexample could be useful.
Section 68: Builtin types#
- Grammar Rules from
jac.lark: - Corresponding Markdown File:
jac/examples/reference/builtin_types.md -
Findings:
-
List of Built-in Type Keywords:
- Grammar: Defines tokens for
type,any,bool,dict,set,tuple,list,float,int,bytes,string. - Documentation: Lists all these types, categorizing them (Primitive, Collection, Meta).
- Status: Covered and consistent.
- Grammar: Defines tokens for
-
Usage in Type Annotations:
- Documentation: Shows examples like
name: str,data: list,-> dict. This is the primary use case for these keywords representing types. - Grammar: This usage fits into rules like
type_tag: COLON expressionwhereexpressioncan be anamed_refthat is one of thesebuiltin_typekeywords. - Status: Primary usage context covered.
- Documentation: Shows examples like
-
Other Grammatical Roles:
- The
builtin_typerule is also part ofatom_literal(allowingx = intifintis treated as a value) andtype_ref(allowing`int). - Documentation (
builtin_types.md): Focuses on their use as type specifiers in annotations rather than these other roles. - Status: These specific grammatical roles are not detailed in this document but are part of other grammar rules (
atom_literal,type_ref).
- The
-
-
Overall: The
builtin_types.mdcorrectly lists the available built-in type keywords and illustrates their main function in type annotations. It does not exhaustively cover every grammatical context where these type names might appear, but those are better suited for the sections defining those contexts (e.g.,atom.mdfor literals).
Section 69: f-string tokens#
- Grammar Rules for f-string structure (from "Atom" section) and its terminals:
// Structure rule (uses these terminals) fstring: FSTR_START fstr_parts FSTR_END | FSTR_SQ_START fstr_sq_parts FSTR_SQ_END fstr_parts: (FSTR_PIECE | FSTR_BESC | LBRACE expression RBRACE )* fstr_sq_parts: (FSTR_SQ_PIECE | FSTR_BESC | LBRACE expression RBRACE )* // Terminal definitions for f-string components FSTR_START.1: "f\"" FSTR_END: "\"" FSTR_SQ_START.1: "f'" FSTR_SQ_END: "'" FSTR_PIECE.-1: /[^\{\}\"]+/ FSTR_SQ_PIECE.-1: /[^\{\}\']+/ FSTR_BESC.1: /{{|}}/ - Corresponding Markdown File:
jac/examples/reference/f_string_tokens.md -
Findings:
-
Basic F-String Syntax (
f"...",f'..."):- Grammar:
FSTR_START...FSTR_ENDandFSTR_SQ_START...FSTR_SQ_ENDalong withfstr_partsdefine this. - Documentation: Shows
f"Hello, {name}!";. Single-quotedf'...'version implied by grammar but not explicitly shown as alternative in this doc. - Status: Covered (double-quoted shown).
- Grammar:
-
Embedded Expressions (
{expression}):- Grammar:
LBRACE expression RBRACEwithinfstr_parts. - Documentation: Well covered with various examples of embedded expressions.
- Status: Covered.
- Grammar:
-
Format Specifications (e.g.,
{value:.2f}):- Documentation: Shows examples like
f"Pi: {value:.2f}". - Grammar: Handled by the
expressionwithin{...}if it includes formatting, relying on Python-like f-string capabilities. - Status: Documented.
- Documentation: Shows examples like
-
Escaped Braces (
{{,}}):- Grammar:
FSTR_BESC.1: /{{|}}/. - Documentation (
f_string_tokens.md): Does not show examples of escaped braces. - Issue: Undocumented feature.
- Grammar:
-
Multi-Line F-Strings (e.g.,
f"""..."""):- Documentation: Shows an example using
f"""...""". - Grammar (Terminals): The
FSTR_START/ENDterminals are defined only forf"andf'. They do not includef"""orf'''. - Issue (Grammar/Doc Mismatch): Documented multi-line f-strings (
f"""...""") are not supported by the providedFSTR_START/ENDterminal definitions. The grammar for f-string delimiters needs to be extended or use the generalSTRINGterminal (which supports triple quotes) if anfprefix on it is handled differently by the lexer.
- Documentation: Shows an example using
-
-
Overall: Core f-string functionality (embedded expressions, format specs) is documented. Escaped braces are an undocumented feature. There's a significant mismatch for multi-line f-strings between documentation and the specific f-string delimiter terminals in the grammar.
Section 70: Lexer Tokens (TYP_... terminals for builtin types)#
-
Grammar Rules from
jac.lark(under this specific heading):(These terminals are used in theTYP_STRING: "str" TYP_INT: "int" TYP_FLOAT: "float" TYP_LIST: "list" TYP_TUPLE: "tuple" TYP_SET: "set" TYP_DICT: "dict" TYP_BOOL: "bool" TYP_BYTES: "bytes" TYP_ANY: "any" TYP_TYPE: "type"builtin_typerule, see Section 68). -
Corresponding Markdown File:
jac/examples/reference/lexer_tokens.md -
Findings:
-
Documentation of
TYP_...Tokens:- The
lexer_tokens.mdfile, in its "Built-in type tokens" subsection, lists:str int float list tuple set dict bool bytes any type. - This list accurately matches the keywords defined as
TYP_...terminals in the grammar. - Status: Covered and consistent.
- The
-
Scope of
lexer_tokens.mdDocument:- The markdown file
lexer_tokens.mdis a broad overview of many Jac token categories (keywords, operators, literals, delimiters), not limited to just theTYP_...built-in type tokens. - This is a general informational document. The
TYP_...tokens are just one part of it.
- The markdown file
-
-
Overall: For the specific grammar section covering
TYP_...terminals, thelexer_tokens.mdfile is consistent. The broader content oflexer_tokens.mdcovers many other terminal types defined elsewhere in thejac.larkgrammar.
Section 71: Remaining Terminal Definitions (Keywords, Literals, Operators, etc.)#
- Grammar Sections in
jac.lark: This covers various terminal definitions typically found at the end of a Lark file, including Keywords (e.g.,KW_IF: "if"), Literal tokens (e.g.,INT,STRING), Identifier tokens (NAME), Operator tokens (e.g.,PLUS: "+",ARROW_R: "-->"), and directives for Comments/Whitespace. - Corresponding Markdown Files: No single, dedicated markdown files for these broad terminal categories.
lexer_tokens.mdprovides a partial overview. Specific terminals are best understood in the context of the grammar rules that use them. -
Findings & Overall Status:
-
Keywords (e.g.,
KW_LET,KW_IF):- Most keywords are defined as simple string literals (e.g.,
KW_IF: "if"). Their usage and meaning are covered by the documentation of the statements/expressions they introduce (e.g.,if_stmtforKW_IF). - Regex-based keywords like
KW_NIN(not in) andKW_ISN(is not) were noted as missing from explicit lists inlogical_and_compare_expressions.mdbut are present incmp_opgrammar. - Status: Implicitly and contextually covered. Definitions are standard.
- Most keywords are defined as simple string literals (e.g.,
-
Literals (Terminals:
STRING,NULL,BOOL,FLOAT,HEX,BIN,OCT,INT):- These define the lexical representation of literal values.
- Their interpretation and usage were discussed under
atom_literal(Section 60) andmultistring/fstring(Section 61). - Key issue previously noted: documentation for numeric base literals (
HEX,BIN,OCT) inatom.mdwas incorrect or missing. The terminal definitions themselves (e.g.,HEX.1: /0[xX][0-9a-fA-F_]+/) are standard. - Status: Terminal definitions are standard. Documentation consistency for their use (especially numeric bases) is the main concern.
-
Identifier (Terminals:
KWESC_NAME,NAME):- Covered in detail under "Names and references" (Section 67).
- Status: Covered.
-
Operators (Object-Spatial, Assignment, Arithmetic, Other - e.g.,
ARROW_R,EQ,PLUS,PIPE_FWD):- These terminals define the symbols for various operations.
- Their meaning and usage are tied to the expression rules that employ them (e.g.,
connect_opforARROW_R,assignmentforEQ,arithmeticforPLUS,pipeforPIPE_FWD). These were covered in their respective expression sections. - The
@operator (DECOR_OP) was noted as missing from arithmetic expression documentation. - Status: Implicitly and contextually covered. Definitions are standard.
-
Punctuation Terminals (e.g.,
COLON: ":",LPAREN: "("):- These are fundamental syntactic markers.
- Their role is defined by their use in all other grammar rules.
- Special punctuation like
TYPE_OP: ""(for type references) andNULL_OK: "?"(null-safe operator) were discussed in context (e.g.,atom,atomic_chain`). - Status: Covered by overall grammar structure.
-
Comments and Whitespace (
COMMENT,WS,%ignoredirectives):- Standard lexer directives and definitions for ignoring comments and whitespace.
- No specific documentation file is typically needed for these beyond standard language behavior.
- Status: Standard, no issues.
-
-
Final Overall Summary on Terminals: The terminal definitions in
jac.larkare, for the most part, standard and serve as the building blocks for the parser. Most are self-explanatory or their meaning is derived from the higher-level grammar rules and the associated documentation for those rules. The consistency issues previously noted (e.g., documentation of numeric literals, specific operators like@,is not,not in) are the primary points of concern related to how these terminals manifest in the language features.
Overall Summary of Findings#
This analysis compared the jac.lark grammar file against the Markdown documentation in jac/examples/reference/. Numerous sections were analyzed, and the findings have been detailed in the preceding sections of this document.
The major themes of inconsistencies and areas for improvement include:
-
Outdated/Incorrect Documentation Examples or Explanations:
atom.md: Incorrect syntax for binary/hex literals (showed function calls).match_literal_patterns.md: MiscategorizedNoneand booleans (which aresingleton_patterns).expressions.md: Contained a lambda example with syntax inconsistent withlambda_exprgrammar.assignments.md: Showed an unconventional destructuring assignment syntax(name=user, age=years) = ...that needs clarification or correction.base_module_structure.md: Overstated requirement forwith entry {}for all module-level code.
-
Grammar Features Not Documented or Under-exemplified:
- Common Patterns: Trailing commas in lists/arguments;
letwith chained assignments; typed declarations without init; assigningyield_exprresults. - Import Statements: Using
.or...infrom_path; multiple modules in one standardimport. - Archetypes/Enums:
asyncarchetypes; empty archetype/enum bodies withSEMI; nesting various statements (py_code_block, other archetypes,impl_def,free_code) inside archetype bodies;KW_LETforhas_stmt; multiple vars in onehas; enum inheritance. - Abilities/Functions:
KW_OVERRIDEkeyword;KW_BYdelegation (for implementation and in calls); return types onevent_clause;static canabilities; no-parenthesisfunc_declfor no-arg functions. - Implementations (
impl):KW_BYdelegation; decorators onimpl;impl_specasinherited_archsorevent_clause; modernimplsyntax fortest. - Global Variables: Multiple declarations in one statement; declaration without initial assignment.
- Python Integration:
py_code_blockusage within archetypes or function bodies. - Testing: String literals for test names vs.
NAMEtoken in grammar; separation of test declaration/implementation intests.md. - Statements: Empty statement (
SEMI); comprehensive list incodeblocks_and_statements.md. - Loops:
elseclause forforloops;async for ... to ... by ...; multi-variable assignment syntax infor i=0,j=0...;if filterinfor...inloop. - Error Handling: Bare
except:syntax intry_stmtdocs inconsistent with grammar. - Pattern Matching: Positional argument patterns in
match_class_pattern; type-onlyClassName()match;list_valfor fancy indexing inindex_slice; comma-separated multi-dim indexing;as_patternwithor_patternon LHS;assign_comprsyntax (:vs.=). - String Literals: Implicit concatenation of adjacent string/f-string literals; escaped braces
{{ }}in f-strings; multi-linef"""..."""support in grammar vs. f-string tokens. - Lambda Expressions: No-param lambdas;
*args/**kwargs; default parameter values; explicit return type annotation. - Object-Spatial: Initial context
(KW_NODE|KW_EDGE)? expr?inedge_ref_chain; deep chaining ofedge_op_ref;disconnect_opas part ofconnectexpression; semantic meaning of chainedspawnexpressions. - Operators:
@(matrix multiplication) operator in arithmetic expressions;is not/not inin comparison operator lists.
- Common Patterns: Trailing commas in lists/arguments;
-
Potential Grammar Issues, Typos, or Ambiguities:
pipe_callrule: Its definition treating|>,:>,spawnas optional unary prefixes is largely inconsistent with their binary nature defined elsewhere. Needs significant review.shiftrule: Useslogical_oras operand name, likely a placeholder/typo.disenage_stmt: Typo fordisengage_stmtin rule name.dict_compr: Ends withRSQUAREinstead ofRBRACE.KWESC_NAME: Regex vs. example (_<>with) could be clarified.- Clarity on whether
KW_SKIPis a generalctrl_stmtor walker-specific based on its grammar placement. delete_stmt:del a,b,c;syntax needs clarification againstKW_DELETE expression.
-
Documentation Structure/Scope Concerns:
atomic_expressions.mddescribesatomic_pipe(:>) not general language atoms.data_spatial_references.mdincludes connection/disconnection operations (which are not strictly "references").lexer_tokens.mdis a very broad token overview.
-
Unused Features Confirmed:
- The
&operator for explicit references (ref: BW_AND? pipe_call) is documented as unused.
- The
This detailed analysis, available in notes.md, should serve as a comprehensive guide for synchronizing the Jac language grammar with its documentation, enhancing clarity, accuracy, and completeness for developers.