9.1.3.1. lex

exception PythonicGcodeMachine.PythonLexYacc.lex.LexError(message, s)[source]

Bases: Exception

class PythonicGcodeMachine.PythonLexYacc.lex.LexToken[source]

Bases: object

Token class. This class is used to represent the tokens produced.

class PythonicGcodeMachine.PythonLexYacc.lex.Lexer[source]

Bases: object

Class to implement the Lexing Engine

The following Lexer class implements the lexer runtime. There are only a few public methods and attributes:

  • input() - Store a new string in the lexer
  • token() - Get the next token
  • clone() - Clone the lexer
  • lineno - Current line number
  • lexpos - Current position in the input string
begin(state)[source]

Changes the lexing state

clone(object=None)[source]
current_state()[source]

Returns the current lexing state

input(s)[source]

Push a new string into the lexer

next()[source]
pop_state()[source]

Restores the previous state

push_state(state)[source]

Changes the lexing state and saves old on stack

readtab(tabfile, fdict)[source]

Read lexer information from a tab file

skip(n)[source]

Skip ahead n characters

token()[source]

Return the next token from the Lexer

Note: This function has been carefully implemented to be as fast as possible. Don’t make changes unless you really know what you are doing

writetab(lextab, outputdir='')[source]

Write lexer information to a table file

class PythonicGcodeMachine.PythonLexYacc.lex.LexerReflect(ldict, log=None, reflags=0)[source]

Bases: object

This class represents information needed to build a lexer as extracted from a user’s input file.

get_all()[source]

Get all of the basic information

get_literals()[source]

Get the literals specifier

get_rules()[source]

Get all of the symbols with a t_ prefix and sort them into various categories (functions, strings, error functions, and ignore characters)

get_states()[source]
get_tokens()[source]

Get the tokens map

validate_all()[source]

Validate all of the information

validate_literals()[source]

Validate literals

validate_module(module)[source]

” This checks to see if there are duplicated t_rulename() functions or strings in the parser input file. This is done using a simple regular expression match on each line in the source code of the given module.

validate_rules()[source]

Validate all of the t_rules collected

validate_tokens()[source]

Validate the tokens

class PythonicGcodeMachine.PythonLexYacc.lex.NullLogger[source]

Bases: object

Null logger is used when no output is generated. Does nothing.

class PythonicGcodeMachine.PythonLexYacc.lex.PlyLogger(f)[source]

Bases: object

This object is a stand-in for a logging object created by the logging module.

critical(msg, *args, **kwargs)[source]
debug(msg, *args, **kwargs)
error(msg, *args, **kwargs)[source]
info(msg, *args, **kwargs)
warning(msg, *args, **kwargs)[source]
PythonicGcodeMachine.PythonLexYacc.lex.TOKEN(r)[source]
PythonicGcodeMachine.PythonLexYacc.lex.Token(r)
PythonicGcodeMachine.PythonLexYacc.lex.get_caller_module_dict(levels)[source]

This function returns a dictionary containing all of the symbols defined within a caller further down the call stack. This is used to get the environment associated with the yacc() call if none was provided.

PythonicGcodeMachine.PythonLexYacc.lex.lex(module=None, object=None, debug=False, optimize=False, lextab='lextab', reflags=64, nowarn=False, outputdir=None, debuglog=None, errorlog=None)[source]