You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
826 B
36 lines
826 B
3 years ago
|
"""
|
||
|
pygments.lexers.gcodelexer
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
|
||
|
Lexers for the G Code Language.
|
||
|
|
||
|
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
||
|
:license: BSD, see LICENSE for details.
|
||
|
"""
|
||
|
|
||
|
from pygments.lexer import RegexLexer, bygroups
|
||
|
from pygments.token import Comment, Name, Text, Keyword, Number
|
||
|
|
||
|
__all__ = ['GcodeLexer']
|
||
|
|
||
|
|
||
|
class GcodeLexer(RegexLexer):
|
||
|
"""
|
||
|
For gcode source code.
|
||
|
|
||
|
.. versionadded:: 2.9
|
||
|
"""
|
||
|
name = 'g-code'
|
||
|
aliases = ['gcode']
|
||
|
filenames = ['*.gcode']
|
||
|
|
||
|
tokens = {
|
||
|
'root': [
|
||
|
(r';.*\n', Comment),
|
||
|
(r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands
|
||
|
(r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)),
|
||
|
(r'\s', Text.Whitespace),
|
||
|
(r'.*\n', Text),
|
||
|
]
|
||
|
}
|