From 898d467079907643cedd78e7ae813dd352017c51 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Mon, 26 Feb 2024 20:45:59 +0000 Subject: [PATCH] lexers/cue: support definitions and dollars in field names (#935) '$' 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. --- lexers/embedded/cue.xml | 2 +- lexers/testdata/cue.actual | 5 +++++ lexers/testdata/cue.expected | 24 +++++++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lexers/embedded/cue.xml b/lexers/embedded/cue.xml index 16d738726..d6c3ea71b 100644 --- a/lexers/embedded/cue.xml +++ b/lexers/embedded/cue.xml @@ -49,7 +49,7 @@ - + diff --git a/lexers/testdata/cue.actual b/lexers/testdata/cue.actual index f6a35e739..830682b2b 100644 --- a/lexers/testdata/cue.actual +++ b/lexers/testdata/cue.actual @@ -29,3 +29,8 @@ A: close({ field2: string }) +// Verify that various field types work +_hidden: int +regular: int +$id: int +#definition: int diff --git a/lexers/testdata/cue.expected b/lexers/testdata/cue.expected index 23204ac83..c7c0dce4c 100644 --- a/lexers/testdata/cue.expected +++ b/lexers/testdata/cue.expected @@ -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"} ]