### Jac-Lang Identifier Patterns Source: https://www.jac-lang.org/learn/jac_ref Defines patterns for valid identifiers in Jac-Lang. This includes standard names starting with letters or underscore, and special names prefixed with '<>'. ```jac-lang KWESC_NAME: /<>[a-zA-Z_][a-zA-Z0-9_]*/ NAME: /[a-zA-Z_][a-zA-Z0-9_]*/ ``` -------------------------------- ### Jac Language Grammar: Implementations Source: https://www.jac-lang.org/learn/jac_ref Defines how implementations for archetypes are declared in Jac. This section covers the syntax for `impl` blocks, specifying which archetype is being implemented and defining its methods or associated data. ```Jac // [Heading]: Implementations. impl_def: decorators? KW_IMPL dotted_name impl_spec? impl_tail impl_spec: inherited_archs | func_decl | event_clause impl_tail: enum_block | block_tail ``` -------------------------------- ### Jac Language: Comments and Whitespace Source: https://www.jac-lang.org/learn/jac_ref Explains the comment syntax and whitespace handling in Jac. Jac uses `#` for single-line comments and `#* ... *#` for multi-line comments. Whitespace (indentation) is insignificant for code structure, relying on curly braces. ```Jac # Single-line comment #* This is a multiline comment. It can span multiple lines. *# // Jac uses curly braces for code blocks, not indentation. // The compiler ignores most whitespace. function example() { return true; } ``` -------------------------------- ### Jac Language Grammar: Functions and Abilities Source: https://www.jac-lang.org/learn/jac_ref Specifies the syntax for defining functions and abilities in Jac. This includes declarations for regular functions, async functions, and 'can' abilities, along with parameters, return types, and override keywords. ```Jac // [Heading]: Functions and Abilities. 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 expression SEMI event_clause: KW_WITH expression? (KW_EXIT | KW_ENTRY) func_decl: (LPAREN func_decl_params? RPAREN) (RETURN_HINT pipe)? | (RETURN_HINT pipe) func_decl_params: (param_var COMMA)* param_var COMMA? param_var: (STAR_POW | STAR_MUL)? named_ref type_tag (EQ expression)? | DIV | STAR_MUL ``` -------------------------------- ### Jac-Lang Arithmetic and Comparison Operators Source: https://www.jac-lang.org/learn/jac_ref Defines standard arithmetic operators (addition, subtraction, multiplication, division, modulo, power, floor division) and comparison operators (equal, less than, greater than, etc.) in Jac-Lang. ```jac-lang EE: "==" LT: "<" GT: ">" LTE: "<=" GTE: ">=" NE: "!=" PLUS: "+" MINUS: "-" STAR_MUL: "*" DIV: "/" MOD: "%" STAR_POW: "**" FLOOR_DIV: "//" DECOR_OP: "@" BW_AND: "&" BW_OR: "|" BW_XOR: "^" BW_NOT: "~" LSHIFT: "<<" RSHIFT: ">>" ``` -------------------------------- ### Jac Language Grammar: Import and Include Statements Source: https://www.jac-lang.org/learn/jac_ref Specifies the syntax for importing modules and specific items from other Jac modules. It covers both direct imports and imports from specific paths, including aliasing. Handles `import`, `from ... import`, and `include` statements. ```Jac // [Heading]: Import/Include Statements. 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: (NAME COLON)? (dotted_name | STRING) (KW_AS NAME)? import_items: (import_item COMMA)* import_item COMMA? import_item: (KW_DEFAULT | STAR_MUL | named_ref) (KW_AS NAME)? dotted_name: named_ref (DOT named_ref)* ``` -------------------------------- ### Jac Language Grammar: With Entry Blocks Source: https://www.jac-lang.org/learn/jac_ref Defines the `with entry` block structure in Jac, used for executing code within a specific entry context. This allows for scoped execution related to entry points or specific contexts. ```Jac // [Heading]: With entry blocks. free_code: KW_WITH KW_ENTRY (COLON NAME)? code_block ``` -------------------------------- ### Jac Language Grammar: Global Variables Source: https://www.jac-lang.org/learn/jac_ref Details the declaration of global variables in Jac. This grammar rule covers the use of keywords like `let` or `global` and how variables are assigned values, potentially with access control. ```Jac // [Heading]: Global variables. global_var: (KW_LET | KW_GLOBAL) access_tag? assignment_list SEMI assignment_list: (assignment | named_ref) (COMMA (assignment | named_ref))* COMMA? ``` -------------------------------- ### Jac-Lang Comments and Whitespace Handling Source: https://www.jac-lang.org/learn/jac_ref Defines how comments (single-line and multi-line) and whitespace (spaces, tabs, newlines) are handled and ignored by the lexer in Jac-Lang. This ensures clean tokenization. ```jac-lang // ************************************************************************* // // Comments and Whitespace // // ************************************************************************* // COMMENT.4: /#\*(.| | )*?\*#|#.*/ WS.-2: /[ \t\f\r\n]+/+ %ignore COMMENT %ignore WS ``` -------------------------------- ### Jac Language Grammar: Enumerations Source: https://www.jac-lang.org/learn/jac_ref Defines the syntax for creating enumerations (enums) in Jac. This includes how enums are declared, their access modifiers, inheritance, and the structure for defining enum members and their values. ```Jac // [Heading]: Enumerations. enum: decorators? enum_decl enum_decl: KW_ENUM access_tag? NAME inherited_archs? (enum_block | SEMI) enum_block: LBRACE assignment_list (py_code_block | free_code)* RBRACE ``` -------------------------------- ### Jac Language Grammar: Code Blocks and Statements Source: https://www.jac-lang.org/learn/jac_ref Outlines the general structure of code blocks and the various types of statements that can be included within them in Jac. This covers control flow statements like `if`, `while`, `for`, `try`, `match`, and `switch`. ```Jac // [Heading]: Codeblocks and Statements. code_block: LBRACE statement* RBRACE statement: import_stmt | ability | has_stmt | archetype | impl_def | if_stmt | while_stmt | for_stmt | try_stmt | match_stmt | switch_stmt | with_stmt ``` -------------------------------- ### Jac-Lang Formatted String Prefixes Source: https://www.jac-lang.org/learn/jac_ref Defines prefixes for formatted and raw-formatted strings in Jac-Lang, supporting double quotes, single quotes, and triple-quoted variants. These are used for string interpolation and raw string handling. ```jac-lang RF_DQ_START.3: /[rR][fF]"|[fF][rR]"/ RF_SQ_START.3: /[rR][fF]'|[fF][rR]' RF_TDQ_START.3: /[rR][fF]\"\"\"|[fF][rR]\"\"\"/ RF_TSQ_START.3: /[rR][fF]'''|[fF][rR]'''/ F_DQ_START.2: /[fF]\"/ F_SQ_START.2: /[fF]'/ F_TDQ_START.2: /[fF]\"\"\"/ F_TSQ_START.2: /[fF]'''/ ``` -------------------------------- ### Jac-Lang Null and Boolean Literals Source: https://www.jac-lang.org/learn/jac_ref Defines the literal representations for null and boolean values in Jac-Lang. 'None' represents null, while 'True' and 'False' represent boolean states. ```jac-lang NULL.1: "None" BOOL.1: /True|False/ ``` -------------------------------- ### Jac-Lang Assignment Operators Source: https://www.jac-lang.org/learn/jac_ref Defines various assignment operators in Jac-Lang, including simple assignment, augmented assignments (add, subtract, multiply, etc.), and bitwise augmented assignments. ```jac-lang EQ: "=" WALRUS_EQ: ":=" ADD_EQ: "+=" SUB_EQ: "-=" MUL_EQ: "*=" DIV_EQ: "/=" MOD_EQ: "%=" MATMUL_EQ: "@=" STAR_POW_EQ: "**=" FLOOR_DIV_EQ: "//=" BW_AND_EQ: "&=" BW_OR_EQ: "|=" BW_XOR_EQ: "^=" LSHIFT_EQ: "<<=" RSHIFT_EQ: ">>=" ``` -------------------------------- ### Jac-Lang Keywords Source: https://www.jac-lang.org/learn/jac_ref Defines keywords for control flow, scope, and language constructs in Jac-Lang. These are fundamental for parsing and understanding Jac-Lang code. ```jac-lang KW_SEM: "sem" KW_ASSERT: "assert" KW_IF: "if" KW_ELIF: "elif" KW_ELSE: "else" KW_FOR: "for" KW_TO: "to" KW_BY: "by" KW_WHILE: "while" KW_CONTINUE: "continue" KW_BREAK: "break" KW_DISENGAGE: "disengage" KW_YIELD: "yield" KW_SKIP: "skip" KW_REPORT: "report" KW_RETURN: "return" KW_DELETE: "del" KW_TRY: "try" KW_EXCEPT: "except" KW_FINALLY: "finally" KW_RAISE: "raise" KW_IN: "in" KW_IS: "is" KW_PRIV: "priv" KW_PUB: "pub" KW_PROT: "protect" KW_HAS: "has" KW_GLOBAL: "glob" KW_CAN: "can" KW_DEF: "def" KW_STATIC: "static" KW_OVERRIDE: "override" KW_MATCH: "match" KW_SWITCH: "switch" KW_CASE: "case" KW_DEFAULT: "default" KW_CLIENT: "cl" KW_INIT: "init" KW_POST_INIT: "postinit" KW_HERE: "here" KW_VISITOR: "visitor" KW_SELF: "self" KW_SUPER: "super" KW_ROOT: "root" KW_NIN.1: /\bnot\s+in\b/ KW_ISN.1: /\bis\s+not\b/ KW_AND.1: /&&|and/ KW_OR.1: /\|\||or/ NOT: "not" // TODO:AST: Rename to KW_NOT ``` -------------------------------- ### Jac Language Grammar: Tests Source: https://www.jac-lang.org/learn/jac_ref Defines the structure for writing tests in Jac. This includes the `test` keyword, optional naming of tests, and the code block containing the test logic. ```Jac // [Heading]: Tests. test: KW_TEST NAME? code_block ``` -------------------------------- ### Jac Language Grammar: Base Module Structure Source: https://www.jac-lang.org/learn/jac_ref Defines the fundamental structure of a Jac module, including how modules are declared and the different types of top-level statements they can contain. This grammar dictates the organization of Jac code files. ```Jac start: module module: (toplevel_stmt (tl_stmt_with_doc | toplevel_stmt)*)? | STRING (tl_stmt_with_doc | toplevel_stmt)* tl_stmt_with_doc: STRING toplevel_stmt toplevel_stmt: KW_CLIENT? onelang_stmt | KW_CLIENT LBRACE onelang_stmt* RBRACE | py_code_block ``` -------------------------------- ### Jac Language Grammar: Archetype Member Blocks Source: https://www.jac-lang.org/learn/jac_ref Details the contents of an archetype's body, known as a member block. It specifies how members like variables, abilities, nested archetypes, and implementations are declared within an archetype. ```Jac // [Heading]: Class Archetype bodies. 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 pipe ``` -------------------------------- ### Jac-Lang JSX Contextual Tokens Source: https://www.jac-lang.org/learn/jac_ref Defines tokens specific to JSX syntax within Jac-Lang, including opening tags, self-closing tags, tag endings, closing tags, fragments, and text content. These allow embedding UI-like structures. ```jac-lang // JSX opening tag start: < followed by identifier or uppercase // Using lower priority so it doesn't interfere with LT operator JSX_OPEN_START.2: /<(?=[A-Z_a-z])/ // JSX self-closing end: /> JSX_SELF_CLOSE: /\/>/ // JSX tag end: > (used for both opening and closing) JSX_TAG_END: />/ // JSX closing tag start: JSX_FRAG_OPEN: /<>/ // JSX fragment close: JSX_FRAG_CLOSE: /<\/>/ // JSX identifier (NAME in JSX context) - allows hyphens for attributes like data-age, aria-label JSX_NAME: /[A-Z_a-z][A-Z_a-z0-9\-]*/ // JSX text content (anything except < > { } and must not start/end with whitespace-only) // Using negative priority so it's only matched as last resort within JSX JSX_TEXT.-1: /[^<>{}\n]+/ ``` -------------------------------- ### Jac-Lang String Conversion Operator Source: https://www.jac-lang.org/learn/jac_ref Defines the conversion operator used in Jac-Lang, indicated by '!'. It's followed by a set of characters that specify the type of conversion. ```jac-lang CONV: /![rRsSaA]/ ``` -------------------------------- ### Jac-Lang String Literals Source: https://www.jac-lang.org/learn/jac_ref Defines regular expressions for matching various string literal formats in Jac-Lang, including raw, bytes, and triple-quoted strings. Handles escape sequences. ```jac-lang STRING: /(r?b?|b?r?)("(?!\").*?(?" A_PIPE_BKWD: "<:" PIPE_FWD: "|>" PIPE_BKWD: "<|" DOT_FWD: ".>" DOT_BKWD: "<." ``` -------------------------------- ### Jac Language Grammar: Class Archetypes Source: https://www.jac-lang.org/learn/jac_ref Defines the structure for declaring archetypes (classes, objects, nodes, edges, walkers) in Jac. This includes support for decorators, access modifiers, inheritance, and asynchronous definitions. ```Jac // [Heading]: Class Archetypes. 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 ``` -------------------------------- ### Jac Language Grammar: Semstrings Source: https://www.jac-lang.org/learn/jac_ref Specifies the declaration of Semstrings in Jac, a feature for defining semantic strings. This includes the basic assignment syntax for these special string types. ```Jac // [Heading]: Semstrings. sem_def: KW_SEM dotted_name (EQ | KW_IS) STRING SEMI ``` -------------------------------- ### Jac-Lang Braced Delimiters Source: https://www.jac-lang.org/learn/jac_ref Defines double curly brace delimiters used in Jac-Lang, likely for specific formatting or templating contexts. These are distinct from standard block delimiters. ```jac-lang D_RBRACE: "}}" D_LBRACE: "{{" ``` -------------------------------- ### Jac-Lang Spatial Object Operators Source: https://www.jac-lang.org/learn/jac_ref Defines operators used for spatial relationships and object communication in Jac-Lang. These include bidirectional, left, and right arrows, with variations for parameterized connections. ```jac-lang ARROW_BI: "<-->" ARROW_L: "<--" ARROW_R: "-->" ARROW_L_P1: "<-:" ARROW_R_P2: ":->" ARROW_L_P2: ":<-" ARROW_R_P1: "->:" CARROW_BI: "<++>" CARROW_L: "<++" CARROW_R: "++>" CARROW_L_P1: "<+ :" CARROW_R_P2: ":+>" CARROW_L_P2: ":<+" CARROW_R_P1: "+> :" ``` -------------------------------- ### Jac-Lang Formatted String Text Content Source: https://www.jac-lang.org/learn/jac_ref Regular expressions for capturing the text content within formatted and raw-formatted strings in Jac-Lang. These expressions handle escape sequences and differentiate between quote types. ```jac-lang F_TEXT_DQ.-1: /[^"{}\\n]+|\\./ F_TEXT_SQ.-1: /[^'{} \\n]+|\\./ F_TEXT_TDQ.-1: /(?:[^"{}\\n]|\"(?!\"))+|\\./s F_TEXT_TSQ.-1: /(?:[^'{}\\n]|'(?!''))+|\\./s RF_TEXT_DQ.-1: /[^"{}]+/ RF_TEXT_SQ.-1: /[^'{}]+/ RF_TEXT_TDQ.-1: /(?:[^"{}\\]|\"(?!\"))+/s RF_TEXT_TSQ.-1: /(?:[^'{} \\n]|'(?!''))+/s F_FORMAT_TEXT.-1: /[^{}]+/ ``` -------------------------------- ### Jac-Lang Numeric Literals Source: https://www.jac-lang.org/learn/jac_ref Defines regular expressions for various numeric literal types in Jac-Lang, including floats, hexadecimal, binary, octal, and integers. Supports underscores for readability. ```jac-lang FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]\d+)/ HEX.1: /0[xX][0-9a-fA-F_]+/ BIN.1: /0[bB][01_]+/ OCT.1: /0[oO][0-7_]+/ INT: /[0-9][0-9_]*/ ``` -------------------------------- ### Jac-Lang String Literal Endings Source: https://www.jac-lang.org/learn/jac_ref Defines the closing characters for various string literal types in Jac-Lang. These are crucial for correctly parsing the end of strings, including triple-quoted ones. ```jac-lang F_DQ_END: "\"" F_SQ_END: "'" F_TDQ_END: "\"\"\"" F_TSQ_END: "'''" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.