This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/pygments/lexers/gcodelexer.py
Jean Abou Samra 25f230191f Move versionadded data to a lexer attribute
That way, we can set it to "" for old lexers, and check that it's
present on new lexers. (In the future, we might also use it for better
presentation in the documentation.)
2023-11-26 14:51:52 +01:00

35 lines
874 B
Python

"""
pygments.lexers.gcodelexer
~~~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for the G Code Language.
:copyright: Copyright 2006-2023 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.
"""
name = 'g-code'
aliases = ['gcode']
filenames = ['*.gcode']
url = 'https://en.wikipedia.org/wiki/G-code'
version_added = '2.9'
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),
]
}