![]() |
Belle II Software
light-2303-iriomote
|


Public Member Functions | |
| def | __init__ (self) |
| def | LBRACK (self, t) |
| def | RBRACK (self, t) |
| def | LPAREN (self, t) |
Public Attributes | |
| control_token_stack | |
| control_token_stack (list): stack for keeping track of seen brackets and parenthesis. More... | |
Static Public Attributes | |
| dictionary | cut_tokens |
| cut specific tokens More... | |
| dictionary | expression_tokens |
| expression tokens, also needed for cut. More... | |
| dictionary | tokens = expression_tokens.union(cut_tokens) |
| Set of all tokens. | |
| string | ignore = " \t\n" |
| ignore spaces tabs and newlines | |
| dictionary | literals = {r","} |
| comma token definition as literal | |
| string | EQUALEQUAL = r"==" |
| token regular expression for '==' | |
| string | GREATEREQUAL = r">=" |
| token regular expression for '>=' | |
| string | LESSEQUAL = r"<=" |
| token regular expression for '<=' | |
| string | GREATER = r">" |
| token regular expression for '>' | |
| string | LESS = r"<" |
| token regular expression for '<' | |
| string | NOTEQUAL = r"!=" |
| token regular expression for '!=' | |
| string | POWER = r"\*\*|\^" |
| token regular expression for power, both '**' and '^' allowed | |
| string | TIMES = r"\*" |
| token regular expression for '*' | |
| string | DIVIDE = r"/" |
| token regular expression for '/' | |
| string | PLUS = r"\+" |
| token regular expression for '+' | |
| string | MINUS = r"-" |
| token regular expression for '-' | |
Class responsible for scanning the cut and generating a stream of tokens. The token stream can be passed to `B2Parser` to generate a syntax tree.
Definition at line 73 of file b2parser.py.
| def __init__ | ( | self | ) |
Initialize Lexer
Definition at line 79 of file b2parser.py.
| def LBRACK | ( | self, | |
| t | |||
| ) |
Scan opening bracket.
Parameters:
t (sly.lex.token): token of type LBRACK
Raises:
SyntaxError: if no following closing bracket is found
in the input.
Side Effect:
Pushes 'BRACK' onto control_token_stack
Returns:
sly.lex.Token
Definition at line 146 of file b2parser.py.
| def LPAREN | ( | self, | |
| t | |||
| ) |
Scan opening parenthesis.
Parameters:
t (sly.lex.token): token of type LPAREN
Raises:
SyntaxError: if no following closing parenthesis is found
in the input.
Side Effect:
Pushes 'PAREN' onto control_token_stack
Returns:
sly.lex.Token
Definition at line 198 of file b2parser.py.
| def RBRACK | ( | self, | |
| t | |||
| ) |
Scan closing bracket.
Parameters:
t (sly.lex.token): token of type RBRACK
Raises:
SyntaxError: 1. If control_token_stack is empty, which means
no bracket was opened previously.
2. If state of control_token_stack is 'PAREN', which
means a closing parenthesis is expected.
Side Effect:
Pops object from control_token_stack
Returns:
sly.lex.Token
Definition at line 169 of file b2parser.py.
| control_token_stack |
control_token_stack (list): stack for keeping track of seen brackets and parenthesis.
Allows finding parenthesis and bracket syntax errors on scanner level.
Definition at line 84 of file b2parser.py.
|
static |
cut specific tokens
Definition at line 87 of file b2parser.py.
|
static |
expression tokens, also needed for cut.
Definition at line 97 of file b2parser.py.