Skip to content

Commit

Permalink
Extend pygments grammar definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Sep 30, 2024
1 parent 8f0d4f6 commit 2349140
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/pygerber/gerber/pygments.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,24 @@ class GerberLexer(RegexLexer):
(r"Y(?=[0-9]+)", Keyword),
(r"I(?=[0-9]+)", Keyword),
(r"J(?=[0-9]+)", Keyword),
# properties
(r"(?<=%)FS", Keyword),
(r"(?<=%FS)[LT][AI]", Keyword.Constant),
(r"(?<=%)IP", Keyword),
(r"(?<=%)IR", Keyword),
(r"(?<=%)MO(?=MM|IN)", Keyword),
(r"(?<=%MO)(MM|IN)", Keyword.Constant),
(r"(?<=%)OF", Keyword),
(r"(?<=%)AS", Keyword),
(r"(?<=%)MI", Keyword),
(r"(?<=%)IN", Keyword),
(r"(?<=%)SF", Keyword),
# attributes
(r"(?<=%)TA", Keyword),
(r"(?<=%)TO", Keyword),
(r"(?<=%)TF", Keyword),
(r"(?<=%)TD", Keyword),
(r"(?<=%)MO(?=MM|IN)", Keyword),
(r"(?<=%MO)(MM|IN)", Keyword.Constant),
# apertures
(r"(?<=%ADD[0-9])[._a-zA-Z$][._a-zA-Z0-9]*", Name.Class),
(r"(?<=%ADD[0-9][0-9])[._a-zA-Z$][._a-zA-Z0-9]*", Name.Class),
(r"(?<=%ADD[0-9][0-9][0-9])[._a-zA-Z$][._a-zA-Z0-9]*", Name.Class),
Expand All @@ -63,14 +73,18 @@ class GerberLexer(RegexLexer):
(r"(?<=%AM)[._a-zA-Z$][._a-zA-Z0-9]*", Name.Class),
(r"(?<=%)AB", Keyword),
(r"(?<=%)SR", Keyword),
# D codes
(r"D0*1(?=\*)", Keyword),
(r"D0*2(?=\*)", Keyword),
(r"D0*3(?=\*)", Keyword),
(r"D[0-9]+", Name.Variable),
# G codes
(r"G[0-9]+", Keyword),
# M codes
(r"M[0-9]+", Keyword),
(r"[0-9]+\.[0-9]+", Number),
(r"[0-9]+", Number),
(r"\$[0-9]+", Name.Variable),
(r"[+-]*[0-9]+\.[0-9]+", Number),
(r"[+-]*[0-9]+", Number),
]
}

Expand Down

0 comments on commit 2349140

Please sign in to comment.