codekingpro/portable-devtools
114k
1"""2 pygments.lexers.gcodelexer3 ~~~~~~~~~~~~~~~~~~~~~~~~~~4 5 Lexers for the G Code Language.6 7 :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, bygroups12from pygments.token import Comment, Name, Text, Keyword, Number13 14__all__ = ['GcodeLexer']15 16 17class GcodeLexer(RegexLexer):18 """19 For gcode source code.20 """21 name = 'g-code'22 aliases = ['gcode']23 filenames = ['*.gcode']24 url = 'https://en.wikipedia.org/wiki/G-code'25 version_added = '2.9'26 27 tokens = {28 'root': [29 (r';.*\n', Comment),30 (r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands31 (r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)),32 (r'\s', Text.Whitespace),33 (r'.*\n', Text),34 ]35 }36 