1
1
mirror of https://github.com/oxalica/nil.git synced 2024-11-25 18:41:40 +03:00

Add parser tests

This commit is contained in:
oxalica 2022-07-23 05:14:57 +08:00
parent f48a103ee6
commit 3a4e18c5a5
21 changed files with 908 additions and 0 deletions

50
syntax/src/tests.rs Normal file
View File

@ -0,0 +1,50 @@
use crate::parse_file;
use expect_test::expect_file;
use std::fmt::Write;
use std::fs;
use std::path::Path;
fn run_test(dir: &Path, ok: bool) {
let mut test_files = dir
.read_dir()
.unwrap()
.filter_map(|entry| {
let path = entry.unwrap().path();
if path.extension().map_or(false, |ext| ext == "nix") {
Some(path)
} else {
None
}
})
.collect::<Vec<_>>();
test_files.sort();
for path in test_files {
let src = fs::read_to_string(&path).unwrap();
println!("Parsing {}", path.display());
let ast = parse_file(&src);
let mut got = String::new();
for (err, loc) in ast.errors() {
writeln!(got, "{} at {}", err, u32::from(*loc)).unwrap();
}
write!(got, "{:#?}", ast.syntax_node()).unwrap();
if ok != ast.errors().is_empty() {
println!("--------\n{}\n--------", got);
panic!("Unexpected test result for {}", path.display());
}
let expect_path = path.with_extension("ast");
println!("{:?}", expect_path);
expect_file![expect_path].assert_eq(&got);
}
}
#[test]
fn parser() {
let dir = Path::new("test_data/parser").canonicalize().unwrap();
run_test(&dir.join("ok"), true);
run_test(&dir.join("err"), false);
}

View File

@ -0,0 +1,2 @@
Unexpected token at 0
SOURCE_FILE@0..0

View File

View File

@ -0,0 +1,22 @@
Multiple root expressions at 12
SOURCE_FILE@0..24
ASSERT@0..12
KW_ASSERT@0..6 "assert"
SPACE@6..7 " "
LITERAL@7..8
INT@7..8 "1"
SEMICOLON@8..9 ";"
SPACE@9..10 " "
LITERAL@10..11
INT@10..11 "2"
SPACE@11..12 "\n"
ASSERT@12..24
KW_ASSERT@12..18 "assert"
SPACE@18..19 " "
LITERAL@19..20
INT@19..20 "3"
SEMICOLON@20..21 ";"
SPACE@21..22 " "
LITERAL@22..23
INT@22..23 "4"
SPACE@23..24 "\n"

View File

@ -0,0 +1,2 @@
assert 1; 2
assert 3; 4

View File

@ -0,0 +1,32 @@
SOURCE_FILE@0..33
LIST@0..32
L_BRACK@0..1 "["
SPACE@1..2 " "
LITERAL@2..4
INT@2..4 "42"
SPACE@4..5 " "
LITERAL@5..8
FLOAT@5..8 "1.0"
SPACE@8..9 " "
LITERAL@9..14
FLOAT@9..14 "1.2e3"
SPACE@14..15 " "
PAREN@15..27
L_PAREN@15..16 "("
LET_IN@16..26
KW_LET@16..19 "let"
SPACE@19..20 " "
KW_IN@20..22 "in"
SPACE@22..23 " "
ATTR_SET@23..26
L_CURLY@23..24 "{"
SPACE@24..25 " "
R_CURLY@25..26 "}"
R_PAREN@26..27 ")"
SPACE@27..28 " "
ATTR_SET@28..30
L_CURLY@28..29 "{"
R_CURLY@29..30 "}"
SPACE@30..31 " "
R_BRACK@31..32 "]"
SPACE@32..33 "\n"

View File

@ -0,0 +1 @@
[ 42 1.0 1.2e3 (let in { }) {} ]

View File

@ -0,0 +1,62 @@
SOURCE_FILE@0..78
ASSERT@0..78
KW_ASSERT@0..6 "assert"
SPACE@6..7 " "
LITERAL@7..8
INT@7..8 "1"
SEMICOLON@8..9 ";"
SPACE@9..10 "\n"
WITH@10..78
KW_WITH@10..14 "with"
SPACE@14..15 " "
LITERAL@15..16
INT@15..16 "2"
SEMICOLON@16..17 ";"
SPACE@17..18 "\n"
LET_IN@18..78
KW_LET@18..21 "let"
SPACE@21..22 " "
KW_IN@22..24 "in"
SPACE@24..25 "\n"
IF_THEN_ELSE@25..78
KW_IF@25..27 "if"
SPACE@27..30 "\n "
ATTR_SET@30..37
KW_REC@30..33 "rec"
SPACE@33..34 " "
L_CURLY@34..35 "{"
SPACE@35..36 " "
R_CURLY@36..37 "}"
SPACE@37..38 "\n"
KW_THEN@38..42 "then"
SPACE@42..45 "\n "
ATTR_SET@45..52
KW_LET@45..48 "let"
SPACE@48..49 " "
L_CURLY@49..50 "{"
SPACE@50..51 " "
R_CURLY@51..52 "}"
SPACE@52..53 "\n"
KW_ELSE@53..57 "else"
SPACE@57..60 "\n "
LAMBDA@60..78
PARAM@60..61
IDENT@60..61 "a"
COLON@61..62 ":"
SPACE@62..65 "\n "
LAMBDA@65..78
PARAM@65..70
PAT@65..70
L_CURLY@65..66 "{"
SPACE@66..67 " "
PAT_FIELD@67..69
IDENT@67..68 "b"
SPACE@68..69 " "
R_CURLY@69..70 "}"
COLON@70..71 ":"
SPACE@71..74 "\n "
ATTR_SET@74..77
L_CURLY@74..75 "{"
SPACE@75..76 " "
R_CURLY@76..77 "}"
SPACE@77..78 "\n"

View File

@ -0,0 +1,11 @@
assert 1;
with 2;
let in
if
rec { }
then
let { }
else
a:
{ b }:
{ }

View File

@ -0,0 +1,258 @@
SOURCE_FILE@0..209
LIST@0..208
L_BRACK@0..1 "["
SPACE@1..4 "\n "
PAREN@4..13
L_PAREN@4..5 "("
LAMBDA@5..12
PARAM@5..6
IDENT@5..6 "a"
COLON@6..7 ":"
SPACE@7..8 " "
LAMBDA@8..12
PARAM@8..9
IDENT@8..9 "b"
COLON@9..10 ":"
SPACE@10..11 " "
LITERAL@11..12
INT@11..12 "0"
R_PAREN@12..13 ")"
SPACE@13..16 "\n "
PAREN@16..29
L_PAREN@16..17 "("
LAMBDA@17..28
PARAM@17..20
PAT@17..20
L_CURLY@17..18 "{"
SPACE@18..19 " "
R_CURLY@19..20 "}"
COLON@20..21 ":"
SPACE@21..22 " "
LAMBDA@22..28
PARAM@22..25
PAT@22..25
L_CURLY@22..23 "{"
SPACE@23..24 " "
R_CURLY@24..25 "}"
COLON@25..26 ":"
SPACE@26..27 " "
LITERAL@27..28
INT@27..28 "0"
R_PAREN@28..29 ")"
SPACE@29..32 "\n "
PAREN@32..44
L_PAREN@32..33 "("
LAMBDA@33..43
PARAM@33..40
PAT@33..40
L_CURLY@33..34 "{"
SPACE@34..35 " "
DOT3@35..38 "..."
SPACE@38..39 " "
R_CURLY@39..40 "}"
COLON@40..41 ":"
SPACE@41..42 " "
LITERAL@42..43
INT@42..43 "0"
R_PAREN@43..44 ")"
SPACE@44..47 "\n "
PAREN@47..57
L_PAREN@47..48 "("
LAMBDA@48..56
PARAM@48..53
PAT@48..53
L_CURLY@48..49 "{"
SPACE@49..50 " "
PAT_FIELD@50..52
IDENT@50..51 "a"
SPACE@51..52 " "
R_CURLY@52..53 "}"
COLON@53..54 ":"
SPACE@54..55 " "
LITERAL@55..56
INT@55..56 "0"
R_PAREN@56..57 ")"
SPACE@57..60 "\n "
PAREN@60..71
L_PAREN@60..61 "("
LAMBDA@61..70
PARAM@61..67
PAT@61..67
L_CURLY@61..62 "{"
SPACE@62..63 " "
PAT_FIELD@63..64
IDENT@63..64 "a"
COMMA@64..65 ","
SPACE@65..66 " "
R_CURLY@66..67 "}"
COLON@67..68 ":"
SPACE@68..69 " "
LITERAL@69..70
INT@69..70 "0"
R_PAREN@70..71 ")"
SPACE@71..74 "\n "
PAREN@74..89
L_PAREN@74..75 "("
LAMBDA@75..88
PARAM@75..85
PAT@75..85
L_CURLY@75..76 "{"
SPACE@76..77 " "
PAT_FIELD@77..78
IDENT@77..78 "a"
COMMA@78..79 ","
SPACE@79..80 " "
DOT3@80..83 "..."
SPACE@83..84 " "
R_CURLY@84..85 "}"
COLON@85..86 ":"
SPACE@86..87 " "
LITERAL@87..88
INT@87..88 "0"
R_PAREN@88..89 ")"
SPACE@89..92 "\n "
PAREN@92..105
L_PAREN@92..93 "("
LAMBDA@93..104
PARAM@93..101
PAT@93..101
L_CURLY@93..94 "{"
SPACE@94..95 " "
PAT_FIELD@95..96
IDENT@95..96 "a"
COMMA@96..97 ","
SPACE@97..98 " "
PAT_FIELD@98..100
IDENT@98..99 "b"
SPACE@99..100 " "
R_CURLY@100..101 "}"
COLON@101..102 ":"
SPACE@102..103 " "
LITERAL@103..104
INT@103..104 "0"
R_PAREN@104..105 ")"
SPACE@105..108 "\n "
PAREN@108..120
L_PAREN@108..109 "("
LAMBDA@109..119
PARAM@109..116
PAT@109..116
L_CURLY@109..110 "{"
SPACE@110..111 " "
DOT3@111..114 "..."
SPACE@114..115 " "
R_CURLY@115..116 "}"
COLON@116..117 ":"
SPACE@117..118 " "
LITERAL@118..119
INT@118..119 "0"
R_PAREN@119..120 ")"
SPACE@120..123 "\n "
PAREN@123..149
L_PAREN@123..124 "("
LAMBDA@124..148
PARAM@124..145
PAT@124..145
L_CURLY@124..125 "{"
SPACE@125..126 " "
PAT_FIELD@126..135
IDENT@126..127 "a"
SPACE@127..128 " "
QUESTION@128..129 "?"
SPACE@129..130 " "
LAMBDA@130..135
PARAM@130..132
PAT@130..132
L_CURLY@130..131 "{"
R_CURLY@131..132 "}"
COLON@132..133 ":"
SPACE@133..134 " "
REF@134..135
IDENT@134..135 "a"
COMMA@135..136 ","
SPACE@136..137 " "
PAT_FIELD@137..138
IDENT@137..138 "b"
COMMA@138..139 ","
SPACE@139..140 " "
DOT3@140..143 "..."
SPACE@143..144 " "
R_CURLY@144..145 "}"
COLON@145..146 ":"
SPACE@146..147 " "
LITERAL@147..148
INT@147..148 "0"
R_PAREN@148..149 ")"
SPACE@149..153 "\n\n "
PAREN@153..163
L_PAREN@153..154 "("
LAMBDA@154..162
PARAM@154..159
IDENT@154..155 "a"
AT@155..156 "@"
PAT@156..159
L_CURLY@156..157 "{"
SPACE@157..158 " "
R_CURLY@158..159 "}"
COLON@159..160 ":"
SPACE@160..161 " "
LITERAL@161..162
INT@161..162 "0"
R_PAREN@162..163 ")"
SPACE@163..166 "\n "
PAREN@166..178
L_PAREN@166..167 "("
LAMBDA@167..177
PARAM@167..174
IDENT@167..168 "a"
AT@168..169 "@"
PAT@169..174
L_CURLY@169..170 "{"
SPACE@170..171 " "
PAT_FIELD@171..173
IDENT@171..172 "a"
SPACE@172..173 " "
R_CURLY@173..174 "}"
COLON@174..175 ":"
SPACE@175..176 " "
LITERAL@176..177
INT@176..177 "0"
R_PAREN@177..178 ")"
SPACE@178..181 "\n "
PAREN@181..191
L_PAREN@181..182 "("
LAMBDA@182..190
PARAM@182..187
PAT@182..185
L_CURLY@182..183 "{"
SPACE@183..184 " "
R_CURLY@184..185 "}"
AT@185..186 "@"
IDENT@186..187 "a"
COLON@187..188 ":"
SPACE@188..189 " "
LITERAL@189..190
INT@189..190 "0"
R_PAREN@190..191 ")"
SPACE@191..194 "\n "
PAREN@194..206
L_PAREN@194..195 "("
LAMBDA@195..205
PARAM@195..202
PAT@195..200
L_CURLY@195..196 "{"
SPACE@196..197 " "
PAT_FIELD@197..199
IDENT@197..198 "a"
SPACE@198..199 " "
R_CURLY@199..200 "}"
AT@200..201 "@"
IDENT@201..202 "a"
COLON@202..203 ":"
SPACE@203..204 " "
LITERAL@204..205
INT@204..205 "0"
R_PAREN@205..206 ")"
SPACE@206..207 "\n"
R_BRACK@207..208 "]"
SPACE@208..209 "\n"

View File

@ -0,0 +1,16 @@
[
(a: b: 0)
({ }: { }: 0)
({ ... }: 0)
({ a }: 0)
({ a, }: 0)
({ a, ... }: 0)
({ a, b }: 0)
({ ... }: 0)
({ a ? {}: a, b, ... }: 0)
(a@{ }: 0)
(a@{ a }: 0)
({ }@a: 0)
({ a }@a: 0)
]

View File

@ -0,0 +1,90 @@
SOURCE_FILE@0..71
BINARY_OP@0..71
LITERAL@0..1
INT@0..1 "1"
SPACE@1..2 " "
MINUS_GT@2..4 "->"
BINARY_OP@4..71
BINARY_OP@4..32
BINARY_OP@4..23
SPACE@4..5 " "
LITERAL@5..6
INT@5..6 "2"
SPACE@6..7 " "
OR2@7..9 "||"
BINARY_OP@9..23
SPACE@9..10 " "
UNARY_OP@10..13
MINUS@10..11 "-"
LITERAL@11..12
INT@11..12 "3"
SPACE@12..13 " "
AND2@13..15 "&&"
BINARY_OP@15..23
SPACE@15..16 " "
LITERAL@16..17
INT@16..17 "4"
SPACE@17..18 " "
EQ2@18..20 "=="
SPACE@20..21 " "
LITERAL@21..22
INT@21..22 "5"
SPACE@22..23 " "
OR2@23..25 "||"
BINARY_OP@25..32
SPACE@25..26 " "
LITERAL@26..27
INT@26..27 "6"
SPACE@27..28 " "
LT@28..29 "<"
SPACE@29..30 " "
LITERAL@30..31
INT@30..31 "7"
SPACE@31..32 " "
OR2@32..34 "||"
BINARY_OP@34..71
SPACE@34..35 " "
LITERAL@35..36
INT@35..36 "8"
SPACE@36..37 " "
SLASH2@37..39 "//"
BINARY_OP@39..71
SPACE@39..40 " "
UNARY_OP@40..66
BANG@40..41 "!"
BINARY_OP@41..66
LITERAL@41..42
INT@41..42 "9"
SPACE@42..43 " "
PLUS@43..44 "+"
BINARY_OP@44..66
SPACE@44..45 " "
LITERAL@45..47
INT@45..47 "10"
SPACE@47..48 " "
STAR@48..49 "*"
BINARY_OP@49..66
SPACE@49..50 " "
LITERAL@50..52
INT@50..52 "11"
SPACE@52..53 " "
PLUS2@53..55 "++"
HAS_ATTR@55..66
SPACE@55..56 " "
APPLY@56..62
LITERAL@56..58
INT@56..58 "12"
SPACE@58..59 " "
LITERAL@59..61
INT@59..61 "13"
SPACE@61..62 " "
QUESTION@62..63 "?"
ATTR_PATH@63..66
SPACE@63..64 " "
IDENT@64..65 "a"
SPACE@65..66 " "
SLASH2@66..68 "//"
SPACE@68..69 " "
LITERAL@69..70
INT@69..70 "1"
SPACE@70..71 "\n"

View File

@ -0,0 +1 @@
1 -> 2 || -3 && 4 == 5 || 6 < 7 || 8 // !9 + 10 * 11 ++ 12 13 ? a // 1

View File

@ -0,0 +1,37 @@
SOURCE_FILE@0..27
APPLY@0..27
SELECT@0..25
REF@0..1
IDENT@0..1 "a"
DOT@1..2 "."
ATTR_PATH@2..13
IDENT@2..3 "b"
DOT@3..4 "."
DYNAMIC@4..8
DOLLAR_L_CURLY@4..6 "${"
REF@6..7
IDENT@6..7 "c"
R_CURLY@7..8 "}"
DOT@8..9 "."
STRING@9..12
DQUOTE@9..10 "\""
STRING_FRAGMENT@10..11 "d"
DQUOTE@11..12 "\""
SPACE@12..13 " "
KW_OR@13..15 "or"
SELECT@15..25
SPACE@15..16 " "
REF@16..17
IDENT@16..17 "e"
DOT@17..18 "."
ATTR_PATH@18..20
IDENT@18..19 "f"
SPACE@19..20 " "
KW_OR@20..22 "or"
SPACE@22..23 " "
REF@23..24
IDENT@23..24 "g"
SPACE@24..25 " "
REF@25..26
IDENT@25..26 "h"
SPACE@26..27 "\n"

View File

@ -0,0 +1 @@
a.b.${c}."d" or e.f or g h

View File

@ -0,0 +1,96 @@
SOURCE_FILE@0..121
LIST@0..120
L_BRACK@0..1 "["
SPACE@1..4 "\n "
REF@4..5
IDENT@4..5 "a"
SPACE@5..8 "\n "
LITERAL@8..9
INT@8..9 "1"
SPACE@9..12 "\n "
LITERAL@12..15
FLOAT@12..15 "1.2"
SPACE@15..18 "\n "
LITERAL@18..20
ABSOLUTE_PATH@18..20 "/a"
SPACE@20..23 "\n "
LITERAL@23..26
RELATIVE_PATH@23..26 "a/a"
SPACE@26..29 "\n "
LITERAL@29..32
HOME_PATH@29..32 "~/a"
SPACE@32..35 "\n "
LITERAL@35..38
URI@35..38 "a:a"
SPACE@38..41 "\n "
STRING@41..52
DQUOTE@41..42 "\""
STRING_FRAGMENT@42..44 "fo"
DYNAMIC@44..50
DOLLAR_L_CURLY@44..46 "${"
REF@46..49
IDENT@46..49 "bar"
R_CURLY@49..50 "}"
STRING_FRAGMENT@50..51 "o"
DQUOTE@51..52 "\""
SPACE@52..55 "\n "
INDENT_STRING@55..68
QUOTE2@55..57 "''"
STRING_FRAGMENT@57..59 "fo"
DYNAMIC@59..65
DOLLAR_L_CURLY@59..61 "${"
REF@61..64
IDENT@61..64 "bar"
R_CURLY@64..65 "}"
STRING_FRAGMENT@65..66 "o"
QUOTE2@66..68 "''"
SPACE@68..71 "\n "
ATTR_SET@71..78
KW_REC@71..74 "rec"
SPACE@74..75 " "
L_CURLY@75..76 "{"
SPACE@76..77 " "
R_CURLY@77..78 "}"
SPACE@78..81 "\n "
ATTR_SET@81..88
KW_LET@81..84 "let"
SPACE@84..85 " "
L_CURLY@85..86 "{"
SPACE@86..87 " "
R_CURLY@87..88 "}"
SPACE@88..91 "\n "
ATTR_SET@91..94
L_CURLY@91..92 "{"
SPACE@92..93 " "
R_CURLY@93..94 "}"
SPACE@94..97 "\n "
SELECT@97..115
REF@97..98
IDENT@97..98 "a"
DOT@98..99 "."
ATTR_PATH@99..101
IDENT@99..100 "b"
SPACE@100..101 " "
KW_OR@101..103 "or"
SELECT@103..115
SPACE@103..104 " "
REF@104..105
IDENT@104..105 "c"
DOT@105..106 "."
ATTR_PATH@106..108
IDENT@106..107 "d"
SPACE@107..108 " "
KW_OR@108..110 "or"
SPACE@110..111 " "
REF@111..112
IDENT@111..112 "e"
SPACE@112..115 "\n "
SELECT@115..119
REF@115..116
IDENT@115..116 "f"
DOT@116..117 "."
ATTR_PATH@117..119
IDENT@117..118 "g"
SPACE@118..119 "\n"
R_BRACK@119..120 "]"
SPACE@120..121 "\n"

View File

@ -0,0 +1,16 @@
[
a
1
1.2
/a
a/a
~/a
a:a
"fo${bar}o"
''fo${bar}o''
rec { }
let { }
{ }
a.b or c.d or e
f.g
]

View File

@ -0,0 +1,150 @@
SOURCE_FILE@0..160
LET_IN@0..160
KW_LET@0..3 "let"
SPACE@3..6 "\n "
ATTR_PATH_VALUE@6..27
ATTR_PATH@6..23
IDENT@6..7 "a"
DOT@7..8 "."
IDENT@8..9 "b"
DOT@9..10 "."
DYNAMIC@10..14
DOLLAR_L_CURLY@10..12 "${"
REF@12..13
IDENT@12..13 "c"
R_CURLY@13..14 "}"
DOT@14..15 "."
STRING@15..22
DQUOTE@15..16 "\""
STRING_FRAGMENT@16..17 "d"
DYNAMIC@17..21
DOLLAR_L_CURLY@17..19 "${"
REF@19..20
IDENT@19..20 "e"
R_CURLY@20..21 "}"
DQUOTE@21..22 "\""
SPACE@22..23 " "
EQ@23..24 "="
SPACE@24..25 " "
LITERAL@25..26
INT@25..26 "1"
SEMICOLON@26..27 ";"
SPACE@27..30 "\n "
INHERIT@30..49
KW_INHERIT@30..37 "inherit"
SPACE@37..38 " "
IDENT@38..39 "a"
SPACE@39..40 " "
DYNAMIC@40..44
DOLLAR_L_CURLY@40..42 "${"
REF@42..43
IDENT@42..43 "b"
R_CURLY@43..44 "}"
SPACE@44..45 " "
STRING@45..48
DQUOTE@45..46 "\""
STRING_FRAGMENT@46..47 "c"
DQUOTE@47..48 "\""
SEMICOLON@48..49 ";"
SPACE@49..52 "\n "
ATTR_PATH_VALUE@52..65
ATTR_PATH@52..61
DYNAMIC@52..58
DOLLAR_L_CURLY@52..54 "${"
REF@54..57
IDENT@54..57 "dyn"
R_CURLY@57..58 "}"
DOT@58..59 "."
IDENT@59..60 "a"
SPACE@60..61 " "
EQ@61..62 "="
SPACE@62..63 " "
LITERAL@63..64
INT@63..64 "1"
SEMICOLON@64..65 ";"
SPACE@65..68 "\n "
INHERIT@68..86
KW_INHERIT@68..75 "inherit"
SPACE@75..76 " "
PAREN@76..83
L_PAREN@76..77 "("
BINARY_OP@77..82
REF@77..78
IDENT@77..78 "a"
SPACE@78..79 " "
PLUS@79..80 "+"
SPACE@80..81 " "
REF@81..82
IDENT@81..82 "b"
R_PAREN@82..83 ")"
SPACE@83..84 " "
IDENT@84..85 "c"
SEMICOLON@85..86 ";"
SPACE@86..87 "\n"
KW_IN@87..89 "in"
SPACE@89..90 " "
ATTR_SET@90..159
L_CURLY@90..91 "{"
SPACE@91..94 "\n "
INHERIT@94..104
KW_INHERIT@94..101 "inherit"
SPACE@101..102 " "
IDENT@102..103 "c"
SEMICOLON@103..104 ";"
SPACE@104..107 "\n "
ATTR_PATH_VALUE@107..128
ATTR_PATH@107..111
IDENT@107..108 "d"
DOT@108..109 "."
IDENT@109..110 "e"
SPACE@110..111 " "
EQ@111..112 "="
SPACE@112..113 " "
ATTR_SET@113..127
KW_REC@113..116 "rec"
SPACE@116..117 " "
L_CURLY@117..118 "{"
SPACE@118..119 " "
ATTR_PATH_VALUE@119..125
ATTR_PATH@119..121
IDENT@119..120 "f"
SPACE@120..121 " "
EQ@121..122 "="
SPACE@122..123 " "
LITERAL@123..124
INT@123..124 "1"
SEMICOLON@124..125 ";"
SPACE@125..126 " "
R_CURLY@126..127 "}"
SEMICOLON@127..128 ";"
SPACE@128..131 "\n "
ATTR_PATH_VALUE@131..157
ATTR_PATH@131..136
DYNAMIC@131..135
DOLLAR_L_CURLY@131..133 "${"
REF@133..134
IDENT@133..134 "f"
R_CURLY@134..135 "}"
SPACE@135..136 " "
EQ@136..137 "="
SPACE@137..138 " "
ATTR_SET@138..156
KW_LET@138..141 "let"
SPACE@141..142 " "
L_CURLY@142..143 "{"
SPACE@143..144 " "
ATTR_PATH_VALUE@144..154
ATTR_PATH@144..149
IDENT@144..148 "body"
SPACE@148..149 " "
EQ@149..150 "="
SPACE@150..151 " "
LITERAL@151..153
INT@151..153 "42"
SEMICOLON@153..154 ";"
SPACE@154..155 " "
R_CURLY@155..156 "}"
SEMICOLON@156..157 ";"
SPACE@157..158 "\n"
R_CURLY@158..159 "}"
SPACE@159..160 "\n"

View File

@ -0,0 +1,10 @@
let
a.b.${c}."d${e}" = 1;
inherit a ${b} "c";
${dyn}.a = 1;
inherit (a + b) c;
in {
inherit c;
d.e = rec { f = 1; };
${f} = let { body = 42; };
}

View File

@ -0,0 +1,50 @@
SOURCE_FILE@0..45
LET_IN@0..45
KW_LET@0..3 "let"
SPACE@3..4 " "
ATTR_PATH_VALUE@4..11
ATTR_PATH@4..7
IDENT@4..6 "or"
SPACE@6..7 " "
EQ@7..8 "="
SPACE@8..9 " "
LITERAL@9..10
INT@9..10 "1"
SEMICOLON@10..11 ";"
SPACE@11..12 " "
KW_IN@12..14 "in"
SPACE@14..15 " "
BINARY_OP@15..45
LIST@15..30
L_BRACK@15..16 "["
SPACE@16..17 " "
SELECT@17..29
ATTR_SET@17..20
L_CURLY@17..18 "{"
SPACE@18..19 " "
R_CURLY@19..20 "}"
DOT@20..21 "."
ATTR_PATH@21..24
IDENT@21..23 "or"
SPACE@23..24 " "
KW_OR@24..26 "or"
SPACE@26..27 " "
LITERAL@27..28
INT@27..28 "1"
SPACE@28..29 " "
R_BRACK@29..30 "]"
SPACE@30..31 " "
PLUS@31..32 "+"
SPACE@32..33 " "
APPLY@33..45
APPLY@33..42
REF@33..38
IDENT@33..38 "foldr"
SPACE@38..39 " "
REF@39..41
IDENT@39..41 "or"
SPACE@41..42 " "
ATTR_SET@42..44
L_CURLY@42..43 "{"
R_CURLY@43..44 "}"
SPACE@44..45 "\n"

View File

@ -0,0 +1 @@
let or = 1; in [ { }.or or 1 ] + foldr or {}