Last active
January 14, 2026 05:25
-
-
Save openly-retro/77c2a19549aa2711c42a8664769fd28b to your computer and use it in GitHub Desktop.
Attempt to describe up-to-date Stellaris (Clausewitz) script in Antlr grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false | |
| // $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging | |
| grammar oxr_stellaris_grammar; | |
| content | |
| : expr+ EOF | |
| ; | |
| expr | |
| : assignment+ | |
| | listitem | |
| | comparison+ | |
| ; | |
| assignment | |
| : key '=' val | |
| ; | |
| comparison | |
| : key ('>'|'<='|'<'|'>=') val | |
| ; | |
| listitem | |
| : key | |
| ; | |
| key | |
| : name | |
| | attrib | |
| | INTEGER | |
| ; | |
| val | |
| : name | |
| | number | |
| | FLOAT | |
| | BOOLEAN | |
| | block | |
| | INTEGER | |
| | STATICVAR | |
| | INLINESCRIPTREF | |
| | equation | |
| | attrib | |
| ; | |
| attrib | |
| : name accessor (attrib | name) | |
| ; | |
| accessor | |
| : '.' | |
| | '@' | |
| | ':' | |
| ; | |
| block | |
| : '{' (expr* | name) '}' | |
| ; | |
| equation | |
| : '@[' ( name | MATHSYMBOL )* ']' | |
| ; | |
| number | |
| : INTEGER | |
| | FLOAT | |
| ; | |
| name | |
| : STRING | |
| | IDENTIFIER | |
| | EVENTTARGET | |
| | STATICVAR | |
| ; | |
| INTEGER | |
| : [+-]? DIGIT+ | |
| ; | |
| FLOAT | |
| : INTEGER+ '.' DIGIT* | |
| | '.' DIGIT+ | |
| ; | |
| BOOLEAN | |
| : ('yes'|'no') | |
| ; | |
| MATHSYMBOL | |
| : ('+'|'-'|'*'|'('|')') ; | |
| fragment DIGIT | |
| : [0-9] | |
| ; | |
| IDENTIFIER | |
| : [a-zA-Z_0-9]+ | |
| ; | |
| EVENTTARGET | |
| : IDENTIFIER ':' IDENTIFIER | |
| ; | |
| STRING | |
| : '"' ~["\r\n]* '"' | |
| ; | |
| STATICVAR | |
| : '@' [a-zA-Z_0-9]+ | |
| ; | |
| INLINESCRIPTREF | |
| : [a-zA-Z/_]+ ; | |
| COMMENT | |
| : '#' ~[\r\n]* -> channel(HIDDEN) | |
| ; | |
| SPACE | |
| : [ \t\f] -> channel(HIDDEN) | |
| ; | |
| NL | |
| : [\r\n] -> channel(HIDDEN) | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment