From 51c42db1bdef9b8cc0d5b42cbd3b4c4903f11a68 Mon Sep 17 00:00:00 2001 From: Fabrice Salvaire Date: Mon, 24 Dec 2018 17:52:33 +0100 Subject: [PATCH] lexer cleanup --- PythonicGcodeMachine/Gcode/Rs274/Lexer.py | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/PythonicGcodeMachine/Gcode/Rs274/Lexer.py b/PythonicGcodeMachine/Gcode/Rs274/Lexer.py index ed9c95a..12c9efd 100644 --- a/PythonicGcodeMachine/Gcode/Rs274/Lexer.py +++ b/PythonicGcodeMachine/Gcode/Rs274/Lexer.py @@ -18,7 +18,16 @@ # #################################################################################################### -__all__ = ['GcodeLexerError', 'GcodeLexer'] +"""Module to implement a RS-274 G-code lexer.""" + +#################################################################################################### + +__all__ = [ + 'GcodeLexerError', + 'GcodeLexer', + 'GcodeLexerMixin', + 'GcodeTokenMixin', +] #################################################################################################### @@ -36,11 +45,9 @@ class GcodeLexerError(ValueError): #################################################################################################### -class GcodeLexer: +class GcodeTokenMixin: - """Class to implement a RS-274 G-code lexer. - - """ + """Mixin to define RS-274 G-code tokens. """ # List of token names. tokens = ( @@ -196,6 +203,12 @@ class GcodeLexer: # raise GcodeLexerError("Illegal character @{} '{}'".format(t.lexpos, t.value)) raise GcodeLexerError(t.lexpos) +#################################################################################################### + +class GcodeLexerMixin: + + """Class to implement a RS-274 G-code lexer.""" + ############################################## def __init__(self): @@ -226,3 +239,8 @@ class GcodeLexer: if not token: break yield token + +#################################################################################################### + +class GcodeLexer(GcodeLexerMixin, GcodeTokenMixin): + pass -- GitLab