Belle II Software development
|
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. | |
Static Public Attributes | |
dict | cut_tokens |
cut specific tokens | |
dict | expression_tokens |
expression tokens, also needed for cut. | |
dict | tokens = expression_tokens.union(cut_tokens) |
Set of all tokens. | |
str | ignore = " \t\n" |
ignore spaces tabs and newlines | |
dict | literals = {r","} |
comma token definition as literal | |
str | EQUALEQUAL = r"==" |
token regular expression for '==' | |
str | GREATEREQUAL = r">=" |
token regular expression for '>=' | |
str | LESSEQUAL = r"<=" |
token regular expression for '<=' | |
str | GREATER = r">" |
token regular expression for '>' | |
str | LESS = r"<" |
token regular expression for '<' | |
str | NOTEQUAL = r"!=" |
token regular expression for '!=' | |
str | POWER = r"\*\*|\^" |
token regular expression for power, both '**' and '^' allowed | |
str | TIMES = r"\*" |
token regular expression for '*' | |
str | DIVIDE = r"/" |
token regular expression for '/' | |
str | PLUS = r"\+" |
token regular expression for '+' | |
str | MINUS = r"-" |
token regular expression for '-' | |
Parameters : | |
Raises : | |
int | SyntaxError : 1. If control_token_stack is empty, which means |
Returns : | |
Warning : | |
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 |
token regular expression for '/'
Definition at line 135 of file b2parser.py.
|
static |
token regular expression for '=='
Definition at line 117 of file b2parser.py.
|
static |
expression tokens, also needed for cut.
Definition at line 97 of file b2parser.py.
|
static |
token regular expression for '>'
Definition at line 123 of file b2parser.py.
|
static |
token regular expression for '>='
Definition at line 119 of file b2parser.py.
|
static |
ignore spaces tabs and newlines
Definition at line 109 of file b2parser.py.
|
static |
token regular expression for '<'
Definition at line 125 of file b2parser.py.
|
static |
token regular expression for '<='
Definition at line 121 of file b2parser.py.
|
static |
comma token definition as literal
Definition at line 113 of file b2parser.py.
|
static |
token regular expression for '-'
Definition at line 139 of file b2parser.py.
|
static |
token regular expression for '!='
Definition at line 127 of file b2parser.py.
|
static |
Definition at line 225 of file b2parser.py.
|
static |
token regular expression for '+'
Definition at line 137 of file b2parser.py.
|
static |
token regular expression for power, both '**' and '^' allowed
Definition at line 131 of file b2parser.py.
|
static |
Definition at line 228 of file b2parser.py.
|
static |
Definition at line 237 of file b2parser.py.
|
static |
Definition at line 229 of file b2parser.py.
|
static |
token regular expression for '*'
Definition at line 133 of file b2parser.py.
|
static |
Set of all tokens.
Definition at line 105 of file b2parser.py.
|
static |
Definition at line 284 of file b2parser.py.