9.1.1.5.4. Lexer

Module to implement a RS-274 G-code lexer.

exception PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeLexerError[source]

Bases: ValueError

class PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeLexer[source]

Bases: PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeLexerMixin, PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeTokenMixin

class PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeLexerMixin[source]

Bases: object

Class to implement a RS-274 G-code lexer.

input(data)[source]
tokenize(data)[source]
class PythonicGcodeMachine.Gcode.Rs274.Lexer.GcodeTokenMixin[source]

Bases: object

Mixin to define RS-274 G-code tokens.

T_B = 'b'
t_A = 'a'
t_ABSOLUTE_VALUE = 'abs'
t_AND = 'and'
t_ARC_COSINE = 'acos'
t_ARC_SINE = 'asin'
t_ARC_TANGENT = 'atan'
t_C = 'c'
t_COSINE = 'cos'
t_D = 'd'
t_DIVIDED_BY = '\\/'
t_EOF_COMMENT(t)[source]

;.*

t_EQUAL_SIGN = '='
t_EXCLUSIVE_OR = 'xor'
t_E_RAISED_TO = 'exp'
t_F = 'f'
t_FIX_DOWN = 'fix'
t_FIX_UP = 'fup'
t_G = 'g'
t_H = 'h'
t_I = 'i'
t_INLINE_COMMENT(t)[source]

([^)]*)

t_J = 'j'
t_K = 'k'
t_L = 'l'
t_LEFT_BRACKET = '\\['
t_M = 'm'
t_MINUS = '-'
t_MODULO = 'mod'
t_N = 'n'
t_NATURAL_LOG_OF = 'ln'
t_NON_EXCLUSIVE_OR = 'or'
t_P = 'p'
t_PARAMETER_SIGN = '\\#'
t_PLUS = '\\+'
t_POWER = '\\*\\*'
t_Q = 'q'
t_R = 'r'
t_REAL(t)[source]

((+|-)?(d+.d*|(.)?d+))

t_RIGHT_BRACKET = '\\]'
t_ROUND = 'round'
t_S = 's'
t_SINE = 'sin'
t_SQUARE_ROOT = 'sqrt'
t_T = 't'
t_TANGENT = 'tan'
t_TIMES = '\\*'
t_X = 'x'
t_Y = 'y'
t_Z = 'z'
t_error(t)[source]

Error handling rule

t_ignore = ' \t'
tokens = ('ABSOLUTE_VALUE', 'AND', 'ARC_COSINE', 'ARC_SINE', 'ARC_TANGENT', 'COSINE', 'DIVIDED_BY', 'EQUAL_SIGN', 'EXCLUSIVE_OR', 'E_RAISED_TO', 'FIX_DOWN', 'FIX_UP', 'LEFT_BRACKET', 'MINUS', 'MODULO', 'NATURAL_LOG_OF', 'NON_EXCLUSIVE_OR', 'PARAMETER_SIGN', 'PLUS', 'POWER', 'RIGHT_BRACKET', 'ROUND', 'SINE', 'SQUARE_ROOT', 'TANGENT', 'TIMES', 'A', 'B', 'C', 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'P', 'Q', 'R', 'S', 'T', 'X', 'Y', 'Z', 'N', 'POSITIVE_INTEGER', 'POSITIVE_REAL', 'REAL', 'INLINE_COMMENT', 'EOF_COMMENT')