Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/gcodelexer.py: 100%
8 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:45 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:45 +0000
1"""
2 pygments.lexers.gcodelexer
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 Lexers for the G Code Language.
7 :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer, bygroups
12from pygments.token import Comment, Name, Text, Keyword, Number
14__all__ = ['GcodeLexer']
17class GcodeLexer(RegexLexer):
18 """
19 For gcode source code.
21 .. versionadded:: 2.9
22 """
23 name = 'g-code'
24 aliases = ['gcode']
25 filenames = ['*.gcode']
27 tokens = {
28 'root': [
29 (r';.*\n', Comment),
30 (r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands
31 (r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)),
32 (r'\s', Text.Whitespace),
33 (r'.*\n', Text),
34 ]
35 }