Skip to content

Commit 037695d

Browse files
committed
fix(chapi-ast-c): fix lexer grammar and update documentation
- 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.
1 parent 903396e commit 037695d

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

chapi-ast-c/src/main/antlr/CLexer.g4

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ lexer grammar CLexer;
22

33
channels { COMMENTS_CHANNEL, DIRECTIVE }
44

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

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

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

1817
Auto : 'auto' ;
@@ -192,8 +191,8 @@ DIRECTIVE_FALSE: 'false' -> channel(DIREC
192191
INCLUDE: 'include' -> channel(DIRECTIVE);
193192
DEFINE: 'define' -> channel(DIRECTIVE);
194193
UNDEF: 'undef' -> channel(DIRECTIVE);
195-
DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE), type(Ifdef);
196-
DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE), type(Ifndef);
194+
DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE), type(Ifdef);
195+
DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE), type(Ifndef);
197196
DIRECTIVE_IF: 'if' -> channel(DIRECTIVE), type(If);
198197
ELIF: 'elif' -> channel(DIRECTIVE);
199198
DIRECTIVE_ELSE: 'else' -> channel(DIRECTIVE), type(Else);
@@ -213,17 +212,11 @@ DIRECTIVE_BANG: '!' -> channel(DIREC
213212
DIRECTIVE_LG: '<' -> channel(DIRECTIVE), type(Less);
214213
DIRECTIVE_GT: '>' -> channel(DIRECTIVE), type(Greater);
215214
DIRECTIVE_DOT: '.' -> channel(DIRECTIVE), type(Dot);
216-
// '{'
217215
DIRECTIVE_LEFT_BRACE: '{' -> channel(DIRECTIVE), type(LeftBrace);
218-
// '}'
219216
DIRECTIVE_RIGHT_BRACE: '}' -> channel(DIRECTIVE), type(RightBrace);
220-
// ;
221217
DIRECTIVE_SEMI: ';' -> channel(DIRECTIVE), type(Semi);
222-
// ,
223218
DIRECTIVE_COMMA: ',' -> channel(DIRECTIVE), type(Comma);
224-
// *
225219
DIRECTIVE_STAR: '*' -> channel(DIRECTIVE), type(Star);
226-
// union
227220
DIRECTIVE_UNION: 'union' -> channel(DIRECTIVE), type(Union);
228221
DIRECTIVE_OP_EQ: '==' -> channel(DIRECTIVE), type(OP_EQ);
229222
DIRECTIVE_OP_NE: '!=' -> channel(DIRECTIVE), type(OP_NE);
@@ -248,7 +241,6 @@ fragment InputCharacter: ~[\r\n\u0085\u2028\u2029];
248241
fragment IdentifierNondigit
249242
: Nondigit
250243
| UniversalCharacterName
251-
//| // other implementation-defined characters...
252244
;
253245

254246
fragment Nondigit

docs/home.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ permalink: /
1717
> language source code into a unified abstract model, simplifying cross-language development. Chapi
1818
> 是一个通用层次抽象解析器与信息转换器,它可以将不同编程语言的源代码转换为统一的层次抽象模型。
1919
20-
Chapi => Cha + Pi => Tea Pi => Tea π => 茶 π. See on in
20+
Chapi => Cha + Pi => Tea Pi => Tea π => 茶 π. See on in
2121
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/).
2222

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

2525
language stages:
2626

0 commit comments

Comments
 (0)