1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

Update iscdhcp xml file (#778)

This updates the ISC dhcp XML lexer. It:

- Fixes functions in function by removed the arglist state, this make
  NameFunction tokens work.
- Adds KeywordType for more words that can open a brace delimited
  section.
- Remove another set of Keyword so that they become NameVariables

Note on that latter point, from what I could scrape together from the
dhcp manual pages is that there exist 150+ directives/keywords in that
syntax, I pondered adding them all, but there lays madness, so sort of
took the middle ground, in the hopes it is useful enough to other folks

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2023-03-27 22:38:06 +02:00 committed by GitHub
parent 7c08f459bd
commit 8588e37b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 51 deletions

View File

@ -18,47 +18,32 @@
<token type="LiteralStringInterpol"/>
</rule>
</state>
<state name="arglist">
<rule pattern="\)">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern=",">
<token type="Punctuation"/>
</rule>
<rule pattern="[\w\-.]+">
<token type="NameVariable"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
</state>
<state name="root">
<rule pattern="#.*?\n">
<token type="Comment"/>
</rule>
<rule pattern="(group|host|subnet|netmask|class|pool)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="(authoritative|domain-name-servers|ethernet|fixed-address|hardware|option|use-host-decl-name|include)\b">
<rule pattern="(hardware|packet|leased-address|host-decl-name|lease-time|max-lease-time|client-state|config-option|option|filename|next-server|allow|deny|match|ignore)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(on|off|true|false)\b">
<rule pattern="(include|group|host|subnet|subnet6|netmask|class|subclass|pool|failover|include|shared-network|range|range6|prefix6)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="(on|off|true|false|none)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="(if|elsif|else)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(exists|known|static)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="(and|or|not)\b">
<token type="OperatorWord"/>
</rule>
<rule pattern="(==|!=|~=|~~|=)">
<token type="Operator"/>
</rule>
<rule pattern="(exists|known|static)\b">
<token type="Keyword"/>
</rule>
<rule pattern="[{},;]">
<rule pattern="[{},;\)]">
<token type="Punctuation"/>
</rule>
<rule pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}">
@ -70,21 +55,20 @@
<rule pattern="[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="(\w+)(\s+)(\()">
<rule pattern="&#34;">
<token type="LiteralString"/>
<push state="doublequotestring"/>
</rule>
<rule pattern="([\w\-.]+)(\s*)(\()">
<bygroups>
<token type="NameFunction"/>
<token type="Text"/>
<token type="Punctuation"/>
</bygroups>
<push state="arglist"/>
</rule>
<rule pattern="[\w\-.]+">
<token type="NameVariable"/>
</rule>
<rule pattern="&#34;">
<token type="LiteralString"/>
<push state="doublequotestring"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>

View File

@ -32,6 +32,7 @@ subnet 10.254.239.32 netmask 255.255.255.224 {
option routers rtr-239-32-1.example.org;
}
# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {
range 10.5.5.26 10.5.5.30;
@ -57,6 +58,7 @@ host fantasia {
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "S\"UNW";
log(info,concat("SUN request from ",host-decl-name));
}
shared-network 224-29 {

View File

@ -11,7 +11,7 @@
{"type":"Text","value":"\n"},
{"type":"Keyword","value":"option"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"domain-name-servers"},
{"type":"NameVariable","value":"domain-name-servers"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"ns1.example.org"},
{"type":"Punctuation","value":","},
@ -24,17 +24,17 @@
{"type":"NameVariable","value":"600"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n"},
{"type":"NameVariable","value":"max-lease-time"},
{"type":"Keyword","value":"max-lease-time"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"7200"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n\n"},
{"type":"NameVariable","value":"ddns-update-style"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"none"},
{"type":"KeywordConstant","value":"none"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n\n"},
{"type":"Keyword","value":"authoritative"},
{"type":"NameVariable","value":"authoritative"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n\n"},
{"type":"NameVariable","value":"log-facility"},
@ -54,7 +54,7 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"range"},
{"type":"KeywordType","value":"range"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"10.254.239.10"},
{"type":"Text","value":" "},
@ -83,7 +83,7 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"range"},
{"type":"KeywordType","value":"range"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"dynamic-bootp"},
{"type":"Text","value":" "},
@ -107,7 +107,7 @@
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n\n"},
{"type":"Text","value":"\n\n\n"},
{"type":"Comment","value":"# A slightly different configuration for an internal subnet.\n"},
{"type":"KeywordType","value":"subnet"},
{"type":"Text","value":" "},
@ -119,7 +119,7 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"range"},
{"type":"KeywordType","value":"range"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"10.5.5.26"},
{"type":"Text","value":" "},
@ -128,7 +128,7 @@
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"option"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"domain-name-servers"},
{"type":"NameVariable","value":"domain-name-servers"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"ns1.internal.example.org"},
{"type":"Punctuation","value":";"},
@ -167,7 +167,7 @@
{"type":"NameVariable","value":"600"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"max-lease-time"},
{"type":"Keyword","value":"max-lease-time"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"7200"},
{"type":"Punctuation","value":";"},
@ -182,12 +182,12 @@
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"hardware"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"ethernet"},
{"type":"NameVariable","value":"ethernet"},
{"type":"Text","value":" "},
{"type":"LiteralNumberHex","value":"0:0:c0:5d:bd:95"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"filename"},
{"type":"Keyword","value":"filename"},
{"type":"Text","value":" "},
{"type":"LiteralString","value":"\"vmunix.passacaglia\""},
{"type":"Punctuation","value":";"},
@ -207,12 +207,12 @@
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"hardware"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"ethernet"},
{"type":"NameVariable","value":"ethernet"},
{"type":"Text","value":" "},
{"type":"LiteralNumberHex","value":"08:00:07:26:c0:a5"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"fixed-address"},
{"type":"NameVariable","value":"fixed-address"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"fantasia.example.com"},
{"type":"Punctuation","value":";"},
@ -225,14 +225,14 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"match"},
{"type":"Keyword","value":"match"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"if"},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"substring"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"("},
{"type":"NameVariable","value":"option"},
{"type":"Keyword","value":"option"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"vendor-class-identifier"},
{"type":"Punctuation","value":","},
@ -249,10 +249,21 @@
{"type":"LiteralStringEscape","value":"\\\""},
{"type":"LiteralString","value":"UNW\""},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"NameFunction","value":"log"},
{"type":"Punctuation","value":"("},
{"type":"NameVariable","value":"info"},
{"type":"Punctuation","value":","},
{"type":"NameFunction","value":"concat"},
{"type":"Punctuation","value":"("},
{"type":"LiteralString","value":"\"SUN request from \""},
{"type":"Punctuation","value":","},
{"type":"Keyword","value":"host-decl-name"},
{"type":"Punctuation","value":"));"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n\n"},
{"type":"NameVariable","value":"shared-network"},
{"type":"KeywordType","value":"shared-network"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"224-29"},
{"type":"Text","value":" "},
@ -300,7 +311,7 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"allow"},
{"type":"Keyword","value":"allow"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"members"},
{"type":"Text","value":" "},
@ -309,7 +320,7 @@
{"type":"LiteralString","value":"\"foo\""},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"range"},
{"type":"KeywordType","value":"range"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"10.17.224.10"},
{"type":"Text","value":" "},
@ -322,7 +333,7 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"deny"},
{"type":"Keyword","value":"deny"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"members"},
{"type":"Text","value":" "},
@ -331,7 +342,7 @@
{"type":"LiteralString","value":"\"foo\""},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n "},
{"type":"NameVariable","value":"range"},
{"type":"KeywordType","value":"range"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"10.0.29.10"},
{"type":"Text","value":" "},