agglovar.merge.config.parser
Lexer and parser for intersect configuration strings. Contains code for parsing string and generating an AST from according to grammar rules. Downstream objects will generate a configuration object from the AST.
Classes
Token lexer for intersect configuration strings. |
|
Intersect configuration parser. |
Module Contents
- class agglovar.merge.config.parser.IntersectConfigLexer(**kwdargs: dict)
Bases:
objectToken lexer for intersect configuration strings.
- parse_float(str_val: str) float
Parse float from string.
- Parameters:
str_val – String to parse.
- Returns:
Float value.
- Raises:
ValueError – If the string does not represent a float value.
- parse_int(str_val: str) int
Parse int from string.
- Parameters:
str_val – String to parse.
- Returns:
Integer value.
- Raises:
ValueError – If the string does not represent an int value.
- t_KEYWORD(t)
w(w|d)*
- t_KW_FALSE(t)
[fF][aA][lL][sS][eE]
- t_KW_MATCH(t)
[mM][aA][tT][cC][hH]
- t_KW_TRUE(t)
[tT][rR][uU][eE]
- t_T_FLOAT(t)
[+-]?(d+.d*)|(d*.d+)
- t_T_FLOAT_EXP(t)
[+-]?((d+.?d*)|(.d+))[eE][+-]?((d+.?d*)|(.d+))
- t_T_INT(t)
[+-]?(d+)
- t_T_INT_MULT(t)
[+-]?((d+.?d*)|(.d+))[kKmMgG]
- t_T_UNLIMITED(t)
[uU][nN][lL][iI][mM][iI][tT][eE][dD]
- t_error(t)
Handle lexer errors.
- Parameters:
t – Token that caused the error.
- Raises:
ValueError – Always raised for illegal characters.
- lexer: ply.lex.Lexer
- class agglovar.merge.config.parser.IntersectConfigParser(**kwdargs: Any)
Bases:
objectIntersect configuration parser.
- p_primitive_list_elements(p) None
- primitive_list_elementsprimitive_list_element
- primitive_list_element ‘,’ primitive_list_elements‘,’ primitive_list_elements
- parse(*args, **kwdargs) dict
Parse a configuration string.
Arguments are passed to the parser.
- Returns:
AST as a dictionary.
- Raises:
Exception – If the ply parser or lexer throws an exception. Multiple exception types may be thrown.
- lexer: ply.lex.Lexer
- parser: ply.yacc.LRParser