pyab_experiment.language.lexer#

Lexical Analysis for Experiment Language Definition

This module defines the lexer for the experiment language definition. It includes common constructs such as operators, identifiers, and literals (floats, integers). The module also defines reserved keywords used by the grammar.

The lexical analysis is performed using YACC (via the SLY implementation) for finite state automaton processing.

Module Contents#

Classes#

BlockComment

Helper state that deals with C style opening

ExperimentLexer

Lexical analyzer for an AB testing configuration language.

class pyab_experiment.language.lexer.BlockComment[source]#

Bases: pyab_experiment.sly.Lexer

Helper state that deals with C style opening and closing block comments

ignore_newline = '\\n+'[source]#
tokens[source]#
BLOCK_COMMENT_END(t)[source]#
ignore_newline(t)[source]#
t_block_comment_content(t)[source]#
class pyab_experiment.language.lexer.ExperimentLexer[source]#

Bases: pyab_experiment.sly.Lexer

Lexical analyzer for an AB testing configuration language.

This class provides a method for tokenizing an AB testing configuration file into a list of tokens, to be used for parsing and validation, in conjunction with the grammar defined in a companion class. The lexer uses regular expressions to match terminal patterns in the configuration file and generate corresponding tokens.

COLON = ':'[source]#
COMMA = ','[source]#
ID = '[a-zA-Z_][a-zA-Z0-9_]*'[source]#
KW_AND = 'and'[source]#
KW_DEF = 'def'[source]#
KW_ELIF = 'else\\s*if'[source]#
KW_ELSE = 'else'[source]#
KW_EQ = '=='[source]#
KW_GE = '>='[source]#
KW_GT = '>'[source]#
KW_IF = 'if'[source]#
KW_IN = 'in'[source]#
KW_LE = '<='[source]#
KW_LT = '<'[source]#
KW_NE = '!='[source]#
KW_NOT = 'not'[source]#
KW_NOT_IN = 'not\\s+in'[source]#
KW_OR = 'or'[source]#
KW_RETURN = 'return'[source]#
KW_SALT = 'salt'[source]#
KW_SPLITTERS = 'splitters'[source]#
KW_WEIGHTED = 'weighted'[source]#
LBRACE = '{'[source]#
LPAREN = '\\('[source]#
MINUS = '-'[source]#
RBRACE = '}'[source]#
RPAREN = '\\)'[source]#
ignore_inline_comment = '//.*'[source]#
ignore_newline = '\\n+'[source]#
ignore_ws = '\\s+'[source]#
tokens[source]#
BLOCK_COMMENT_START(t)[source]#
NON_NEG_FLOAT(t)[source]#
NON_NEG_INTEGER(t)[source]#
STRING_LITERAL(t)[source]#
error(t)[source]#
ignore_newline(t)[source]#