Skip to content

Commit

Permalink
fix(chapi-ast-c): fix lexer grammar and update documentation
Browse files Browse the repository at this point in the history
- Fix lexer grammar in CLexer.g4 file to capture certain tokens correctly.
- Update the documentation in home.md file to correct spelling and add pronunciation information for "Chapi".
- Also, add a reference link about the spread of the word "tea" over land and sea.
- This commit improves the accuracy of the lexer and enhances the documentation for the Chapi project.
  • Loading branch information
phodal committed Feb 3, 2024
1 parent 903396e commit 037695d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 3 additions & 11 deletions chapi-ast-c/src/main/antlr/CLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ lexer grammar CLexer;

channels { COMMENTS_CHANNEL, DIRECTIVE }

//options { superClass = chapi.ast.antlr.CLexerBase; }

SINGLE_LINE_DOC_COMMENT: '///' InputCharacter* -> channel(COMMENTS_CHANNEL);
EMPTY_DELIMITED_DOC_COMMENT: '/***/' -> channel(COMMENTS_CHANNEL);
DELIMITED_DOC_COMMENT: '/**' ~'/' .*? '*/' -> channel(COMMENTS_CHANNEL);
SINGLE_LINE_COMMENT: '//' InputCharacter* -> channel(COMMENTS_CHANNEL);
DELIMITED_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL);
WHITESPACES: (Whitespace | Newline)+ -> channel(HIDDEN);
// if we want to capture in again, we can use
SHARP: '#' -> mode(DIRECTIVE_MODE), skip;

//Directive: '#' ~ [\n]* -> channel (HIDDEN);
MultiLineMacro: '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN);

Auto : 'auto' ;
Expand Down Expand Up @@ -192,8 +191,8 @@ DIRECTIVE_FALSE: 'false' -> channel(DIREC
INCLUDE: 'include' -> channel(DIRECTIVE);
DEFINE: 'define' -> channel(DIRECTIVE);
UNDEF: 'undef' -> channel(DIRECTIVE);
DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE), type(Ifdef);
DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE), type(Ifndef);
DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE), type(Ifdef);
DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE), type(Ifndef);
DIRECTIVE_IF: 'if' -> channel(DIRECTIVE), type(If);
ELIF: 'elif' -> channel(DIRECTIVE);
DIRECTIVE_ELSE: 'else' -> channel(DIRECTIVE), type(Else);
Expand All @@ -213,17 +212,11 @@ DIRECTIVE_BANG: '!' -> channel(DIREC
DIRECTIVE_LG: '<' -> channel(DIRECTIVE), type(Less);
DIRECTIVE_GT: '>' -> channel(DIRECTIVE), type(Greater);
DIRECTIVE_DOT: '.' -> channel(DIRECTIVE), type(Dot);
// '{'
DIRECTIVE_LEFT_BRACE: '{' -> channel(DIRECTIVE), type(LeftBrace);
// '}'
DIRECTIVE_RIGHT_BRACE: '}' -> channel(DIRECTIVE), type(RightBrace);
// ;
DIRECTIVE_SEMI: ';' -> channel(DIRECTIVE), type(Semi);
// ,
DIRECTIVE_COMMA: ',' -> channel(DIRECTIVE), type(Comma);
// *
DIRECTIVE_STAR: '*' -> channel(DIRECTIVE), type(Star);
// union
DIRECTIVE_UNION: 'union' -> channel(DIRECTIVE), type(Union);
DIRECTIVE_OP_EQ: '==' -> channel(DIRECTIVE), type(OP_EQ);
DIRECTIVE_OP_NE: '!=' -> channel(DIRECTIVE), type(OP_NE);
Expand All @@ -248,7 +241,6 @@ fragment InputCharacter: ~[\r\n\u0085\u2028\u2029];
fragment IdentifierNondigit
: Nondigit
| UniversalCharacterName
//| // other implementation-defined characters...
;

fragment Nondigit
Expand Down
4 changes: 2 additions & 2 deletions docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ permalink: /
> language source code into a unified abstract model, simplifying cross-language development. Chapi
> 是一个通用层次抽象解析器与信息转换器,它可以将不同编程语言的源代码转换为统一的层次抽象模型。
Chapi => Cha + Pi => Tea Pi => Tea π => 茶 π. See on in
Chapi => Cha + Pi => Tea Pi => Tea π => 茶 π. See on in
refs: [Tea if by sea, cha if by land](https://qz.com/1176962/map-how-the-word-tea-spread-over-land-and-sea-to-conquer-the-world/).

Chapi (pronoounce /tʃɑpi/) also pronounce XP in Chinese if you always call X in 叉.
Chapi (pronounce /tʃɑpi/) also pronounce XP in Chinese if you always call X in 叉.

language stages:

Expand Down

0 comments on commit 037695d

Please sign in to comment.