This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/snippets/nix/functions.txt
tarnacious 1d92d12403
Nix lexer improvements (#2551)
* 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
2023-11-05 11:10:28 +01:00

219 lines
4.2 KiB
Text

---input---
x: x + 1
A function that expects an integer and returns it increased by 1
x: y: x + y
(x: x + 1) 100
let inc = x: x + 1; in inc (inc (inc 100))
{ x, y }: x + y
{ x, y ? "bar" }: x + y
{ x, y, ... }: x + y
{ x, y } @ args: x + y
args @ { x, y }: x + y
---tokens---
'x' Text
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'1' Literal.Number.Integer
'\n\n\n' Text
'A' Text
' ' Text
'function' Text
' ' Text
'that' Text
' ' Text
'expects' Text
' ' Text
'an' Text
' ' Text
'integer' Text
' ' Text
'and' Operator.Word
' ' Text
'returns' Text
' ' Text
'it' Text
' ' Text
'increased' Text
' ' Text
'by' Text
' ' Text
'1' Literal.Number.Integer
'\n\n' Text
'x' Text
':' Punctuation
' ' Text
'y' Text
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n\n' Text
'(' Punctuation
'x' Text
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'1' Literal.Number.Integer
')' Punctuation
' ' Text
'100' Literal.Number.Integer
'\n\n' Text
'let' Keyword
' ' Text
'inc' Literal.String.Symbol
' ' Text
'=' Operator
' ' Text
'x' Text
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'1' Literal.Number.Integer
';' Punctuation
' ' Text
'in' Keyword
' ' Text
'inc' Text
' ' Text
'(' Punctuation
'inc' Text
' ' Text
'(' Punctuation
'inc' Text
' ' Text
'100' Literal.Number.Integer
')' Punctuation
')' Punctuation
'\n\n' Text
'{' Punctuation
' ' Text
'x' Text
',' Punctuation
' ' Text
'y' Text
' ' Text
'}' Punctuation
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n\n' Text
'{' Punctuation
' ' Text
'x' Text
',' Punctuation
' ' Text
'y' Text
' ' Text
'?' Operator
' ' Text
'"' Literal.String.Double
'bar' Literal.String.Double
'"' Literal.String.Double
' ' Text
'}' Punctuation
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n\n' Text
'{' Punctuation
' ' Text
'x' Text
',' Punctuation
' ' Text
'y' Text
',' Punctuation
' ' Text
'.' Operator
'.' Operator
'.' Operator
' ' Text
'}' Punctuation
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n\n' Text
'{' Punctuation
' ' Text
'x' Text
',' Punctuation
' ' Text
'y' Text
' ' Text
'}' Punctuation
' ' Text
'@' Punctuation
' ' Text
'args' Text
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n\n' Text
'args' Text
' ' Text
'@' Punctuation
' ' Text
'{' Punctuation
' ' Text
'x' Text
',' Punctuation
' ' Text
'y' Text
' ' Text
'}' Punctuation
':' Punctuation
' ' Text
'x' Text
' ' Text
'+' Operator
' ' Text
'y' Text
'\n' Text