feat(package): hemar: antlr grammar, but still does not work

This commit is contained in:
2025-11-26 14:48:51 +00:00
parent 8a08272f68
commit 777d48bf3d
16 changed files with 282 additions and 7 deletions

View File

@@ -0,0 +1,49 @@
lexer grammar HemarLexer;
// ---------- default mode: plain text ----------
// Everything that is not the start of "{[" is TEXT
TEXT
: ( ~'{' | '{' ~'[' )+
;
// When we see "{[", emit LeftBrace and enter TAG mode
LeftBrace
: '{[' -> pushMode(TAG)
;
// skip whitespace in plain text if you want
SKIP_WS
: [ \t\r\n]+ -> skip
;
// ---------- TAG mode: inside {[ ... ]} ----------
mode TAG;
fragment WS: [ \t\r\n] ;
For : 'for';
In : 'in';
End : 'end';
// identifier inside tag
Path
: String
| String '.' Path
;
String
: ( ~[.\] \t\r\n] | ']' ~[}. \t\r\n] )+
| '"' ( ~'"' | '\\' '"' )+ '"'
;
// closing "]}": emit RightBrace and go back to default mode
RightBrace
: ']}' -> popMode
;
// skip whitespace inside tag
SKIP_TAG_WS
: WS+ -> skip
;