1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-10-30 23:57:49 +02:00

fix: add lexer compile time validation for group by

So that if there's a mismatch between capture groups and emitters, it
will error early.
This commit is contained in:
Alec Thomas
2025-06-20 20:13:09 +10:00
parent cd5c4a8d02
commit a5ceb288f9
12 changed files with 667 additions and 529 deletions

View File

@@ -12,7 +12,24 @@
<body>
<div class="container">
<h1 class="title">Chroma Playground ({{.Version}})</h1>
<nav class="level">
<div class="level-left">
<div class="level-item">
<h1 class="title">Chroma Playground ({{.Version}})</h1>
</div>
</div>
<div class="level-right">
<div class="level-item">
<div class="container has-text-centered">
<button name="darkmode" id="theme-toggle" class="button">
<span class="icon is-small">
<ion-icon id="theme-icon" name="ellipse-outline"></ion-icon>
</span>
</button>
</div>
</div>
</div>
</nav>
<div class="notification">
<button class="delete"></button>

View File

@@ -10,6 +10,12 @@ type Emitter interface {
Emit(groups []string, state *LexerState) Iterator
}
// ValidatingEmitter is an Emitter that can validate against a compiled rule.
type ValidatingEmitter interface {
Emitter
ValidateEmitter(rule *CompiledRule) error
}
// SerialisableEmitter is an Emitter that can be serialised and deserialised to/from JSON.
type SerialisableEmitter interface {
Emitter
@@ -30,6 +36,8 @@ type byGroupsEmitter struct {
Emitters
}
var _ ValidatingEmitter = (*byGroupsEmitter)(nil)
// ByGroups emits a token for each matching group in the rule's regex.
func ByGroups(emitters ...Emitter) Emitter {
return &byGroupsEmitter{Emitters: emitters}
@@ -37,6 +45,13 @@ func ByGroups(emitters ...Emitter) Emitter {
func (b *byGroupsEmitter) EmitterKind() string { return "bygroups" }
func (b *byGroupsEmitter) ValidateEmitter(rule *CompiledRule) error {
if len(rule.Regexp.GetGroupNumbers())-1 != len(b.Emitters) {
return fmt.Errorf("number of groups %d does not match number of emitters %d", len(rule.Regexp.GetGroupNumbers())-1, len(b.Emitters))
}
return nil
}
func (b *byGroupsEmitter) Emit(groups []string, state *LexerState) Iterator {
iterators := make([]Iterator, 0, len(groups)-1)
if len(b.Emitters) != len(groups)-1 {

View File

@@ -6,103 +6,104 @@
<rules>
<state name="attr">
<rule pattern="&#34;.*?&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule pattern="&#39;.*?&#39;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule pattern="[^\s&gt;]+">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
</state>
<state name="root">
<rule pattern="[^{([*#]+">
<token type="Other"/>
<token type="Other" />
</rule>
<rule pattern="(\{\{)(\s*)">
<bygroups>
<token type="CommentPreproc"/>
<token type="Text"/>
<token type="CommentPreproc" />
<token type="Text" />
</bygroups>
<push state="ngExpression"/>
<push state="ngExpression" />
</rule>
<rule pattern="([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)">
<bygroups>
<token type="Punctuation"/>
<token type="NameAttribute"/>
<token type="Punctuation"/>
<token type="Text"/>
<token type="Operator"/>
<token type="Text"/>
<token type="Punctuation" />
<token type="NameAttribute" />
<token type="Punctuation" />
<token type="Text" />
<token type="Operator" />
<token type="Text" />
</bygroups>
<push state="attr"/>
<push state="attr" />
</rule>
<rule pattern="([([]+)([\w:.-]+)([\])]+)(\s*)">
<bygroups>
<token type="Punctuation"/>
<token type="NameAttribute"/>
<token type="Punctuation"/>
<token type="Text"/>
<token type="Punctuation" />
<token type="NameAttribute" />
<token type="Punctuation" />
<token type="TextWhitespace" />
</bygroups>
</rule>
<rule pattern="([*#])([\w:.-]+)(\s*)(=)(\s*)">
<bygroups>
<token type="Punctuation"/>
<token type="NameAttribute"/>
<token type="Punctuation"/>
<token type="Operator"/>
<token type="Punctuation" />
<token type="NameAttribute" />
<token type="Punctuation" />
<token type="Operator" />
<token type="TextWhitespace" />
</bygroups>
<push state="attr"/>
<push state="attr" />
</rule>
<rule pattern="([*#])([\w:.-]+)(\s*)">
<bygroups>
<token type="Punctuation"/>
<token type="NameAttribute"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="NameAttribute" />
<token type="Punctuation" />
</bygroups>
</rule>
</state>
<state name="ngExpression">
<rule pattern="\s+(\|\s+)?">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="\}\}">
<token type="CommentPreproc"/>
<pop depth="1"/>
<token type="CommentPreproc" />
<pop depth="1" />
</rule>
<rule pattern=":?(true|false)">
<token type="LiteralStringBoolean"/>
<token type="LiteralStringBoolean" />
</rule>
<rule pattern=":?&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern=":?&#39;(\\\\|\\&#39;|[^&#39;])*&#39;">
<token type="LiteralStringSingle"/>
<token type="LiteralStringSingle" />
</rule>
<rule pattern="[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?">
<token type="LiteralNumber"/>
<token type="LiteralNumber" />
</rule>
<rule pattern="[a-zA-Z][\w-]*(\(.*\))?">
<token type="NameVariable"/>
<token type="NameVariable" />
</rule>
<rule pattern="\.[\w-]+(\(.*\))?">
<token type="NameVariable"/>
<token type="NameVariable" />
</rule>
<rule pattern="(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)">
<bygroups>
<token type="Operator"/>
<token type="Text"/>
<token type="LiteralString"/>
<token type="Text"/>
<token type="Operator"/>
<token type="Text"/>
<token type="LiteralString"/>
<token type="Text"/>
<token type="Operator" />
<token type="Text" />
<token type="LiteralString" />
<token type="Text" />
<token type="Operator" />
<token type="Text" />
<token type="LiteralString" />
<token type="Text" />
</bygroups>
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -8,123 +8,144 @@
<rules>
<state name="root">
<rule pattern="\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="¬\n">
<token type="LiteralStringEscape"/>
<token type="LiteralStringEscape" />
</rule>
<rule pattern="&#39;s\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="(--|#).*?$">
<token type="Comment"/>
<token type="Comment" />
</rule>
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push state="comment"/>
<token type="CommentMultiline" />
<push state="comment" />
</rule>
<rule pattern="[(){}!,.:]">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="(«)([^»]+)(»)">
<bygroups>
<token type="Text"/>
<token type="NameBuiltin"/>
<token type="Text"/>
<token type="Text" />
<token type="NameBuiltin" />
<token type="Text" />
</bygroups>
</rule>
<rule pattern="\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)">
<rule
pattern="\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)"
>
<bygroups>
<token type="Keyword"/>
<token type="NameBuiltin"/>
<token type="Keyword" />
<token type="NameBuiltin" />
</bygroups>
</rule>
<rule pattern="(-|\*|\+|&amp;|≠|&gt;=?|&lt;=?|=|≥|≤|/|÷|\^)">
<token type="Operator"/>
<token type="Operator" />
</rule>
<rule pattern="\b(and|or|is equal|equals|(is )?equal to|is not|isn&#39;t|isn&#39;t equal( to)?|is not equal( to)?|doesn&#39;t equal|does not equal|(is )?greater than|comes after|is not less than or equal( to)?|isn&#39;t less than or equal( to)?|(is )?less than|comes before|is not greater than or equal( to)?|isn&#39;t greater than or equal( to)?|(is )?greater than or equal( to)?|is not less than|isn&#39;t less than|does not come before|doesn&#39;t come before|(is )?less than or equal( to)?|is not greater than|isn&#39;t greater than|does not come after|doesn&#39;t come after|starts? with|begins? with|ends? with|contains?|does not contain|doesn&#39;t contain|is in|is contained by|is not in|is not contained by|isn&#39;t contained by|div|mod|not|(a )?(ref( to)?|reference to)|is|does)\b">
<token type="OperatorWord"/>
<rule
pattern="\b(and|or|is equal|equals|(is )?equal to|is not|isn&#39;t|isn&#39;t equal( to)?|is not equal( to)?|doesn&#39;t equal|does not equal|(is )?greater than|comes after|is not less than or equal( to)?|isn&#39;t less than or equal( to)?|(is )?less than|comes before|is not greater than or equal( to)?|isn&#39;t greater than or equal( to)?|(is )?greater than or equal( to)?|is not less than|isn&#39;t less than|does not come before|doesn&#39;t come before|(is )?less than or equal( to)?|is not greater than|isn&#39;t greater than|does not come after|doesn&#39;t come after|starts? with|begins? with|ends? with|contains?|does not contain|doesn&#39;t contain|is in|is contained by|is not in|is not contained by|isn&#39;t contained by|div|mod|not|(a )?(ref( to)?|reference to)|is|does)\b"
>
<token type="OperatorWord" />
</rule>
<rule pattern="^(\s*(?:on|end)\s+)(zoomed|write to file|will zoom|will show|will select tab view item|will resize( sub views)?|will resign active|will quit|will pop up|will open|will move|will miniaturize|will hide|will finish launching|will display outline cell|will display item cell|will display cell|will display browser cell|will dismiss|will close|will become active|was miniaturized|was hidden|update toolbar item|update parameters|update menu item|shown|should zoom|should selection change|should select tab view item|should select row|should select item|should select column|should quit( after last window closed)?|should open( untitled)?|should expand item|should end editing|should collapse item|should close|should begin editing|selection changing|selection changed|selected tab view item|scroll wheel|rows changed|right mouse up|right mouse dragged|right mouse down|resized( sub views)?|resigned main|resigned key|resigned active|read from file|prepare table drop|prepare table drag|prepare outline drop|prepare outline drag|prepare drop|plugin loaded|parameters updated|panel ended|opened|open untitled|number of rows|number of items|number of browser rows|moved|mouse up|mouse moved|mouse exited|mouse entered|mouse dragged|mouse down|miniaturized|load data representation|launched|keyboard up|keyboard down|items changed|item value changed|item value|item expandable|idle|exposed|end editing|drop|drag( (entered|exited|updated))?|double clicked|document nib name|dialog ended|deminiaturized|data representation|conclude drop|column resized|column moved|column clicked|closed|clicked toolbar item|clicked|choose menu item|child of item|changed|change item value|change cell value|cell value changed|cell value|bounds changed|begin editing|became main|became key|awake from nib|alert ended|activated|action|accept table drop|accept outline drop)">
<bygroups>
<token type="Keyword"/>
<token type="NameFunction"/>
</bygroups>
<rule
pattern="^(\s*(?:on|end)\s+)(zoomed|write to file|will zoom|will show|will select tab view item|will resize( sub views)?|will resign active|will quit|will pop up|will open|will move|will miniaturize|will hide|will finish launching|will display outline cell|will display item cell|will display cell|will display browser cell|will dismiss|will close|will become active|was miniaturized|was hidden|update toolbar item|update parameters|update menu item|shown|should zoom|should selection change|should select tab view item|should select row|should select item|should select column|should quit( after last window closed)?|should open( untitled)?|should expand item|should end editing|should collapse item|should close|should begin editing|selection changing|selection changed|selected tab view item|scroll wheel|rows changed|right mouse up|right mouse dragged|right mouse down|resized( sub views)?|resigned main|resigned key|resigned active|read from file|prepare table drop|prepare table drag|prepare outline drop|prepare outline drag|prepare drop|plugin loaded|parameters updated|panel ended|opened|open untitled|number of rows|number of items|number of browser rows|moved|mouse up|mouse moved|mouse exited|mouse entered|mouse dragged|mouse down|miniaturized|load data representation|launched|keyboard up|keyboard down|items changed|item value changed|item value|item expandable|idle|exposed|end editing|drop|drag( (entered|exited|updated))?|double clicked|document nib name|dialog ended|deminiaturized|data representation|conclude drop|column resized|column moved|column clicked|closed|clicked toolbar item|clicked|choose menu item|child of item|changed|change item value|change cell value|cell value changed|cell value|bounds changed|begin editing|became main|became key|awake from nib|alert ended|activated|action|accept table drop|accept outline drop)"
>
<token type="Keyword" />
</rule>
<rule pattern="^(\s*)(in|on|script|to)(\s+)">
<bygroups>
<token type="Text"/>
<token type="Keyword"/>
<token type="Text"/>
<token type="Text" />
<token type="Keyword" />
<token type="Text" />
</bygroups>
</rule>
<rule pattern="\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b">
<rule
pattern="\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b"
>
<bygroups>
<token type="Keyword"/>
<token type="NameClass"/>
<token type="Keyword" />
<token type="NameClass" />
</bygroups>
</rule>
<rule pattern="\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b">
<token type="NameConstant"/>
<rule
pattern="\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b"
>
<token type="NameConstant" />
</rule>
<rule pattern="\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b">
<token type="NameBuiltin"/>
<rule
pattern="\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|with|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b">
<token type="Keyword"/>
<rule
pattern="\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|with|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b"
>
<token type="Keyword" />
</rule>
<rule pattern="\b(global|local|prop(erty)?|set|get)\b">
<token type="Keyword"/>
<token type="Keyword" />
</rule>
<rule pattern="\b(but|put|returning|the)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(attachment|attribute run|character|day|month|paragraph|word|year)s?\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(about|above|against|apart from|around|aside from|at|below|beneath|beside|between|for|given|instead of|on|onto|out of|over|since)\b">
<token type="NameBuiltin"/>
<rule
pattern="\b(about|above|against|apart from|around|aside from|at|below|beneath|beside|between|for|given|instead of|on|onto|out of|over|since)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(accepts arrow key|action method|active|alignment|allowed identifiers|allows branch selection|allows column reordering|allows column resizing|allows column selection|allows customization|allows editing text attributes|allows empty selection|allows mixed state|allows multiple selection|allows reordering|allows undo|alpha( value)?|alternate image|alternate increment value|alternate title|animation delay|associated file name|associated object|auto completes|auto display|auto enables items|auto repeat|auto resizes( outline column)?|auto save expanded items|auto save name|auto save table columns|auto saves configuration|auto scroll|auto sizes all columns to fit|auto sizes cells|background color|bezel state|bezel style|bezeled|border rect|border type|bordered|bounds( rotation)?|box type|button returned|button type|can choose directories|can choose files|can draw|can hide|cell( (background color|size|type))?|characters|class|click count|clicked( data)? column|clicked data item|clicked( data)? row|closeable|collating|color( (mode|panel))|command key down|configuration|content(s| (size|view( margins)?))?|context|continuous|control key down|control size|control tint|control view|controller visible|coordinate system|copies( on scroll)?|corner view|current cell|current column|current( field)? editor|current( menu)? item|current row|current tab view item|data source|default identifiers|delta (x|y|z)|destination window|directory|display mode|displayed cell|document( (edited|rect|view))?|double value|dragged column|dragged distance|dragged items|draws( cell)? background|draws grid|dynamically scrolls|echos bullets|edge|editable|edited( data)? column|edited data item|edited( data)? row|enabled|enclosing scroll view|ending page|error handling|event number|event type|excluded from windows menu|executable path|expanded|fax number|field editor|file kind|file name|file type|first responder|first visible column|flipped|floating|font( panel)?|formatter|frameworks path|frontmost|gave up|grid color|has data items|has horizontal ruler|has horizontal scroller|has parent data item|has resize indicator|has shadow|has sub menu|has vertical ruler|has vertical scroller|header cell|header view|hidden|hides when deactivated|highlights by|horizontal line scroll|horizontal page scroll|horizontal ruler view|horizontally resizable|icon image|id|identifier|ignores multiple clicks|image( (alignment|dims when disabled|frame style|scaling))?|imports graphics|increment value|indentation per level|indeterminate|index|integer value|intercell spacing|item height|key( (code|equivalent( modifier)?|window))?|knob thickness|label|last( visible)? column|leading offset|leaf|level|line scroll|loaded|localized sort|location|loop mode|main( (bunde|menu|window))?|marker follows cell|matrix mode|maximum( content)? size|maximum visible columns|menu( form representation)?|miniaturizable|miniaturized|minimized image|minimized title|minimum column width|minimum( content)? size|modal|modified|mouse down state|movie( (controller|file|rect))?|muted|name|needs display|next state|next text|number of tick marks|only tick mark values|opaque|open panel|option key down|outline table column|page scroll|pages across|pages down|palette label|pane splitter|parent data item|parent window|pasteboard|path( (names|separator))?|playing|plays every frame|plays selection only|position|preferred edge|preferred type|pressure|previous text|prompt|properties|prototype cell|pulls down|rate|released when closed|repeated|requested print time|required file type|resizable|resized column|resource path|returns records|reuses columns|rich text|roll over|row height|rulers visible|save panel|scripts path|scrollable|selectable( identifiers)?|selected cell|selected( data)? columns?|selected data items?|selected( data)? rows?|selected item identifier|selection by rect|send action on arrow key|sends action when done editing|separates columns|separator item|sequence number|services menu|shared frameworks path|shared support path|sheet|shift key down|shows alpha|shows state by|size( mode)?|smart insert delete enabled|sort case sensitivity|sort column|sort order|sort type|sorted( data rows)?|sound|source( mask)?|spell checking enabled|starting page|state|string value|sub menu|super menu|super view|tab key traverses cells|tab state|tab type|tab view|table view|tag|target( printer)?|text color|text container insert|text container origin|text returned|tick mark position|time stamp|title(d| (cell|font|height|position|rect))?|tool tip|toolbar|trailing offset|transparent|treat packages as directories|truncated labels|types|unmodified characters|update views|use sort indicator|user defaults|uses data source|uses ruler|uses threaded animation|uses title from previous column|value wraps|version|vertical( (line scroll|page scroll|ruler view))?|vertically resizable|view|visible( document rect)?|volume|width|window|windows menu|wraps|zoomable|zoomed)\b">
<token type="NameAttribute"/>
<rule
pattern="\b(accepts arrow key|action method|active|alignment|allowed identifiers|allows branch selection|allows column reordering|allows column resizing|allows column selection|allows customization|allows editing text attributes|allows empty selection|allows mixed state|allows multiple selection|allows reordering|allows undo|alpha( value)?|alternate image|alternate increment value|alternate title|animation delay|associated file name|associated object|auto completes|auto display|auto enables items|auto repeat|auto resizes( outline column)?|auto save expanded items|auto save name|auto save table columns|auto saves configuration|auto scroll|auto sizes all columns to fit|auto sizes cells|background color|bezel state|bezel style|bezeled|border rect|border type|bordered|bounds( rotation)?|box type|button returned|button type|can choose directories|can choose files|can draw|can hide|cell( (background color|size|type))?|characters|class|click count|clicked( data)? column|clicked data item|clicked( data)? row|closeable|collating|color( (mode|panel))|command key down|configuration|content(s| (size|view( margins)?))?|context|continuous|control key down|control size|control tint|control view|controller visible|coordinate system|copies( on scroll)?|corner view|current cell|current column|current( field)? editor|current( menu)? item|current row|current tab view item|data source|default identifiers|delta (x|y|z)|destination window|directory|display mode|displayed cell|document( (edited|rect|view))?|double value|dragged column|dragged distance|dragged items|draws( cell)? background|draws grid|dynamically scrolls|echos bullets|edge|editable|edited( data)? column|edited data item|edited( data)? row|enabled|enclosing scroll view|ending page|error handling|event number|event type|excluded from windows menu|executable path|expanded|fax number|field editor|file kind|file name|file type|first responder|first visible column|flipped|floating|font( panel)?|formatter|frameworks path|frontmost|gave up|grid color|has data items|has horizontal ruler|has horizontal scroller|has parent data item|has resize indicator|has shadow|has sub menu|has vertical ruler|has vertical scroller|header cell|header view|hidden|hides when deactivated|highlights by|horizontal line scroll|horizontal page scroll|horizontal ruler view|horizontally resizable|icon image|id|identifier|ignores multiple clicks|image( (alignment|dims when disabled|frame style|scaling))?|imports graphics|increment value|indentation per level|indeterminate|index|integer value|intercell spacing|item height|key( (code|equivalent( modifier)?|window))?|knob thickness|label|last( visible)? column|leading offset|leaf|level|line scroll|loaded|localized sort|location|loop mode|main( (bunde|menu|window))?|marker follows cell|matrix mode|maximum( content)? size|maximum visible columns|menu( form representation)?|miniaturizable|miniaturized|minimized image|minimized title|minimum column width|minimum( content)? size|modal|modified|mouse down state|movie( (controller|file|rect))?|muted|name|needs display|next state|next text|number of tick marks|only tick mark values|opaque|open panel|option key down|outline table column|page scroll|pages across|pages down|palette label|pane splitter|parent data item|parent window|pasteboard|path( (names|separator))?|playing|plays every frame|plays selection only|position|preferred edge|preferred type|pressure|previous text|prompt|properties|prototype cell|pulls down|rate|released when closed|repeated|requested print time|required file type|resizable|resized column|resource path|returns records|reuses columns|rich text|roll over|row height|rulers visible|save panel|scripts path|scrollable|selectable( identifiers)?|selected cell|selected( data)? columns?|selected data items?|selected( data)? rows?|selected item identifier|selection by rect|send action on arrow key|sends action when done editing|separates columns|separator item|sequence number|services menu|shared frameworks path|shared support path|sheet|shift key down|shows alpha|shows state by|size( mode)?|smart insert delete enabled|sort case sensitivity|sort column|sort order|sort type|sorted( data rows)?|sound|source( mask)?|spell checking enabled|starting page|state|string value|sub menu|super menu|super view|tab key traverses cells|tab state|tab type|tab view|table view|tag|target( printer)?|text color|text container insert|text container origin|text returned|tick mark position|time stamp|title(d| (cell|font|height|position|rect))?|tool tip|toolbar|trailing offset|transparent|treat packages as directories|truncated labels|types|unmodified characters|update views|use sort indicator|user defaults|uses data source|uses ruler|uses threaded animation|uses title from previous column|value wraps|version|vertical( (line scroll|page scroll|ruler view))?|vertically resizable|view|visible( document rect)?|volume|width|window|windows menu|wraps|zoomable|zoomed)\b"
>
<token type="NameAttribute" />
</rule>
<rule pattern="\b(action cell|alert reply|application|box|browser( cell)?|bundle|button( cell)?|cell|clip view|color well|color-panel|combo box( item)?|control|data( (cell|column|item|row|source))?|default entry|dialog reply|document|drag info|drawer|event|font(-panel)?|formatter|image( (cell|view))?|matrix|menu( item)?|item|movie( view)?|open-panel|outline view|panel|pasteboard|plugin|popup button|progress indicator|responder|save-panel|scroll view|secure text field( cell)?|slider|sound|split view|stepper|tab view( item)?|table( (column|header cell|header view|view))|text( (field( cell)?|view))?|toolbar( item)?|user-defaults|view|window)s?\b">
<token type="NameBuiltin"/>
<rule
pattern="\b(action cell|alert reply|application|box|browser( cell)?|bundle|button( cell)?|cell|clip view|color well|color-panel|combo box( item)?|control|data( (cell|column|item|row|source))?|default entry|dialog reply|document|drag info|drawer|event|font(-panel)?|formatter|image( (cell|view))?|matrix|menu( item)?|item|movie( view)?|open-panel|outline view|panel|pasteboard|plugin|popup button|progress indicator|responder|save-panel|scroll view|secure text field( cell)?|slider|sound|split view|stepper|tab view( item)?|table( (column|header cell|header view|view))|text( (field( cell)?|view))?|toolbar( item)?|user-defaults|view|window)s?\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(animate|append|call method|center|close drawer|close panel|display|display alert|display dialog|display panel|go|hide|highlight|increment|item for|load image|load movie|load nib|load panel|load sound|localized string|lock focus|log|open drawer|path for|pause|perform action|play|register|resume|scroll|select( all)?|show|size to fit|start|step back|step forward|stop|synchronize|unlock focus|update)\b">
<token type="NameBuiltin"/>
<rule
pattern="\b(animate|append|call method|center|close drawer|close panel|display|display alert|display dialog|display panel|go|hide|highlight|increment|item for|load image|load movie|load nib|load panel|load sound|localized string|lock focus|log|open drawer|path for|pause|perform action|play|register|resume|scroll|select( all)?|show|size to fit|start|step back|step forward|stop|synchronize|unlock focus|update)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b((in )?back of|(in )?front of|[0-9]+(st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|after|back|before|behind|every|front|index|last|middle|some|that|through|thru|where|whose)\b">
<token type="NameBuiltin"/>
<rule
pattern="\b((in )?back of|(in )?front of|[0-9]+(st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|after|back|before|behind|every|front|index|last|middle|some|that|through|thru|where|whose)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="\b([a-zA-Z]\w*)\b">
<token type="NameVariable"/>
<token type="NameVariable" />
</rule>
<rule pattern="[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?">
<token type="LiteralNumberFloat"/>
<token type="LiteralNumberFloat" />
</rule>
<rule pattern="[-+]?\d+">
<token type="LiteralNumberInteger"/>
<token type="LiteralNumberInteger" />
</rule>
</state>
<state name="comment">
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push/>
<token type="CommentMultiline" />
<push />
</rule>
<rule pattern="\*\)">
<token type="CommentMultiline"/>
<pop depth="1"/>
<token type="CommentMultiline" />
<pop depth="1" />
</rule>
<rule pattern="[^*(]+">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
<rule pattern="[*(]">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -9,301 +9,314 @@
<rules>
<state name="whitespace">
<rule pattern="^#if\s+0">
<token type="CommentPreproc"/>
<push state="if0"/>
<token type="CommentPreproc" />
<push state="if0" />
</rule>
<rule pattern="^#">
<token type="CommentPreproc"/>
<push state="macro"/>
<token type="CommentPreproc" />
<push state="macro" />
</rule>
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)">
<bygroups>
<usingself state="root"/>
<token type="CommentPreproc"/>
<usingself state="root" />
<token type="CommentPreproc" />
</bygroups>
<push state="if0"/>
<push state="if0" />
</rule>
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#)">
<bygroups>
<usingself state="root"/>
<token type="CommentPreproc"/>
<usingself state="root" />
<token type="CommentPreproc" />
</bygroups>
<push state="macro"/>
<push state="macro" />
</rule>
<rule pattern="\n">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="\\\n">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="//(\n|[\w\W]*?[^\\]\n)">
<token type="CommentSingle"/>
<token type="CommentSingle" />
</rule>
<rule pattern="/(\\\n)?[*][\w\W]*?[*](\\\n)?/">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
<rule pattern="/(\\\n)?[*][\w\W]*">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
</state>
<state name="string">
<rule pattern="&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule pattern="\\([\\abfnrtv&#34;\&#39;]|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})">
<token type="LiteralStringEscape"/>
<token type="LiteralStringEscape" />
</rule>
<rule pattern="[^\\&#34;\n]+">
<token type="LiteralString"/>
<token type="LiteralString" />
</rule>
<rule pattern="\\\n">
<token type="LiteralString"/>
<token type="LiteralString" />
</rule>
<rule pattern="\\">
<token type="LiteralString"/>
<token type="LiteralString" />
</rule>
</state>
<state name="macro">
<rule pattern="(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)">
<bygroups>
<token type="CommentPreproc"/>
<token type="Text"/>
<token type="CommentPreprocFile"/>
<token type="CommentPreproc" />
<token type="Text" />
<token type="CommentPreprocFile" />
</bygroups>
</rule>
<rule pattern="[^/\n]+">
<token type="CommentPreproc"/>
<token type="CommentPreproc" />
</rule>
<rule pattern="/[*](.|\n)*?[*]/">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
<rule pattern="//.*?\n">
<token type="CommentSingle"/>
<pop depth="1"/>
<token type="CommentSingle" />
<pop depth="1" />
</rule>
<rule pattern="/">
<token type="CommentPreproc"/>
<token type="CommentPreproc" />
</rule>
<rule pattern="(?&lt;=\\)\n">
<token type="CommentPreproc"/>
<token type="CommentPreproc" />
</rule>
<rule pattern="\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
<token type="CommentPreproc" />
<pop depth="1" />
</rule>
</state>
<state name="statements">
<rule pattern="(reinterpret_cast|static_assert|dynamic_cast|thread_local|static_cast|const_cast|protected|constexpr|namespace|restrict|noexcept|override|operator|typename|template|explicit|decltype|nullptr|private|alignof|virtual|mutable|alignas|typeid|friend|throws|export|public|delete|final|using|throw|catch|this|try|new)\b">
<token type="Keyword"/>
<rule
pattern="(reinterpret_cast|static_assert|dynamic_cast|thread_local|static_cast|const_cast|protected|constexpr|namespace|restrict|noexcept|override|operator|typename|template|explicit|decltype|nullptr|private|alignof|virtual|mutable|alignas|typeid|friend|throws|export|public|delete|final|using|throw|catch|this|try|new)\b"
>
<token type="Keyword" />
</rule>
<rule pattern="char(16_t|32_t)\b">
<token type="KeywordType"/>
<token type="KeywordType" />
</rule>
<rule pattern="(class)\b">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
<token type="Keyword" />
</bygroups>
<push state="classname"/>
<push state="classname" />
</rule>
<rule pattern="(R)(&#34;)([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralString"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralString"/>
<token type="LiteralStringAffix" />
<token type="LiteralString" />
<token type="LiteralStringDelimiter" />
<token type="LiteralStringDelimiter" />
<token type="LiteralString" />
<token type="LiteralStringDelimiter" />
<token type="LiteralString" />
</bygroups>
</rule>
<rule pattern="(u8|u|U)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
<token type="LiteralStringAffix" />
<token type="LiteralString" />
</bygroups>
<push state="string"/>
<push state="string" />
</rule>
<rule pattern="(L?)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
<token type="LiteralStringAffix" />
<token type="LiteralString" />
</bygroups>
<push state="string"/>
<push state="string" />
</rule>
<rule pattern="(L?)(&#39;)(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\&#39;\n])(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringChar"/>
<token type="LiteralStringChar"/>
<token type="LiteralStringChar"/>
<token type="LiteralStringAffix" />
<token type="LiteralStringChar" />
<token type="LiteralStringChar" />
<token type="LiteralStringChar" />
</bygroups>
</rule>
<rule pattern="(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*">
<token type="LiteralNumberFloat"/>
<token type="LiteralNumberFloat" />
</rule>
<rule pattern="(\d+\.\d*|\.\d+|\d+[fF])[fF]?">
<token type="LiteralNumberFloat"/>
<token type="LiteralNumberFloat" />
</rule>
<rule pattern="0x[0-9a-fA-F]+[LlUu]*">
<token type="LiteralNumberHex"/>
<token type="LiteralNumberHex" />
</rule>
<rule pattern="0[0-7]+[LlUu]*">
<token type="LiteralNumberOct"/>
<token type="LiteralNumberOct" />
</rule>
<rule pattern="\d+[LlUu]*">
<token type="LiteralNumberInteger"/>
<token type="LiteralNumberInteger" />
</rule>
<rule pattern="\*/">
<token type="Error"/>
<token type="Error" />
</rule>
<rule pattern="[~!%^&amp;*+=|?:&lt;&gt;/-]">
<token type="Operator"/>
<token type="Operator" />
</rule>
<rule pattern="[()\[\],.]">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="(restricted|volatile|continue|register|default|typedef|struct|extern|switch|sizeof|static|return|union|while|const|break|goto|enum|else|case|auto|for|asm|if|do)\b">
<token type="Keyword"/>
<rule
pattern="(restricted|volatile|continue|register|default|typedef|struct|extern|switch|sizeof|static|return|union|while|const|break|goto|enum|else|case|auto|for|asm|if|do)\b"
>
<token type="Keyword" />
</rule>
<rule pattern="(_Bool|_Complex|_Imaginary|array|atomic_bool|atomic_char|atomic_int|atomic_llong|atomic_long|atomic_schar|atomic_short|atomic_uchar|atomic_uint|atomic_ullong|atomic_ulong|atomic_ushort|auto|bool|boolean|BooleanVariables|Byte|byte|Char|char|char16_t|char32_t|class|complex|Const|const|const_cast|delete|double|dynamic_cast|enum|explicit|extern|Float|float|friend|inline|Int|int|int16_t|int32_t|int64_t|int8_t|Long|long|new|NULL|null|operator|private|PROGMEM|protected|public|register|reinterpret_cast|short|signed|sizeof|Static|static|static_cast|String|struct|typedef|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|virtual|Void|void|Volatile|volatile|word)\b">
<token type="KeywordType"/>
<rule
pattern="(_Bool|_Complex|_Imaginary|array|atomic_bool|atomic_char|atomic_int|atomic_llong|atomic_long|atomic_schar|atomic_short|atomic_uchar|atomic_uint|atomic_ullong|atomic_ulong|atomic_ushort|auto|bool|boolean|BooleanVariables|Byte|byte|Char|char|char16_t|char32_t|class|complex|Const|const|const_cast|delete|double|dynamic_cast|enum|explicit|extern|Float|float|friend|inline|Int|int|int16_t|int32_t|int64_t|int8_t|Long|long|new|NULL|null|operator|private|PROGMEM|protected|public|register|reinterpret_cast|short|signed|sizeof|Static|static|static_cast|String|struct|typedef|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|virtual|Void|void|Volatile|volatile|word)\b"
>
<token type="KeywordType" />
</rule>
<rule pattern="(and|final|If|Loop|loop|not|or|override|setup|Setup|throw|try|xor)\b">
<token type="Keyword"/>
<token type="Keyword" />
</rule>
<rule pattern="(ANALOG_MESSAGE|BIN|CHANGE|DEC|DEFAULT|DIGITAL_MESSAGE|EXTERNAL|FALLING|FIRMATA_STRING|HALF_PI|HEX|HIGH|INPUT|INPUT_PULLUP|INTERNAL|INTERNAL1V1|INTERNAL1V1|INTERNAL2V56|INTERNAL2V56|LED_BUILTIN|LED_BUILTIN_RX|LED_BUILTIN_TX|LOW|LSBFIRST|MSBFIRST|OCT|OUTPUT|PI|REPORT_ANALOG|REPORT_DIGITAL|RISING|SET_PIN_MODE|SYSEX_START|SYSTEM_RESET|TWO_PI)\b">
<token type="KeywordConstant"/>
<rule
pattern="(ANALOG_MESSAGE|BIN|CHANGE|DEC|DEFAULT|DIGITAL_MESSAGE|EXTERNAL|FALLING|FIRMATA_STRING|HALF_PI|HEX|HIGH|INPUT|INPUT_PULLUP|INTERNAL|INTERNAL1V1|INTERNAL1V1|INTERNAL2V56|INTERNAL2V56|LED_BUILTIN|LED_BUILTIN_RX|LED_BUILTIN_TX|LOW|LSBFIRST|MSBFIRST|OCT|OUTPUT|PI|REPORT_ANALOG|REPORT_DIGITAL|RISING|SET_PIN_MODE|SYSEX_START|SYSTEM_RESET|TWO_PI)\b"
>
<token type="KeywordConstant" />
</rule>
<rule pattern="(boolean|const|byte|word|string|String|array)\b">
<token type="NameVariable"/>
<token type="NameVariable" />
</rule>
<rule pattern="(Keyboard|KeyboardController|MouseController|SoftwareSerial|EthernetServer|EthernetClient|LiquidCrystal|RobotControl|GSMVoiceCall|EthernetUDP|EsploraTFT|HttpClient|RobotMotor|WiFiClient|GSMScanner|FileSystem|Scheduler|GSMServer|YunClient|YunServer|IPAddress|GSMClient|GSMModem|Keyboard|Ethernet|Console|GSMBand|Esplora|Stepper|Process|WiFiUDP|GSM_SMS|Mailbox|USBHost|Firmata|PImage|Client|Server|GSMPIN|FileIO|Bridge|Serial|EEPROM|Stream|Mouse|Audio|Servo|File|Task|GPRS|WiFi|Wire|TFT|GSM|SPI|SD)\b">
<token type="NameClass"/>
<rule
pattern="(Keyboard|KeyboardController|MouseController|SoftwareSerial|EthernetServer|EthernetClient|LiquidCrystal|RobotControl|GSMVoiceCall|EthernetUDP|EsploraTFT|HttpClient|RobotMotor|WiFiClient|GSMScanner|FileSystem|Scheduler|GSMServer|YunClient|YunServer|IPAddress|GSMClient|GSMModem|Keyboard|Ethernet|Console|GSMBand|Esplora|Stepper|Process|WiFiUDP|GSM_SMS|Mailbox|USBHost|Firmata|PImage|Client|Server|GSMPIN|FileIO|Bridge|Serial|EEPROM|Stream|Mouse|Audio|Servo|File|Task|GPRS|WiFi|Wire|TFT|GSM|SPI|SD)\b"
>
<token type="NameClass" />
</rule>
<rule pattern="(abs|Abs|accept|ACos|acos|acosf|addParameter|analogRead|AnalogRead|analogReadResolution|AnalogReadResolution|analogReference|AnalogReference|analogWrite|AnalogWrite|analogWriteResolution|AnalogWriteResolution|answerCall|asin|ASin|asinf|atan|ATan|atan2|ATan2|atan2f|atanf|attach|attached|attachGPRS|attachInterrupt|AttachInterrupt|autoscroll|available|availableForWrite|background|beep|begin|beginPacket|beginSD|beginSMS|beginSpeaker|beginTFT|beginTransmission|beginWrite|bit|Bit|BitClear|bitClear|bitRead|BitRead|bitSet|BitSet|BitWrite|bitWrite|blink|blinkVersion|BSSID|buffer|byte|cbrt|cbrtf|Ceil|ceil|ceilf|changePIN|char|charAt|checkPIN|checkPUK|checkReg|circle|cityNameRead|cityNameWrite|clear|clearScreen|click|close|compareTo|compassRead|concat|config|connect|connected|constrain|Constrain|copysign|copysignf|cos|Cos|cosf|cosh|coshf|countryNameRead|countryNameWrite|createChar|cursor|debugPrint|degrees|Delay|delay|DelayMicroseconds|delayMicroseconds|detach|DetachInterrupt|detachInterrupt|DigitalPinToInterrupt|digitalPinToInterrupt|DigitalRead|digitalRead|DigitalWrite|digitalWrite|disconnect|display|displayLogos|drawBMP|drawCompass|encryptionType|end|endPacket|endSMS|endsWith|endTransmission|endWrite|equals|equalsIgnoreCase|exists|exitValue|Exp|exp|expf|fabs|fabsf|fdim|fdimf|fill|find|findUntil|float|floor|Floor|floorf|flush|fma|fmaf|fmax|fmaxf|fmin|fminf|fmod|fmodf|gatewayIP|get|getAsynchronously|getBand|getButton|getBytes|getCurrentCarrier|getIMEI|getKey|getModifiers|getOemKey|getPINUsed|getResult|getSignalStrength|getSocket|getVoiceCallStatus|getXChange|getYChange|hangCall|height|highByte|HighByte|home|hypot|hypotf|image|indexOf|int|interrupts|IPAddress|IRread|isActionDone|isAlpha|isAlphaNumeric|isAscii|isControl|isDigit|isDirectory|isfinite|isGraph|isHexadecimalDigit|isinf|isListening|isLowerCase|isnan|isPIN|isPressed|isPrintable|isPunct|isSpace|isUpperCase|isValid|isWhitespace|keyboardRead|keyPressed|keyReleased|knobRead|lastIndexOf|ldexp|ldexpf|leftToRight|length|line|lineFollowConfig|listen|listenOnLocalhost|loadImage|localIP|log|Log|log10|log10f|logf|long|lowByte|LowByte|lrint|lrintf|lround|lroundf|macAddress|maintain|map|Map|Max|max|messageAvailable|Micros|micros|millis|Millis|Min|min|mkdir|motorsStop|motorsWrite|mouseDragged|mouseMoved|mousePressed|mouseReleased|move|noAutoscroll|noBlink|noBuffer|noCursor|noDisplay|noFill|noInterrupts|NoInterrupts|noListenOnLocalhost|noStroke|noTone|NoTone|onReceive|onRequest|open|openNextFile|overflow|parseCommand|parseFloat|parseInt|parsePacket|pauseMode|peek|PinMode|pinMode|playFile|playMelody|point|pointTo|position|Pow|pow|powf|prepare|press|print|printFirmwareVersion|println|printVersion|process|processInput|PulseIn|pulseIn|pulseInLong|PulseInLong|put|radians|random|Random|randomSeed|RandomSeed|read|readAccelerometer|readBlue|readButton|readBytes|readBytesUntil|readGreen|readJoystickButton|readJoystickSwitch|readJoystickX|readJoystickY|readLightSensor|readMessage|readMicrophone|readNetworks|readRed|readSlider|readString|readStringUntil|readTemperature|ready|rect|release|releaseAll|remoteIP|remoteNumber|remotePort|remove|replace|requestFrom|retrieveCallingNumber|rewindDirectory|rightToLeft|rmdir|robotNameRead|robotNameWrite|round|roundf|RSSI|run|runAsynchronously|running|runShellCommand|runShellCommandAsynchronously|scanNetworks|scrollDisplayLeft|scrollDisplayRight|seek|sendAnalog|sendDigitalPortPair|sendDigitalPorts|sendString|sendSysex|Serial_Available|Serial_Begin|Serial_End|Serial_Flush|Serial_Peek|Serial_Print|Serial_Println|Serial_Read|serialEvent|setBand|setBitOrder|setCharAt|setClockDivider|setCursor|setDataMode|setDNS|setFirmwareVersion|setMode|setPINUsed|setSpeed|setTextSize|setTimeout|ShiftIn|shiftIn|ShiftOut|shiftOut|shutdown|signbit|sin|Sin|sinf|sinh|sinhf|size|sizeof|Sq|sq|Sqrt|sqrt|sqrtf|SSID|startLoop|startsWith|step|stop|stroke|subnetMask|substring|switchPIN|tan|Tan|tanf|tanh|tanhf|tempoWrite|text|toCharArray|toInt|toLowerCase|tone|Tone|toUpperCase|transfer|trim|trunc|truncf|tuneWrite|turn|updateIR|userNameRead|userNameWrite|voiceCall|waitContinue|width|WiFiServer|word|write|writeBlue|writeGreen|writeJSON|writeMessage|writeMicroseconds|writeRed|writeRGB|yield|Yield)\b">
<token type="NameFunction"/>
<rule
pattern="(abs|Abs|accept|ACos|acos|acosf|addParameter|analogRead|AnalogRead|analogReadResolution|AnalogReadResolution|analogReference|AnalogReference|analogWrite|AnalogWrite|analogWriteResolution|AnalogWriteResolution|answerCall|asin|ASin|asinf|atan|ATan|atan2|ATan2|atan2f|atanf|attach|attached|attachGPRS|attachInterrupt|AttachInterrupt|autoscroll|available|availableForWrite|background|beep|begin|beginPacket|beginSD|beginSMS|beginSpeaker|beginTFT|beginTransmission|beginWrite|bit|Bit|BitClear|bitClear|bitRead|BitRead|bitSet|BitSet|BitWrite|bitWrite|blink|blinkVersion|BSSID|buffer|byte|cbrt|cbrtf|Ceil|ceil|ceilf|changePIN|char|charAt|checkPIN|checkPUK|checkReg|circle|cityNameRead|cityNameWrite|clear|clearScreen|click|close|compareTo|compassRead|concat|config|connect|connected|constrain|Constrain|copysign|copysignf|cos|Cos|cosf|cosh|coshf|countryNameRead|countryNameWrite|createChar|cursor|debugPrint|degrees|Delay|delay|DelayMicroseconds|delayMicroseconds|detach|DetachInterrupt|detachInterrupt|DigitalPinToInterrupt|digitalPinToInterrupt|DigitalRead|digitalRead|DigitalWrite|digitalWrite|disconnect|display|displayLogos|drawBMP|drawCompass|encryptionType|end|endPacket|endSMS|endsWith|endTransmission|endWrite|equals|equalsIgnoreCase|exists|exitValue|Exp|exp|expf|fabs|fabsf|fdim|fdimf|fill|find|findUntil|float|floor|Floor|floorf|flush|fma|fmaf|fmax|fmaxf|fmin|fminf|fmod|fmodf|gatewayIP|get|getAsynchronously|getBand|getButton|getBytes|getCurrentCarrier|getIMEI|getKey|getModifiers|getOemKey|getPINUsed|getResult|getSignalStrength|getSocket|getVoiceCallStatus|getXChange|getYChange|hangCall|height|highByte|HighByte|home|hypot|hypotf|image|indexOf|int|interrupts|IPAddress|IRread|isActionDone|isAlpha|isAlphaNumeric|isAscii|isControl|isDigit|isDirectory|isfinite|isGraph|isHexadecimalDigit|isinf|isListening|isLowerCase|isnan|isPIN|isPressed|isPrintable|isPunct|isSpace|isUpperCase|isValid|isWhitespace|keyboardRead|keyPressed|keyReleased|knobRead|lastIndexOf|ldexp|ldexpf|leftToRight|length|line|lineFollowConfig|listen|listenOnLocalhost|loadImage|localIP|log|Log|log10|log10f|logf|long|lowByte|LowByte|lrint|lrintf|lround|lroundf|macAddress|maintain|map|Map|Max|max|messageAvailable|Micros|micros|millis|Millis|Min|min|mkdir|motorsStop|motorsWrite|mouseDragged|mouseMoved|mousePressed|mouseReleased|move|noAutoscroll|noBlink|noBuffer|noCursor|noDisplay|noFill|noInterrupts|NoInterrupts|noListenOnLocalhost|noStroke|noTone|NoTone|onReceive|onRequest|open|openNextFile|overflow|parseCommand|parseFloat|parseInt|parsePacket|pauseMode|peek|PinMode|pinMode|playFile|playMelody|point|pointTo|position|Pow|pow|powf|prepare|press|print|printFirmwareVersion|println|printVersion|process|processInput|PulseIn|pulseIn|pulseInLong|PulseInLong|put|radians|random|Random|randomSeed|RandomSeed|read|readAccelerometer|readBlue|readButton|readBytes|readBytesUntil|readGreen|readJoystickButton|readJoystickSwitch|readJoystickX|readJoystickY|readLightSensor|readMessage|readMicrophone|readNetworks|readRed|readSlider|readString|readStringUntil|readTemperature|ready|rect|release|releaseAll|remoteIP|remoteNumber|remotePort|remove|replace|requestFrom|retrieveCallingNumber|rewindDirectory|rightToLeft|rmdir|robotNameRead|robotNameWrite|round|roundf|RSSI|run|runAsynchronously|running|runShellCommand|runShellCommandAsynchronously|scanNetworks|scrollDisplayLeft|scrollDisplayRight|seek|sendAnalog|sendDigitalPortPair|sendDigitalPorts|sendString|sendSysex|Serial_Available|Serial_Begin|Serial_End|Serial_Flush|Serial_Peek|Serial_Print|Serial_Println|Serial_Read|serialEvent|setBand|setBitOrder|setCharAt|setClockDivider|setCursor|setDataMode|setDNS|setFirmwareVersion|setMode|setPINUsed|setSpeed|setTextSize|setTimeout|ShiftIn|shiftIn|ShiftOut|shiftOut|shutdown|signbit|sin|Sin|sinf|sinh|sinhf|size|sizeof|Sq|sq|Sqrt|sqrt|sqrtf|SSID|startLoop|startsWith|step|stop|stroke|subnetMask|substring|switchPIN|tan|Tan|tanf|tanh|tanhf|tempoWrite|text|toCharArray|toInt|toLowerCase|tone|Tone|toUpperCase|transfer|trim|trunc|truncf|tuneWrite|turn|updateIR|userNameRead|userNameWrite|voiceCall|waitContinue|width|WiFiServer|word|write|writeBlue|writeGreen|writeJSON|writeMessage|writeMicroseconds|writeRed|writeRGB|yield|Yield)\b"
>
<token type="NameFunction" />
</rule>
<rule pattern="(typename|__inline|restrict|_inline|thread|inline|naked)\b">
<token type="KeywordReserved"/>
<token type="KeywordReserved" />
</rule>
<rule pattern="(__m(128i|128d|128|64))\b">
<token type="KeywordReserved"/>
<token type="KeywordReserved" />
</rule>
<rule pattern="__(forceinline|identifier|unaligned|declspec|fastcall|finally|stdcall|wchar_t|assume|except|int32|cdecl|int16|leave|based|raise|int64|noop|int8|w64|try|asm)\b">
<token type="KeywordReserved"/>
<rule
pattern="__(forceinline|identifier|unaligned|declspec|fastcall|finally|stdcall|wchar_t|assume|except|int32|cdecl|int16|leave|based|raise|int64|noop|int8|w64|try|asm)\b"
>
<token type="KeywordReserved" />
</rule>
<rule pattern="(true|false|NULL)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="([a-zA-Z_]\w*)(\s*)(:)(?!:)">
<bygroups>
<token type="NameLabel"/>
<token type="Text"/>
<token type="Punctuation"/>
<token type="NameLabel" />
<token type="Text" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule pattern="[a-zA-Z_]\w*">
<token type="Name"/>
<token type="Name" />
</rule>
</state>
<state name="function">
<rule>
<include state="whitespace"/>
<include state="whitespace" />
</rule>
<rule>
<include state="statements"/>
<include state="statements" />
</rule>
<rule pattern=";">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="\{">
<token type="Punctuation"/>
<push/>
<token type="Punctuation" />
<push />
</rule>
<rule pattern="\}">
<token type="Punctuation"/>
<pop depth="1"/>
<token type="Punctuation" />
<pop depth="1" />
</rule>
</state>
<state name="if0">
<rule pattern="^\s*#if.*?(?&lt;!\\)\n">
<token type="CommentPreproc"/>
<push/>
<token type="CommentPreproc" />
<push />
</rule>
<rule pattern="^\s*#el(?:se|if).*\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
<token type="CommentPreproc" />
<pop depth="1" />
</rule>
<rule pattern="^\s*#endif.*?(?&lt;!\\)\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
<token type="CommentPreproc" />
<pop depth="1" />
</rule>
<rule pattern=".*?\n">
<token type="Comment"/>
<token type="Comment" />
</rule>
</state>
<state name="classname">
<rule pattern="[a-zA-Z_]\w*">
<token type="NameClass"/>
<pop depth="1"/>
<token type="NameClass" />
<pop depth="1" />
</rule>
<rule pattern="\s*(?=&gt;)">
<token type="Text"/>
<pop depth="1"/>
<token type="Text" />
<pop depth="1" />
</rule>
</state>
<state name="statement">
<rule>
<include state="whitespace"/>
<include state="whitespace" />
</rule>
<rule>
<include state="statements"/>
<include state="statements" />
</rule>
<rule pattern="[{}]">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern=";">
<token type="Punctuation"/>
<pop depth="1"/>
<token type="Punctuation" />
<pop depth="1" />
</rule>
</state>
<state name="root">
<rule>
<include state="whitespace"/>
<include state="whitespace" />
</rule>
<rule pattern="((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)">
<bygroups>
<usingself state="root"/>
<token type="NameFunction"/>
<usingself state="root"/>
<usingself state="root"/>
<token type="Punctuation"/>
<usingself state="root" />
<token type="NameFunction" />
<usingself state="root" />
<usingself state="root" />
<token type="Punctuation" />
</bygroups>
<push state="function"/>
<push state="function" />
</rule>
<rule pattern="((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)">
<bygroups>
<usingself state="root"/>
<token type="NameFunction"/>
<usingself state="root"/>
<usingself state="root"/>
<token type="Punctuation"/>
<usingself state="root" />
<token type="NameFunction" />
<usingself state="root" />
<usingself state="root" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule>
<push state="statement"/>
<push state="statement" />
</rule>
<rule pattern="__(multiple_inheritance|virtual_inheritance|single_inheritance|interface|uuidof|super|event)\b">
<token type="KeywordReserved"/>
<token type="KeywordReserved" />
</rule>
<rule pattern="__(offload|blockingoffload|outer)\b">
<token type="KeywordPseudo"/>
<token type="KeywordPseudo" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -11,116 +11,116 @@
<rules>
<state name="root">
<rule>
<include state="commentsandwhitespace"/>
<include state="commentsandwhitespace" />
</rule>
<rule pattern="(\.\w+)([ \t]+\w+\s+?)?">
<bygroups>
<token type="KeywordNamespace"/>
<token type="NameLabel"/>
<token type="KeywordNamespace" />
<token type="NameLabel" />
</bygroups>
</rule>
<rule pattern="(\w+)(:)(\s+\.\w+\s+)">
<bygroups>
<token type="NameLabel"/>
<token type="Punctuation"/>
<token type="KeywordNamespace"/>
<token type="NameLabel" />
<token type="Punctuation" />
<token type="KeywordNamespace" />
</bygroups>
<push state="literal"/>
<push state="literal" />
</rule>
<rule pattern="(\w+)(:)">
<bygroups>
<token type="NameLabel"/>
<token type="Punctuation"/>
<token type="NameLabel" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule pattern="svc\s+\w+">
<token type="NameNamespace"/>
<token type="NameNamespace" />
</rule>
<rule pattern="[a-zA-Z]+">
<token type="Text"/>
<push state="opcode"/>
<token type="Text" />
<push state="opcode" />
</rule>
</state>
<state name="commentsandwhitespace">
<rule pattern="\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="[@;].*?\n">
<token type="CommentSingle"/>
<token type="CommentSingle" />
</rule>
<rule pattern="/\*.*?\*/">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
</state>
<state name="literal">
<rule pattern="0b[01]+">
<token type="LiteralNumberBin"/>
<pop depth="1"/>
<token type="LiteralNumberBin" />
<pop depth="1" />
</rule>
<rule pattern="0x\w{1,8}">
<token type="LiteralNumberHex"/>
<pop depth="1"/>
<token type="LiteralNumberHex" />
<pop depth="1" />
</rule>
<rule pattern="0\d+">
<token type="LiteralNumberOct"/>
<pop depth="1"/>
<token type="LiteralNumberOct" />
<pop depth="1" />
</rule>
<rule pattern="\d+?\.\d+?">
<token type="LiteralNumberFloat"/>
<pop depth="1"/>
<token type="LiteralNumberFloat" />
<pop depth="1" />
</rule>
<rule pattern="\d+">
<token type="LiteralNumberInteger"/>
<pop depth="1"/>
<token type="LiteralNumberInteger" />
<pop depth="1" />
</rule>
<rule pattern="(&#34;)(.+)(&#34;)">
<bygroups>
<token type="Punctuation"/>
<token type="LiteralStringDouble"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="LiteralStringDouble" />
<token type="Punctuation" />
</bygroups>
<pop depth="1"/>
<pop depth="1" />
</rule>
<rule pattern="(&#39;)(.{1}|\\.{1})(&#39;)">
<bygroups>
<token type="Punctuation"/>
<token type="LiteralStringChar"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="LiteralStringChar" />
<token type="Punctuation" />
</bygroups>
<pop depth="1"/>
<pop depth="1" />
</rule>
</state>
<state name="opcode">
<rule pattern="\n">
<token type="Text"/>
<pop depth="1"/>
<token type="Text" />
<pop depth="1" />
</rule>
<rule pattern="(@|;).*\n">
<token type="CommentSingle"/>
<pop depth="1"/>
<token type="CommentSingle" />
<pop depth="1" />
</rule>
<rule pattern="(\s+|,)">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="[rapcfxwbhsdqv]\d{1,2}">
<token type="NameClass"/>
<token type="NameClass" />
</rule>
<rule pattern="=0x\w+">
<rule pattern="(=)(0x\w+)">
<bygroups>
<token type="Text"/>
<token type="NameLabel"/>
<token type="Text" />
<token type="NameLabel" />
</bygroups>
</rule>
<rule pattern="(=)(\w+)">
<bygroups>
<token type="Text"/>
<token type="NameLabel"/>
<token type="Text" />
<token type="NameLabel" />
</bygroups>
</rule>
<rule pattern="#">
<token type="Text"/>
<push state="literal"/>
<token type="Text" />
<push state="literal" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -13,45 +13,45 @@
<rules>
<state name="root">
<rule pattern="#.*">
<token type="Comment"/>
<token type="Comment" />
</rule>
<rule pattern="(ONBUILD)((?:\s*\\?\s*))">
<bygroups>
<token type="Keyword"/>
<using lexer="Bash"/>
<token type="Keyword" />
<using lexer="Bash" />
</bygroups>
</rule>
<rule pattern="(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)">
<rule pattern="(HEALTHCHECK)((?:(?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)">
<bygroups>
<token type="Keyword"/>
<using lexer="Bash"/>
<token type="Keyword" />
<using lexer="Bash" />
</bygroups>
</rule>
<rule pattern="(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])">
<bygroups>
<token type="Keyword"/>
<using lexer="Bash"/>
<using lexer="JSON"/>
<token type="Keyword" />
<using lexer="Bash" />
<using lexer="JSON" />
</bygroups>
</rule>
<rule pattern="(LABEL|ENV|ARG)((?:(?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)">
<bygroups>
<token type="Keyword"/>
<using lexer="Bash"/>
<token type="Keyword" />
<using lexer="Bash" />
</bygroups>
</rule>
<rule pattern="((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)">
<bygroups>
<token type="Keyword"/>
<token type="LiteralString"/>
<token type="Keyword" />
<token type="LiteralString" />
</bygroups>
</rule>
<rule pattern="((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))">
<token type="Keyword"/>
<token type="Keyword" />
</rule>
<rule pattern="(.*\\\n)*.+">
<using lexer="Bash"/>
<using lexer="Bash" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -7,143 +7,125 @@
<rules>
<state name="root">
<rule pattern="(#.*)">
<bygroups>
<token type="CommentSingle"/>
</bygroups>
<token type="CommentSingle" />
</rule>
<rule pattern="((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))">
<bygroups>
<token type="LiteralNumber"/>
</bygroups>
<token type="LiteralNumber" />
</rule>
<rule pattern="((\b(true|false)\b))">
<bygroups>
<token type="NameBuiltin"/>
</bygroups>
<token type="NameBuiltin" />
</rule>
<rule pattern="(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)">
<bygroups>
<token type="KeywordType"/>
</bygroups>
<token type="KeywordType" />
</rule>
<rule pattern="(\b[a-zA-Z_][a-zA-Z0-9]*\b)(\()">
<bygroups>
<token type="NameFunction"/>
<token type="Punctuation"/>
<token type="NameFunction" />
<token type="Punctuation" />
</bygroups>
<push state="params"/>
<push state="params" />
</rule>
<rule pattern="(\{)">
<bygroups>
<token type="Punctuation"/>
</bygroups>
<push state="block"/>
<token type="Punctuation" />
<push state="block" />
</rule>
<rule pattern="(\n|\r|\r\n)">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern=".">
<token type="Text"/>
<token type="Text" />
</rule>
</state>
<state name="string">
<rule pattern="&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule pattern="\\&#34;">
<token type="LiteralString"/>
<token type="LiteralString" />
</rule>
<rule pattern="[^\\&#34;]+">
<token type="LiteralString"/>
<token type="LiteralString" />
</rule>
</state>
<state name="block">
<rule pattern="(\})">
<bygroups>
<token type="Punctuation"/>
</bygroups>
<pop depth="1"/>
<token type="Punctuation" />
<pop depth="1" />
</rule>
<rule pattern="(#.*)">
<bygroups>
<token type="CommentSingle"/>
</bygroups>
<token type="CommentSingle" />
</rule>
<rule pattern="((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))">
<bygroups>
<token type="LiteralNumber"/>
</bygroups>
<token type="LiteralNumber" />
</rule>
<rule pattern="((\b(true|false)\b))">
<bygroups>
<token type="KeywordConstant"/>
</bygroups>
<token type="KeywordConstant" />
</rule>
<rule pattern="&#34;">
<token type="LiteralString"/>
<push state="string"/>
<token type="LiteralString" />
<push state="string" />
</rule>
<rule pattern="(with)">
<bygroups>
<token type="KeywordReserved"/>
</bygroups>
<token type="KeywordReserved" />
</rule>
<rule pattern="(as)([\t ]+)(\b[a-zA-Z_][a-zA-Z0-9]*\b)">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="NameFunction"/>
<token type="KeywordReserved" />
<token type="Text" />
<token type="NameFunction" />
</bygroups>
</rule>
<rule pattern="(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)([\t ]+)(\{)">
<bygroups>
<token type="KeywordType"/>
<token type="Text"/>
<token type="Punctuation"/>
<token type="KeywordType" />
<token type="Text" />
<token type="Punctuation" />
</bygroups>
<push state="block"/>
<push state="block" />
</rule>
<rule pattern="(?!\b(?:scratch|image|resolve|http|checksum|chmod|filename|git|keepGitDir|local|includePatterns|excludePatterns|followPaths|generate|frontendInput|shell|run|readonlyRootfs|env|dir|user|network|security|host|ssh|secret|mount|target|localPath|uid|gid|mode|readonly|tmpfs|sourcePath|cache|mkdir|createParents|chown|createdTime|mkfile|rm|allowNotFound|allowWildcards|copy|followSymlinks|contentsOnly|unpack|createDestPath)\b)(\b[a-zA-Z_][a-zA-Z0-9]*\b)">
<rule
pattern="(?!\b(?:scratch|image|resolve|http|checksum|chmod|filename|git|keepGitDir|local|includePatterns|excludePatterns|followPaths|generate|frontendInput|shell|run|readonlyRootfs|env|dir|user|network|security|host|ssh|secret|mount|target|localPath|uid|gid|mode|readonly|tmpfs|sourcePath|cache|mkdir|createParents|chown|createdTime|mkfile|rm|allowNotFound|allowWildcards|copy|followSymlinks|contentsOnly|unpack|createDestPath)\b)(\b[a-zA-Z_][a-zA-Z0-9]*\b)"
>
<bygroups>
<token type="NameOther"/>
<token type="NameOther" />
</bygroups>
</rule>
<rule pattern="(\n|\r|\r\n)">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern=".">
<token type="Text"/>
<token type="Text" />
</rule>
</state>
<state name="params">
<rule pattern="(\))">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation" />
</bygroups>
<pop depth="1"/>
<pop depth="1" />
</rule>
<rule pattern="(variadic)">
<bygroups>
<token type="Keyword"/>
<token type="Keyword" />
</bygroups>
</rule>
<rule pattern="(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)">
<bygroups>
<token type="KeywordType"/>
<token type="KeywordType" />
</bygroups>
</rule>
<rule pattern="(\b[a-zA-Z_][a-zA-Z0-9]*\b)">
<bygroups>
<token type="NameOther"/>
<token type="NameOther" />
</bygroups>
</rule>
<rule pattern="(\n|\r|\r\n)">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern=".">
<token type="Text"/>
<token type="Text" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -1,3 +1,4 @@
<?xml version="1.0" ?>
<lexer>
<config>
<name>Sed</name>
@@ -10,19 +11,82 @@
</config>
<rules>
<state name="root">
<rule pattern="\s+"><token type="TextWhitespace"/></rule>
<rule pattern="#.*$"><token type="CommentSingle"/></rule>
<rule pattern="[0-9]+"><token type="LiteralNumberInteger"/></rule>
<rule pattern="\$"><token type="Operator"/></rule>
<rule pattern="[{};,!]"><token type="Punctuation"/></rule>
<rule pattern="[dDFgGhHlnNpPqQxz=]"><token type="Keyword"/></rule>
<rule pattern="([berRtTvwW:])([^;\n]*)"><bygroups><token type="Keyword"/><token type="LiteralStringSingle"/></bygroups></rule>
<rule pattern="([aci])((?:.*?\\\n)*(?:.*?[^\\]$))"><bygroups><token type="Keyword"/><token type="LiteralStringDouble"/></bygroups></rule>
<rule pattern="([qQ])([0-9]*)"><bygroups><token type="Keyword"/><token type="LiteralNumberInteger"/></bygroups></rule>
<rule pattern="(/)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(/)"><bygroups><token type="Punctuation"/><token type="LiteralStringRegex"/><token type="Punctuation"/></bygroups></rule>
<rule pattern="(\\(.))((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)"><bygroups><token type="Punctuation"/>None<token type="LiteralStringRegex"/><token type="Punctuation"/></bygroups></rule>
<rule pattern="(y)(.)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)"><bygroups><token type="Keyword"/><token type="Punctuation"/><token type="LiteralStringSingle"/><token type="Punctuation"/><token type="LiteralStringSingle"/><token type="Punctuation"/></bygroups></rule>
<rule pattern="(s)(.)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:[gpeIiMm]|[0-9])*)"><bygroups><token type="Keyword"/><token type="Punctuation"/><token type="LiteralStringRegex"/><token type="Punctuation"/><token type="LiteralStringSingle"/><token type="Punctuation"/><token type="Keyword"/></bygroups></rule>
<rule pattern="\s+">
<token type="TextWhitespace" />
</rule>
<rule pattern="#.*$">
<token type="CommentSingle" />
</rule>
<rule pattern="[0-9]+">
<token type="LiteralNumberInteger" />
</rule>
<rule pattern="\$">
<token type="Operator" />
</rule>
<rule pattern="[{};,!]">
<token type="Punctuation" />
</rule>
<rule pattern="[dDFgGhHlnNpPqQxz=]">
<token type="Keyword" />
</rule>
<rule pattern="([berRtTvwW:])([^;\n]*)">
<bygroups>
<token type="Keyword" />
<token type="LiteralStringSingle" />
</bygroups>
</rule>
<rule pattern="([aci])((?:.*?\\\n)*(?:.*?[^\\]$))">
<bygroups>
<token type="Keyword" />
<token type="LiteralStringDouble" />
</bygroups>
</rule>
<rule pattern="([qQ])([0-9]*)">
<bygroups>
<token type="Keyword" />
<token type="LiteralNumberInteger" />
</bygroups>
</rule>
<rule pattern="(/)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(/)">
<bygroups>
<token type="Punctuation" />
<token type="LiteralStringRegex" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule pattern="(\\(.))((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)">
<bygroups>
<token type="Punctuation" />
<token type="Text" />
<token type="LiteralStringRegex" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule
pattern="(y)(.)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)"
>
<bygroups>
<token type="Keyword" />
<token type="Punctuation" />
<token type="LiteralStringSingle" />
<token type="Punctuation" />
<token type="LiteralStringSingle" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule
pattern="(s)(.)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)(\2)((?:[gpeIiMm]|[0-9])*)"
>
<bygroups>
<token type="Keyword" />
<token type="Punctuation" />
<token type="LiteralStringRegex" />
<token type="Punctuation" />
<token type="LiteralStringSingle" />
<token type="Punctuation" />
<token type="Keyword" />
</bygroups>
</rule>
</state>
</rules>
</lexer>

View File

@@ -12,131 +12,138 @@
<rules>
<state name="string">
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
<token type="LiteralStringDouble" />
<pop depth="1" />
</rule>
<rule pattern="\\\\&#34;">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="[^&#34;\\\\$]+">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="[^\\\\&#34;$]+">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="\$\{">
<token type="LiteralStringInterpol"/>
<push state="interp-inside"/>
<token type="LiteralStringInterpol" />
<push state="interp-inside" />
</rule>
</state>
<state name="interp-inside">
<rule pattern="\}">
<token type="LiteralStringInterpol"/>
<pop depth="1"/>
<token type="LiteralStringInterpol" />
<pop depth="1" />
</rule>
<rule>
<include state="root"/>
<include state="root" />
</rule>
</state>
<state name="root">
<rule pattern="[\[\](),.{}]">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<push state="string"/>
<token type="LiteralStringDouble" />
<push state="string" />
</rule>
<rule pattern="-?[0-9]+">
<token type="LiteralNumber"/>
<token type="LiteralNumber" />
</rule>
<rule pattern="=&gt;">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="(false|true)\b">
<token type="KeywordConstant"/>
<token type="KeywordConstant" />
</rule>
<rule pattern="/(?s)\*(((?!\*/).)*)\*/">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
<rule pattern="\s*(#|//).*\n">
<token type="CommentSingle"/>
<token type="CommentSingle" />
</rule>
<rule pattern="(?!\s*)(variable)(\s*)">
<bygroups>
<token type="Name"/>
<token type="Text"/>
<token type="Text"/>
<token type="Name" />
<token type="Text" />
</bygroups>
</rule>
<rule pattern="^(provisioner|variable|resource|provider|module|output|data)(?!\.)\b">
<token type="KeywordReserved"/>
<token type="KeywordReserved" />
</rule>
<rule pattern="(for|in)\b">
<token type="Keyword"/>
<token type="Keyword" />
</rule>
<rule pattern="(module|count|data|each|var)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(parseint|signum|floor|ceil|log|max|min|abs|pow)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(trimsuffix|formatlist|trimprefix|trimspace|regexall|replace|indent|strrev|format|substr|chomp|split|title|regex|lower|upper|trim|join)\b">
<token type="NameBuiltin"/>
<rule
pattern="(trimsuffix|formatlist|trimprefix|trimspace|regexall|replace|indent|strrev|format|substr|chomp|split|title|regex|lower|upper|trim|join)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="[^.](setintersection|coalescelist|setsubtract|setproduct|matchkeys|chunklist|transpose|contains|distinct|coalesce|setunion|reverse|flatten|element|compact|lookup|length|concat|values|zipmap|range|merge|slice|index|list|sort|keys|map)\b">
<token type="NameBuiltin"/>
<rule
pattern="[^.](setintersection|coalescelist|setsubtract|setproduct|matchkeys|chunklist|transpose|contains|distinct|coalesce|setunion|reverse|flatten|element|compact|lookup|length|concat|values|zipmap|range|merge|slice|index|list|sort|keys|map)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="[^.](base64decode|base64encode|base64gzip|jsondecode|jsonencode|yamldecode|yamlencode|csvdecode|urlencode)\b">
<token type="NameBuiltin"/>
<rule
pattern="[^.](base64decode|base64encode|base64gzip|jsondecode|jsonencode|yamldecode|yamlencode|csvdecode|urlencode)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="(templatefile|filebase64|fileexists|pathexpand|basename|abspath|fileset|dirname|file)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(formatdate|timestamp|timeadd)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(filebase64sha256|filebase64sha512|base64sha512|base64sha256|filesha256|rsadecrypt|filesha512|filesha1|filemd5|uuidv5|bcrypt|sha256|sha512|sha1|uuid|md5)\b">
<token type="NameBuiltin"/>
<rule
pattern="(filebase64sha256|filebase64sha512|base64sha512|base64sha256|filesha256|rsadecrypt|filesha512|filesha1|filemd5|uuidv5|bcrypt|sha256|sha512|sha1|uuid|md5)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="(cidrnetmask|cidrsubnet|cidrhost)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(tostring|tonumber|tobool|tolist|tomap|toset|can|try)\b">
<token type="NameBuiltin"/>
<token type="NameBuiltin" />
</rule>
<rule pattern="(^|[^.\w])(name|x|default|type|description|value)(_[a-zA-Z]\w*)*">
<token type="NameAttribute"/>
<token type="NameAttribute" />
</rule>
<rule pattern="=(?!&gt;)|\+|-|\*|\/|:|!|%|&gt;|&lt;(?!&lt;)|&gt;=|&lt;=|==|!=|&amp;&amp;|\||\?">
<token type="Operator"/>
<token type="Operator" />
</rule>
<rule pattern="\n|\s+|\\\n">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="[a-zA-Z]\w*">
<token type="NameOther"/>
<token type="NameOther" />
</rule>
<rule pattern="(?s)(&lt;&lt;-?)(\w+)(\n\s*(?:(?!\2).)*\s*\n\s*)(\2)">
<bygroups>
<token type="Operator"/>
<token type="Operator"/>
<token type="LiteralString"/>
<token type="Operator"/>
<token type="Operator" />
<token type="Operator" />
<token type="LiteralString" />
<token type="Operator" />
</bygroups>
</rule>
</state>
<state name="declaration">
<rule pattern="(\s*)(&#34;(?:\\\\|\\&#34;|[^&#34;])*&#34;)(\s*)">
<bygroups>
<token type="Text"/>
<token type="NameAttribute"/>
<token type="Text"/>
<token type="Text" />
<token type="NameAttribute" />
<token type="Text" />
</bygroups>
</rule>
<rule pattern="\{">
<token type="Punctuation"/>
<pop depth="1"/>
<token type="Punctuation" />
<pop depth="1" />
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@@ -15,280 +15,287 @@
<rules>
<state name="expression">
<rule pattern="{">
<token type="Punctuation"/>
<push/>
<token type="Punctuation" />
<push />
</rule>
<rule pattern="}">
<token type="Punctuation"/>
<pop depth="1"/>
<token type="Punctuation" />
<pop depth="1" />
</rule>
<rule>
<include state="root"/>
<include state="root" />
</rule>
</state>
<state name="jsx">
<rule pattern="(&lt;)(/?)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="Punctuation" />
<token type="Punctuation" />
</bygroups>
</rule>
<rule pattern="(&lt;)([\w\.]+)">
<bygroups>
<token type="Punctuation"/>
<token type="NameTag"/>
<token type="Punctuation" />
<token type="NameTag" />
</bygroups>
<push state="tag"/>
<push state="tag" />
</rule>
<rule pattern="(&lt;)(/)([\w\.]*)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation"/>
<token type="NameTag"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="Punctuation" />
<token type="NameTag" />
<token type="Punctuation" />
</bygroups>
</rule>
</state>
<state name="tag">
<rule>
<include state="jsx"/>
<include state="jsx" />
</rule>
<rule pattern=",">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="&#39;(\\\\|\\&#39;|[^&#39;])*&#39;">
<token type="LiteralStringSingle"/>
<token type="LiteralStringSingle" />
</rule>
<rule pattern="`">
<token type="LiteralStringBacktick"/>
<push state="interp"/>
<token type="LiteralStringBacktick" />
<push state="interp" />
</rule>
<rule>
<include state="commentsandwhitespace"/>
<include state="commentsandwhitespace" />
</rule>
<rule pattern="\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="([\w-]+\s*)(=)(\s*)">
<bygroups>
<token type="NameAttribute"/>
<token type="Operator"/>
<token type="Text"/>
<token type="NameAttribute" />
<token type="Operator" />
<token type="Text" />
</bygroups>
<push state="attr"/>
<push state="attr" />
</rule>
<rule pattern="[{}]+">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="[\w\.]+">
<token type="NameAttribute"/>
<token type="NameAttribute" />
</rule>
<rule pattern="(/?)(\s*)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Text"/>
<token type="Punctuation"/>
<token type="Punctuation" />
<token type="Text" />
<token type="Punctuation" />
</bygroups>
<pop depth="1"/>
<pop depth="1" />
</rule>
</state>
<state name="comment">
<rule pattern="[^-]+">
<token type="Comment"/>
<token type="Comment" />
</rule>
<rule pattern="--&gt;">
<token type="Comment"/>
<pop depth="1"/>
<token type="Comment" />
<pop depth="1" />
</rule>
<rule pattern="-">
<token type="Comment"/>
<token type="Comment" />
</rule>
</state>
<state name="commentsandwhitespace">
<rule pattern="\s+">
<token type="Text"/>
<token type="Text" />
</rule>
<rule pattern="&lt;!--">
<token type="Comment"/>
<push state="comment"/>
<token type="Comment" />
<push state="comment" />
</rule>
<rule pattern="//.*?\n">
<token type="CommentSingle"/>
<token type="CommentSingle" />
</rule>
<rule pattern="/\*.*?\*/">
<token type="CommentMultiline"/>
<token type="CommentMultiline" />
</rule>
</state>
<state name="badregex">
<rule pattern="\n">
<token type="Text"/>
<pop depth="1"/>
<token type="Text" />
<pop depth="1" />
</rule>
</state>
<state name="interp">
<rule pattern="`">
<token type="LiteralStringBacktick"/>
<pop depth="1"/>
<token type="LiteralStringBacktick" />
<pop depth="1" />
</rule>
<rule pattern="\\\\">
<token type="LiteralStringBacktick"/>
<token type="LiteralStringBacktick" />
</rule>
<rule pattern="\\`">
<token type="LiteralStringBacktick"/>
<token type="LiteralStringBacktick" />
</rule>
<rule pattern="\$\{">
<token type="LiteralStringInterpol"/>
<push state="interp-inside"/>
<token type="LiteralStringInterpol" />
<push state="interp-inside" />
</rule>
<rule pattern="\$">
<token type="LiteralStringBacktick"/>
<token type="LiteralStringBacktick" />
</rule>
<rule pattern="[^`\\$]+">
<token type="LiteralStringBacktick"/>
<token type="LiteralStringBacktick" />
</rule>
</state>
<state name="attr">
<rule pattern="{">
<token type="Punctuation"/>
<push state="expression"/>
<token type="Punctuation" />
<push state="expression" />
</rule>
<rule pattern="&#34;.*?&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule pattern="&#39;.*?&#39;">
<token type="LiteralString"/>
<pop depth="1"/>
<token type="LiteralString" />
<pop depth="1" />
</rule>
<rule>
<pop depth="1"/>
<pop depth="1" />
</rule>
</state>
<state name="interp-inside">
<rule pattern="\}">
<token type="LiteralStringInterpol"/>
<pop depth="1"/>
<token type="LiteralStringInterpol" />
<pop depth="1" />
</rule>
<rule>
<include state="root"/>
<include state="root" />
</rule>
</state>
<state name="slashstartsregex">
<rule>
<include state="commentsandwhitespace"/>
<include state="commentsandwhitespace" />
</rule>
<rule pattern="/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)">
<token type="LiteralStringRegex"/>
<pop depth="1"/>
<token type="LiteralStringRegex" />
<pop depth="1" />
</rule>
<rule pattern="(?=/)">
<token type="Text"/>
<push state="badregex"/>
<token type="Text" />
<push state="badregex" />
</rule>
<rule>
<pop depth="1"/>
<pop depth="1" />
</rule>
</state>
<state name="root">
<rule>
<include state="jsx"/>
<include state="jsx" />
</rule>
<rule pattern="^(?=\s|/|&lt;!--)">
<token type="Text"/>
<push state="slashstartsregex"/>
<token type="Text" />
<push state="slashstartsregex" />
</rule>
<rule>
<include state="commentsandwhitespace"/>
<include state="commentsandwhitespace" />
</rule>
<rule pattern="\+\+|--|~|&amp;&amp;|\?|:|\|\||\\(?=\n)|(&lt;&lt;|&gt;&gt;&gt;?|==?|!=?|[-&lt;&gt;+*%&amp;|^/])=?">
<token type="Operator"/>
<push state="slashstartsregex"/>
<token type="Operator" />
<push state="slashstartsregex" />
</rule>
<rule pattern="[{(\[;,]">
<token type="Punctuation"/>
<push state="slashstartsregex"/>
<token type="Punctuation" />
<push state="slashstartsregex" />
</rule>
<rule pattern="[})\].]">
<token type="Punctuation"/>
<token type="Punctuation" />
</rule>
<rule pattern="(for|in|of|while|do|break|return|yield|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|keyof|asserts|is|infer|await|void|this)\b">
<token type="Keyword"/>
<push state="slashstartsregex"/>
<rule
pattern="(for|in|of|while|do|break|return|yield|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|keyof|asserts|is|infer|await|void|this)\b"
>
<token type="Keyword" />
<push state="slashstartsregex" />
</rule>
<rule pattern="(var|let|with|function)\b">
<token type="KeywordDeclaration"/>
<push state="slashstartsregex"/>
<token type="KeywordDeclaration" />
<push state="slashstartsregex" />
</rule>
<rule pattern="(abstract|async|boolean|class|const|debugger|enum|export|extends|from|get|global|goto|implements|import|interface|namespace|package|private|protected|public|readonly|require|set|static|super|type)\b">
<token type="KeywordReserved"/>
<rule
pattern="(abstract|async|boolean|class|const|debugger|enum|export|extends|from|get|global|goto|implements|import|interface|namespace|package|private|protected|public|readonly|require|set|static|super|type)\b"
>
<token type="KeywordReserved" />
</rule>
<rule pattern="(true|false|null|NaN|Infinity|undefined)\b">
<token type="KeywordConstant"/>
<token type="KeywordConstant" />
</rule>
<rule pattern="(Array|Boolean|Date|Error|Function|Math|Number|Object|Packages|RegExp|String|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\b">
<token type="NameBuiltin"/>
<rule
pattern="(Array|Boolean|Date|Error|Function|Math|Number|Object|Packages|RegExp|String|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\b"
>
<token type="NameBuiltin" />
</rule>
<rule pattern="\b(module)(\s+)(&quot;[\w\./@]+&quot;)(\s+)">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="NameOther"/>
<token type="Text"/>
<token type="KeywordReserved" />
<token type="Text" />
<token type="NameOther" />
<token type="Text" />
</bygroups>
<push state="slashstartsregex"/>
<push state="slashstartsregex" />
</rule>
<rule pattern="\b(string|bool|number|any|never|object|symbol|unique|unknown|bigint)\b">
<token type="KeywordType"/>
<token type="KeywordType" />
</rule>
<rule pattern="\b(constructor|declare|interface|as)\b">
<token type="KeywordReserved"/>
<token type="KeywordReserved" />
</rule>
<rule pattern="(super)(\s*)(\([\w,?.$\s]+\s*\))">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="KeywordReserved" />
<token type="TextWhitespace" />
<token type="Text" />
</bygroups>
<push state="slashstartsregex"/>
<push state="slashstartsregex" />
</rule>
<rule pattern="([a-zA-Z_?.$][\w?.$]*)\(\) \{">
<token type="NameOther"/>
<push state="slashstartsregex"/>
<token type="NameOther" />
<push state="slashstartsregex" />
</rule>
<rule pattern="([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)">
<bygroups>
<token type="NameOther"/>
<token type="Text"/>
<token type="KeywordType"/>
<token type="NameOther" />
<token type="Text" />
<token type="KeywordType" />
</bygroups>
</rule>
<rule pattern="[$a-zA-Z_]\w*">
<token type="NameOther"/>
<token type="NameOther" />
</rule>
<rule pattern="[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?">
<token type="LiteralNumberFloat"/>
<token type="LiteralNumberFloat" />
</rule>
<rule pattern="0x[0-9a-fA-F]+">
<token type="LiteralNumberHex"/>
<token type="LiteralNumberHex" />
</rule>
<rule pattern="[0-9]+">
<token type="LiteralNumberInteger"/>
<token type="LiteralNumberInteger" />
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
<token type="LiteralStringDouble" />
</rule>
<rule pattern="&#39;(\\\\|\\&#39;|[^&#39;])*&#39;">
<token type="LiteralStringSingle"/>
<token type="LiteralStringSingle" />
</rule>
<rule pattern="`">
<token type="LiteralStringBacktick"/>
<push state="interp"/>
<token type="LiteralStringBacktick" />
<push state="interp" />
</rule>
<rule pattern="@\w+">
<token type="KeywordDeclaration"/>
<token type="KeywordDeclaration" />
</rule>
</state>
</rules>

View File

@@ -366,6 +366,17 @@ restart:
}
}
}
// Validate emitters
for state := range r.rules {
for i := range len(r.rules[state]) {
rule := r.rules[state][i]
if validate, ok := rule.Type.(ValidatingEmitter); ok {
if err := validate.ValidateEmitter(rule); err != nil {
return fmt.Errorf("%s: %s: %s: %w", r.config.Name, state, rule.Pattern, err)
}
}
}
}
r.compiled = true
return nil
}