// Regenerate parser by running 'python setup.py antlr' at project root.
grammar Override;
override: (
key EQ value? // key=value
| TILDE key (EQ value?)? // ~key | ~key=value
| PLUS key EQ value? // +key= | +key=value
) EOF;
key :
packageOrGroup // key
| packageOrGroup AT package (COLON package)? // group@pkg | group@pkg1:pkg2
| packageOrGroup AT COLON package // group@:pkg2
;
value: element | choiceSweep;
choiceSweep: element (COMMA element)+;
package: (ID | DOT_PATH);
packageOrGroup: package | ID (SLASH ID)+;
element:
NULL
| QUOTED_VALUE
| primitive
| listValue
| dictValue
;
primitive: (
ID
| INT
| FLOAT
| BOOL
| BACKSLASH
| SLASH
| COLON
| DASH
| PLUS
| DOT
| ASTERISK
| DOLLAR
| DOT_PATH
| INTERPOLATION
)+;
dictValue: DOPEN (ID COLON element (COMMA ID COLON element)*)? DCLOSE;
listValue: LOPEN (element(COMMA element)*)? LCLOSE;
// Tokens
LOPEN: '[';
LCLOSE: ']';
DOPEN: '{';
DCLOSE: '}';
COMMA: ',';
COLON: ':';
DOLLAR: '$';
EQ: '=';
PLUS: '+';
DASH: '-';
TILDE: '~';
DOT: '.';
BACKSLASH: '\\';
SLASH: '/';
AT: '@';
ASTERISK : '*';
// Types
INT: [+-]?('0' | [1-9][0-9_]*);
// does not currently support scientific notation. can be added later
fragment NAN: [Nn][Aa][Nn];
fragment INF: [Ii][Nn][Ff];
FLOAT: ([+-]?([0-9_]+ '.' [0-9_]+ | INF)|NAN);
fragment TRUE: [Tt][Rr][Uu][Ee];
fragment FALSE: [Ff][Aa][Ll][Ss][Ee];
BOOL: TRUE|FALSE;
NULL: [Nn][Uu][Ll][Ll];
ID : [a-zA-Z0-9_]+;
DOT_PATH: ID (DOT ID)+;
WS: (' ' | '\t')+ -> channel(HIDDEN);
QUOTED_VALUE: '\'' .*? '\'' | '"' .*? '"' ;
INTERPOLATION:
DOLLAR DOPEN (
// interpolation
(ID | DOT_PATH)
// custom interpolation
| ID COLON (ID | QUOTED_VALUE) (COMMA (ID | QUOTED_VALUE))*
) DCLOSE;
Thanks for answering.
Yeah, there isn't enough context there.
Hydra is a framework for configuring applications. one of the key
features is that you can override anything in the config from the
command line.
for example, if the app config is:
foo:
bar: 10
You could override it at runtiem with foo.bar=20.
This grammar is parsing the command line for this.
This tutorial describes the basic features of Hydra: https://hydra.cc/docs/next/tutorials/basic/your_first_app/simple_cli
This grammar is now documented here :
https://hydra.cc/docs/next/advanced/command_line_syntax
This doc describes extension to the grammar, adding support for
functions and type casts:
https://docs.google.com/document/d/1JDZGHKk4PrZHqsTTS6ao-DQOu2eVD4ULR6uAxVUR-WI/edit#
I understand that this is a lot to take in just to provide
feedback.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/34d9c948-faf7-4cbb-9f5d-6e9244aeddb4o%40googlegroups.com.