### Rune Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for rune literals in Cangjie, which start with 'r' followed by a single-character string literal enclosed in single or double quotes. It supports standard characters and escape sequences, including Unicode character literals. ```Cangjie RuneLiteral : 'r' ''' (SingleChar | EscapeSeq) ''' : 'r' '"' (SingleChar | EscapeSeq) '"' ; fragment SingleChar : \t ~['\\] ; EscapeSeq : UniCharacterLiteral | EscapedIdentifier ; fragment UniCharacterLiteral : '\' 'u' '{' HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' | '\' 'u' '{' HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit '}' ; fragment EscapedIdentifier : '\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | 'f' | 'v' | '0' | '$') ; ``` -------------------------------- ### Cangjie Single-Line Comments (ANTLR Grammar) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for single-line comments in Cangjie, which begin with '//' and extend to the end of the line. This rule is essential for code readability and maintainability. It uses ANTLR's lexer syntax. ```antlr __ LineComment : '//' ~[ ]* ; ``` -------------------------------- ### Float Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for float literals in Cangjie, supporting both decimal and hexadecimal representations. It includes optional suffixes for specifying float types (f16, f32, f64) and details the structure of decimal and hexadecimal exponents and fractions. ```Cangjie FloatLiteralSuffix : 'f16' | 'f32' | 'f64' ; FloatLiteral : (DecimalLiteral DecimalExponent | DecimalFraction DecimalExponent? | (DecimalLiteral DecimalFraction) DecimalExponent?) FloatLiteralSuffix? | (Hexadecimalprefix (HexadecimalDigits | HexadecimalFraction | (HexadecimalDigits HexadecimalFraction)) HexadecimalExponent) DecimalFraction : '.' DecimalFragment ; DecimalFragment : DecimalDigit (DecimalDigit | '_')* ; DecimalExponent : FloatE Sign? DecimalFragment ; HexadecimalFraction : '.' HexadecimalDigits ; HexadecimalExponent : FloatP Sign? DecimalFragment ; FloatE : [eE] ; FloatP : [pP] ; Sign : [-] ; Hexadecimalprefix : '0' [xX] ; ``` -------------------------------- ### Cangjie Token Separation with Newlines and Semicolons Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Illustrates how semicolons and newline characters function as terminators or separators for expressions and declarations in Cangjie. Demonstrates the 'longest match' principle for newline handling. ```Cangjie let width1: Int32 = 32 // The newline character is treated as a terminator. let length1: Int32 = 1024 // The newline character is treated as a terminator. let width2: Int32 = 32; let length2: Int32 = 1024 // The newline character is treated as a terminator. var x = 100 + // The newline character is treated as a connector. 200 * 300 - // The newline character is treated as a connector. 50 // The newline character is treated as a terminator. ``` -------------------------------- ### Cangjie Multi-Line Comments (ANTLR Grammar) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Specifies the grammar for multi-line comments in Cangjie, which are enclosed by '/*' and '*/'. This syntax supports nested comments, allowing for complex documentation blocks within the code. It is defined using ANTLR's lexer. ```antlr __ DelimitedComment : '/*' ( DelimitedComment | . )*? '*/' ; ``` -------------------------------- ### Cangjie Integer Literal Syntax Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Specifies the syntax for integer literals in Cangjie, supporting binary, octal, decimal, and hexadecimal formats. Optional suffixes can be used to explicitly define the integer type. ```BNF IntegerLiteralSuffix : 'i8' |'i16' |'i32' |'i64' |'u8' |'u16' |'u32' | 'u64' ; IntegerLiteral : BinaryLiteral IntegerLiteralSuffix? | OctalLiteral IntegerLiteralSuffix? | DecimalLiteral '_'* IntegerLiteralSuffix? | HexadecimalLiteral IntegerLiteralSuffix? ; BinaryLiteral : '0' [bB] BinDigit (BinDigit | '_')* ; BinDigit : [01] ; OctalLiteral : '0' [oO] OctalDigit (OctalDigit | '_')* ; OctalDigit : [0-7] ; DecimalLiteral : ([1-9] (DecimalDigit | '_')*) | DecimalDigit ; DecimalDigit : [0-9] ; HexadecimalLiteral : '0' [xX] HexadecimalDigits ; HexadecimalDigits : HexadecimalDigit (HexadecimalDigit | '_')* ; HexadecimalDigit : [0-9a-fA-F] ; ``` -------------------------------- ### Multi-Line Raw String Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for multi-line raw string literals in Cangjie, enclosed by matching numbers of '#' characters and quotes. These literals preserve all characters, including escape sequences, and can span multiple lines. ```Cangjie MultiLineRawStringLiteral : MultiLineRawStringContent ; fragment MultiLineRawStringContent : '#' MultiLineRawStringContent '#' | '#' '"' .*? '"' '#' ; ``` -------------------------------- ### Cangjie Literal Constant Syntax Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the general syntax for literal constants in Cangjie, which represent immutable values. This includes integer, float, rune, boolean, and string literals. ```BNF literalConstant : IntegerLiteral | FloatLiteral | RuneLiteral | booleanLiteral | stringLiteral ; stringLiteral : lineStringLiteral | multiLineStringLiteral | MultiLineRawStringLiteral ; ``` -------------------------------- ### Cangjie Identifier Syntax Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for identifiers in the Cangjie programming language. Identifiers can be regular or raw, with raw identifiers enclosed in backticks and allowing keywords within. ```BNF identifier : Identifier | PUBLIC | PRIVATE | PROTECTED | OVERRIDE | ABSTRACT | SEALED | OPEN | REDEF | GET | SET ; Identifier : '_'* Letter (Letter | '_' | DecimalDigit)* | '`' '_'* Letter (Letter | '_' | DecimalDigit)* '`' ; Letter : [a-zA-Z] ; DecimalDigit : [0-9] ; ``` -------------------------------- ### Multi-Line String Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for multi-line string literals in Cangjie, enclosed in triple quotes (''' or """). These literals can span multiple lines and support escaped characters, with specific rules for handling quotes and newlines. ```Cangjie multiLineStringLiteral : '"""' NL (multiLineStringExpression | multiLineStringContent)* '"""' ; multiLineStringExpression : ' end* (expressionOrDeclaration (end+ expressionOrDeclaration?)*) end* ' ; multiLineStringContent : MultiLineStrText ; MultiLineStrText : ~('\\') | EscapeSeq ; ``` -------------------------------- ### Single-Line String Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for single-line string literals in Cangjie, enclosed in single or double quotes. It allows for escaped characters and prohibits newlines within the string content. ```Cangjie lineStringLiteral : '"' (lineStringExpression | lineStringContent)* '"' ; lineStringExpression : ' SEMI* (expressionOrDeclaration (SEMI+ expressionOrDeclaration?)*) SEMI* ' ; lineStringContent : LineStrText ; LineStrText : ~["\\] | EscapeSeq ; ``` -------------------------------- ### Boolean Literal Syntax (Cangjie) Source: https://cangjie-lang.cn/docs/index_url=%2F0.53.18%2FSpec%2Fsource_zh_cn%2FChapter_01_Lexical_Structure%28zh%29.html Defines the syntax for boolean literals in Cangjie, which are limited to 'true' and 'false'. This is a simple grammar rule for representing boolean values. ```Cangjie booleanLiteral : 'true' | 'false' ; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.