* Add some test snippets for the nix lexer These examples are from the Nix Reference Manual https://nixos.org/manual/nix/unstable/language/index.html This lexer needs some work but before changing anything here is a base line for how it is currently working. * Fixes multiline strings in the Nix lexer This wasn't working at all previously and matching pairs of single quotes would bread subsequent highlighting. * Fix variable matching in Nix lexer The previous regex matched the spaces and equals sign. This is now done using a lookahead. I'm not actually sure these cases should be Literal.String.Symbol, I certainly wouldn't want these highlighted as symbols, but I'm leaving this as-is for now. * Add support for literal floats in the Nix lexer This is checked before matching operators, I feel the it should be a bit more aware of the context, but it didn't raise any issues in the tests. * Handle nested blocks in Nix lexer * Handle interpolation cases, fixes #1800 This matching maybe a bit loose but didn't cause any regression in the test samples. * Fix some string escapes for the Nix lexer These cases were found to emit error tokens when lexing real-world code. The lexing code is not pretty, but handles the cases we know of. * Handle more string escape cases in Nix Lexer These cases found by lexing real-world code and looking for error tokens. * Handle negative integers in Nix lexer * Adds some operators to Nix lexer Also fixes some issues with the literal paths. * Add minus operator * Fix string literal issue in Nix lexer * Fix single backslash string in Nix lexer * Update the nix examplefiles goldens * Fix for string lexing in Nix * Add a missing operator to the nix lexer * Handle path starting with tilde in nix lexer * Handle another string escape in Nix lexer * Cleanup regex in Nix lexer
186 lines
4 KiB
Text
186 lines
4 KiB
Text
---input---
|
|
"foo" + "bar"
|
|
|
|
1 + 2
|
|
|
|
2 / 1
|
|
|
|
"foo" == "f" + "oo"
|
|
|
|
"foo" != "bar"
|
|
|
|
!true
|
|
|
|
2 * 2 < 5
|
|
|
|
5 > 1
|
|
|
|
2 - 1
|
|
|
|
{ x = 1; y = 2; }.x
|
|
|
|
{ x = 1; y = 2; }.z or 3
|
|
|
|
{ x = 1; y = 2; } // { z = 3; }
|
|
|
|
---tokens---
|
|
'"' Literal.String.Double
|
|
'foo' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'"' Literal.String.Double
|
|
'bar' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
'\n\n' Text
|
|
|
|
'1' Literal.Number.Integer
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'2' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'2' Literal.Number.Integer
|
|
' ' Text
|
|
'/' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'"' Literal.String.Double
|
|
'foo' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
' ' Text
|
|
'==' Operator
|
|
' ' Text
|
|
'"' Literal.String.Double
|
|
'f' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'"' Literal.String.Double
|
|
'oo' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
'\n\n' Text
|
|
|
|
'"' Literal.String.Double
|
|
'foo' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
' ' Text
|
|
'!' Operator
|
|
'=' Operator
|
|
' ' Text
|
|
'"' Literal.String.Double
|
|
'bar' Literal.String.Double
|
|
'"' Literal.String.Double
|
|
'\n\n' Text
|
|
|
|
'!' Operator
|
|
'true' Name.Constant
|
|
'\n\n' Text
|
|
|
|
'2' Literal.Number.Integer
|
|
' ' Text
|
|
'*' Operator
|
|
' ' Text
|
|
'2' Literal.Number.Integer
|
|
' ' Text
|
|
'<' Operator
|
|
' ' Text
|
|
'5' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'5' Literal.Number.Integer
|
|
' ' Text
|
|
'>' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'2' Literal.Number.Integer
|
|
' ' Text
|
|
'-' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'{' Punctuation
|
|
' ' Text
|
|
'x' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'y' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'2' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'}' Punctuation
|
|
'.' Operator
|
|
'x' Text
|
|
'\n\n' Text
|
|
|
|
'{' Punctuation
|
|
' ' Text
|
|
'x' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'y' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'2' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'}' Punctuation
|
|
'.' Operator
|
|
'z' Text
|
|
' ' Text
|
|
'or' Operator.Word
|
|
' ' Text
|
|
'3' Literal.Number.Integer
|
|
'\n\n' Text
|
|
|
|
'{' Punctuation
|
|
' ' Text
|
|
'x' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'1' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'y' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'2' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'}' Punctuation
|
|
' ' Text
|
|
'//' Operator
|
|
' ' Text
|
|
'{' Punctuation
|
|
' ' Text
|
|
'z' Literal.String.Symbol
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'3' Literal.Number.Integer
|
|
';' Punctuation
|
|
' ' Text
|
|
'}' Punctuation
|
|
'\n' Text
|