Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lexers/cue: support definitions and dollars in field names
'$' is valid in a bare field name in CUE. It is not special. It happens
to be used by convention at the start of field names, but that is about
it.

Definitions start with '#'.

Add a "section" of tests that cover the various types of field. There
are no errors in new "tests", whereas before (i.e. without the change to
the CUE lexer) there would have been.
  • Loading branch information
myitcv committed Feb 26, 2024
commit fc37acf7cce2a2d31ae57fa072614f7190e6afab
2 changes: 1 addition & 1 deletion lexers/embedded/cue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<rule pattern="(true|false|null|_)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="[_a-zA-Z]\w*">
<rule pattern="#?[_a-zA-Z$]\w*">
<token type="Name"/>
</rule>
</state>
Expand Down
5 changes: 5 additions & 0 deletions lexers/testdata/cue.actual
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ A: close({
field2: string
})

// Verify that various field types work
_hidden: int
regular: int
$id: int
#definition: int
24 changes: 23 additions & 1 deletion lexers/testdata/cue.expected
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,27 @@
{"type":"KeywordType","value":"string"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"})"},
{"type":"Text","value":"\n\n"}
{"type":"Text","value":"\n\n"},
{"type":"CommentSingle","value":"// Verify that various field types work"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"_hidden"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"regular"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"$id"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"#definition"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"Text","value":"\n"}
]