11120: internal: move parser tests to parser crate r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-12-26 15:54:02 +00:00 committed by GitHub
commit 3494d817b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
987 changed files with 24847 additions and 94 deletions

1
Cargo.lock generated
View File

@ -1082,6 +1082,7 @@ dependencies = [
"expect-test",
"limit",
"rustc-ap-rustc_lexer",
"sourcegen",
]
[[package]]

View File

@ -16,3 +16,5 @@ limit = { path = "../limit", version = "0.0.0" }
[dev-dependencies]
expect-test = "1.2"
sourcegen = { path = "../sourcegen" }

View File

@ -463,13 +463,6 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// x.0.bar;
// x.0();
// }
// test_err bad_tuple_index_expr
// fn foo() {
// x.0.;
// x.1i32;
// x.0x01;
// }
fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![.]));
let m = lhs.precede(p);

View File

@ -1,3 +1,5 @@
mod sourcegen_inline_tests;
use std::{
fmt::Write,
fs,
@ -9,7 +11,7 @@ use expect_test::expect_file;
use crate::LexedStr;
#[test]
fn valid_lexes_input() {
fn lex_ok() {
for case in TestCase::list("lexer/ok") {
let actual = lex(&case.text);
expect_file![case.txt].assert_eq(&actual)
@ -17,7 +19,7 @@ fn valid_lexes_input() {
}
#[test]
fn invalid_lexes_input() {
fn lex_err() {
for case in TestCase::list("lexer/err") {
let actual = lex(&case.text);
expect_file![case.txt].assert_eq(&actual)
@ -39,6 +41,79 @@ fn lex(text: &str) -> String {
res
}
#[test]
fn parse_ok() {
for case in TestCase::list("parser/ok") {
let (actual, errors) = parse(&case.text);
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
expect_file![case.txt].assert_eq(&actual);
}
}
#[test]
fn parse_inline_ok() {
for case in TestCase::list("parser/inline/ok") {
let (actual, errors) = parse(&case.text);
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
expect_file![case.txt].assert_eq(&actual);
}
}
#[test]
fn parse_err() {
for case in TestCase::list("parser/err") {
let (actual, errors) = parse(&case.text);
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
expect_file![case.txt].assert_eq(&actual)
}
}
#[test]
fn parse_inline_err() {
for case in TestCase::list("parser/inline/err") {
let (actual, errors) = parse(&case.text);
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
expect_file![case.txt].assert_eq(&actual)
}
}
fn parse(text: &str) -> (String, bool) {
let lexed = LexedStr::new(text);
let input = lexed.to_input();
let output = crate::parse_source_file(&input);
let mut buf = String::new();
let mut errors = Vec::new();
let mut indent = String::new();
lexed.intersperse_trivia(&output, false, &mut |step| match step {
crate::StrStep::Token { kind, text } => {
write!(buf, "{}", indent).unwrap();
write!(buf, "{:?} {:?}\n", kind, text).unwrap();
}
crate::StrStep::Enter { kind } => {
write!(buf, "{}", indent).unwrap();
write!(buf, "{:?}\n", kind).unwrap();
indent.push_str(" ");
}
crate::StrStep::Exit => {
indent.pop();
indent.pop();
}
crate::StrStep::Error { msg, pos } => errors.push(format!("error {}: {}\n", pos, msg)),
});
for (token, msg) in lexed.errors() {
let pos = lexed.text_start(token);
errors.push(format!("error {}: {}\n", pos, msg));
}
let has_errors = !errors.is_empty();
for e in errors {
buf.push_str(&e);
}
(buf, has_errors)
}
#[derive(PartialEq, Eq, PartialOrd, Ord)]
struct TestCase {
rs: PathBuf,

View File

@ -2,21 +2,20 @@
//! them into tests.
use std::{
collections::HashMap,
fs, iter,
path::{Path, PathBuf},
};
use rustc_hash::FxHashMap;
#[test]
fn sourcegen_parser_tests() {
let grammar_dir = sourcegen::project_root().join(Path::new("crates/parser/src/grammar"));
let tests = tests_from_dir(&grammar_dir);
install_tests(&tests.ok, "crates/syntax/test_data/parser/inline/ok");
install_tests(&tests.err, "crates/syntax/test_data/parser/inline/err");
install_tests(&tests.ok, "crates/parser/test_data/parser/inline/ok");
install_tests(&tests.err, "crates/parser/test_data/parser/inline/err");
fn install_tests(tests: &FxHashMap<String, Test>, into: &str) {
fn install_tests(tests: &HashMap<String, Test>, into: &str) {
let tests_dir = sourcegen::project_root().join(into);
if !tests_dir.is_dir() {
fs::create_dir_all(&tests_dir).unwrap();
@ -51,8 +50,8 @@ struct Test {
#[derive(Default, Debug)]
struct Tests {
ok: FxHashMap<String, Test>,
err: FxHashMap<String, Test>,
ok: HashMap<String, Test>,
err: HashMap<String, Test>,
}
fn collect_tests(s: &str) -> Vec<Test> {
@ -102,8 +101,8 @@ fn tests_from_dir(dir: &Path) -> Tests {
}
}
fn existing_tests(dir: &Path, ok: bool) -> FxHashMap<String, (PathBuf, Test)> {
let mut res = FxHashMap::default();
fn existing_tests(dir: &Path, ok: bool) -> HashMap<String, (PathBuf, Test)> {
let mut res = HashMap::default();
for file in fs::read_dir(dir).unwrap() {
let file = file.unwrap();
let path = file.path();

View File

@ -0,0 +1,34 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "a"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "b"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
WHITESPACE "\n"
R_CURLY "}"
error 21: expected COMMA

View File

@ -0,0 +1,18 @@
SOURCE_FILE
ERROR
IF_KW "if"
WHITESPACE " "
ERROR
MATCH_KW "match"
WHITESPACE "\n\n"
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
R_CURLY "}"
error 0: expected an item
error 3: expected an item

View File

@ -0,0 +1,45 @@
SOURCE_FILE
SHEBANG "#!/use/bin/env rusti"
WHITESPACE "\n"
ATTR
POUND "#"
BANG "!"
ERROR
SLASH "/"
USE
USE_KW "use"
ERROR
SLASH "/"
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "bin"
ERROR
SLASH "/"
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "env"
WHITESPACE " "
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "rusti"
WHITESPACE "\n"
error 23: expected `[`
error 23: expected an item
error 27: expected one of `*`, `::`, `{`, `self`, `super` or an identifier
error 28: expected SEMICOLON
error 31: expected BANG
error 31: expected `{`, `[`, `(`
error 31: expected SEMICOLON
error 31: expected an item
error 35: expected BANG
error 35: expected `{`, `[`, `(`
error 35: expected SEMICOLON
error 41: expected BANG
error 41: expected `{`, `[`, `(`
error 41: expected SEMICOLON

View File

@ -0,0 +1,39 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "a"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "b"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "String"
COMMA ","
WHITESPACE "\n"
R_CURLY "}"
ERROR
SEMICOLON ";"
error 39: expected item, found `;`
consider removing this semicolon

View File

@ -0,0 +1,15 @@
SOURCE_FILE
USE
USE_KW "use"
WHITESPACE " "
USE_TREE
PATH
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
COLON2 "::"
ERROR
INT_NUMBER "92"
SEMICOLON ";"
error 9: expected identifier

View File

@ -0,0 +1,62 @@
SOURCE_FILE
FN
ATTR
POUND "#"
L_BRACK "["
META
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
TOKEN_TREE
L_PAREN "("
IDENT "foo"
COMMA ","
WHITESPACE " "
PLUS "+"
COMMA ","
WHITESPACE " "
INT_NUMBER "92"
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n"
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n\n\n"
ATTR
POUND "#"
L_BRACK "["
META
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
TOKEN_TREE
L_PAREN "("
WHITESPACE "\n"
FN_KW "fn"
WHITESPACE " "
IDENT "foo"
TOKEN_TREE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
TOKEN_TREE
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 53: expected R_PAREN
error 53: expected `]`
error 53: expected an item

View File

@ -0,0 +1,74 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "f"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
COMMA ","
WHITESPACE "\n "
VISIBILITY
PUB_KW "pub"
WHITESPACE " "
ERROR
INT_NUMBER "92"
WHITESPACE "\n "
ERROR
PLUS "+"
WHITESPACE " "
ERROR
MINUS "-"
WHITESPACE " "
ERROR
STAR "*"
WHITESPACE "\n "
RECORD_FIELD
VISIBILITY
PUB_KW "pub"
WHITESPACE " "
NAME
IDENT "x"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
COMMA ","
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "z"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "f64"
COMMA ","
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 31: expected field declaration
error 33: expected COMMA
error 38: expected field declaration
error 39: expected COMMA
error 40: expected field declaration
error 41: expected COMMA
error 42: expected field declaration
error 43: expected COMMA

View File

@ -0,0 +1,33 @@
SOURCE_FILE
ERROR
R_CURLY "}"
WHITESPACE "\n\n"
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
SEMICOLON ";"
WHITESPACE "\n\n"
ERROR
R_CURLY "}"
WHITESPACE "\n\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n\n"
ERROR
R_CURLY "}"
WHITESPACE "\n"
error 0: unmatched `}`
error 14: unmatched `}`
error 29: unmatched `}`

View File

@ -0,0 +1,81 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n\n"
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "bar"
TOKEN_TREE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
ERROR
L_CURLY "{"
WHITESPACE "\n "
IF_EXPR
IF_KW "if"
WHITESPACE " "
CONDITION
LITERAL
TRUE_KW "true"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LITERAL
INT_NUMBER "1"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
BIN_EXPR
LITERAL
INT_NUMBER "2"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
LITERAL
INT_NUMBER "3"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "baz"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 17: expected BANG
error 19: expected SEMICOLON
error 20: expected an item

View File

@ -0,0 +1,56 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
GENERIC_PARAM_LIST
L_ANGLE "<"
ERROR
INT_NUMBER "90"
WHITESPACE " "
ERROR
PLUS "+"
WHITESPACE " "
ERROR
INT_NUMBER "2"
ERROR
R_ANGLE ">"
WHITESPACE " "
ERROR
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "f"
ERROR
COLON ":"
WHITESPACE " "
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n\n"
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "T"
SEMICOLON ";"
WHITESPACE "\n"
error 9: expected type parameter
error 11: expected COMMA
error 11: expected R_ANGLE
error 11: expected `;`, `{`, or `(`
error 12: expected an item
error 14: expected an item
error 15: expected an item
error 17: expected an item
error 24: expected SEMICOLON
error 24: expected expression

View File

@ -0,0 +1,45 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
CLOSURE_EXPR
PARAM_LIST
PIPE "|"
PIPE "|"
WHITESPACE " "
RET_TYPE
THIN_ARROW "->"
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
EXPR_STMT
BLOCK_EXPR
UNSAFE_KW "unsafe"
WHITESPACE " "
STMT_LIST
L_CURLY "{"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 24: expected a block
error 24: expected SEMICOLON

View File

@ -0,0 +1,13 @@
SOURCE_FILE
ERROR
ABI
EXTERN_KW "extern"
WHITESPACE " "
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "Foo"
SEMICOLON ";"
WHITESPACE "\n"
error 6: expected existential, fn, trait or impl

View File

@ -0,0 +1,89 @@
SOURCE_FILE
STRUCT
VISIBILITY
PUB_KW "pub"
WHITESPACE " "
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "Cache"
TUPLE_FIELD_LIST
L_PAREN "("
WHITESPACE "\n "
TUPLE_FIELD
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "RefCell"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "HashMap"
GENERIC_ARG_LIST
L_ANGLE "<"
WHITESPACE "\n "
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "TypeId"
COMMA ","
WHITESPACE "\n "
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
ERROR
AT "@"
WHITESPACE " "
TUPLE_FIELD
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Any"
ERROR
ERROR
R_ANGLE ">"
ERROR
COMMA ","
WHITESPACE "\n "
ERROR
R_ANGLE ">"
ERROR
R_ANGLE ">"
WHITESPACE "\n"
ERROR
R_PAREN ")"
ERROR
SEMICOLON ";"
WHITESPACE "\n\n"
error 67: expected type
error 68: expected COMMA
error 68: expected R_ANGLE
error 68: expected COMMA
error 68: expected R_ANGLE
error 68: expected COMMA
error 68: expected R_ANGLE
error 68: expected COMMA
error 72: expected COMMA
error 72: expected a type
error 72: expected R_PAREN
error 72: expected SEMICOLON
error 72: expected an item
error 73: expected an item
error 79: expected an item
error 80: expected an item
error 82: expected an item
error 83: expected an item

View File

@ -0,0 +1,32 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "T"
R_ANGLE ">"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE " "
WHERE_PRED
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "T"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 19: expected colon

View File

@ -0,0 +1,24 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
ERROR
R_CURLY "}"
ERROR
R_PAREN ")"
WHITESPACE " "
ERROR
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 7: expected value parameter
error 7: expected R_PAREN
error 7: expected a block
error 7: unmatched `}`
error 8: expected an item
error 10: expected an item

View File

@ -0,0 +1,44 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
ARG_LIST
L_PAREN "("
WHITESPACE "\n "
LITERAL
INT_NUMBER "1"
COMMA ","
WHITESPACE " "
LITERAL
INT_NUMBER "2"
WHITESPACE "\n "
R_PAREN ")"
WHITESPACE "\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
WHITESPACE " "
LITERAL
INT_NUMBER "92"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 38: expected SEMICOLON

View File

@ -0,0 +1,47 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
PARAM
IDENT_PAT
NAME
IDENT "foo"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "bar"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "92"
SEMICOLON ";"
WHITESPACE "\n "
BIN_EXPR
LITERAL
INT_NUMBER "1"
WHITESPACE " "
PLUS "+"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 44: expected expression

View File

@ -0,0 +1,133 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "FnScopes"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "new_scope"
PARAM_LIST
L_PAREN "("
PARAM
REF_PAT
AMP "&"
R_PAREN ")"
WHITESPACE " "
RET_TYPE
THIN_ARROW "->"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "ScopeId"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "res"
WHITESPACE " "
EQ "="
WHITESPACE " "
METHOD_CALL_EXPR
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
SELF_KW "self"
DOT "."
NAME_REF
IDENT "scopes"
DOT "."
NAME_REF
IDENT "len"
ARG_LIST
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
METHOD_CALL_EXPR
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
SELF_KW "self"
DOT "."
NAME_REF
IDENT "scopes"
DOT "."
NAME_REF
IDENT "push"
ARG_LIST
L_PAREN "("
RECORD_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "ScopeData"
WHITESPACE " "
RECORD_EXPR_FIELD_LIST
L_CURLY "{"
WHITESPACE " "
RECORD_EXPR_FIELD
NAME_REF
IDENT "parent"
COLON ":"
WHITESPACE " "
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "None"
COMMA ","
WHITESPACE " "
RECORD_EXPR_FIELD
NAME_REF
IDENT "entries"
COLON ":"
WHITESPACE " "
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "vec"
BANG "!"
TOKEN_TREE
L_BRACK "["
R_BRACK "]"
WHITESPACE " "
R_CURLY "}"
R_PAREN ")"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "set_parent"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 34: expected pattern
error 34: missing type for function parameter
error 180: expected function arguments
error 180: expected a block

View File

@ -0,0 +1,107 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "bar"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "1"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "baz"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "92"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE "\n "
EXPR_STMT
IF_EXPR
IF_KW "if"
WHITESPACE " "
CONDITION
LITERAL
TRUE_KW "true"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE "\n "
EXPR_STMT
WHILE_EXPR
WHILE_KW "while"
WHITESPACE " "
CONDITION
LITERAL
TRUE_KW "true"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE "\n "
LOOP_EXPR
LOOP_KW "loop"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 24: expected expression
error 24: expected SEMICOLON
error 49: expected pattern
error 49: expected SEMICOLON
error 75: expected pattern
error 75: expected SEMICOLON
error 98: expected pattern
error 98: expected SEMICOLON
error 124: expected pattern
error 124: expected SEMICOLON

View File

@ -0,0 +1,21 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE "\n\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 2: expected a name
error 2: expected function arguments
error 2: expected a block

View File

@ -0,0 +1,34 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
PARAM
IDENT_PAT
NAME
IDENT "x"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE " "
PARAM
IDENT_PAT
NAME
IDENT "y"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 16: missing type for function parameter

View File

@ -0,0 +1,171 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "a"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
ARRAY_EXPR
L_BRACK "["
LITERAL
INT_NUMBER "1"
COMMA ","
WHITESPACE " "
LITERAL
INT_NUMBER "2"
COMMA ","
WHITESPACE " "
ERROR
AT "@"
ERROR
COMMA ","
WHITESPACE " "
STRUCT
STRUCT_KW "struct"
ERROR
COMMA ","
WHITESPACE " "
LET_STMT
LET_KW "let"
ERROR
R_BRACK "]"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "b"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
ARG_LIST
L_PAREN "("
LITERAL
INT_NUMBER "1"
COMMA ","
WHITESPACE " "
LITERAL
INT_NUMBER "2"
COMMA ","
WHITESPACE " "
ERROR
AT "@"
ERROR
COMMA ","
WHITESPACE " "
IMPL
IMPL_KW "impl"
ERROR
COMMA ","
WHITESPACE " "
LET_STMT
LET_KW "let"
ERROR
R_PAREN ")"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "c"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
METHOD_CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
DOT "."
NAME_REF
IDENT "bar"
ARG_LIST
L_PAREN "("
LITERAL
INT_NUMBER "1"
COMMA ","
WHITESPACE " "
LITERAL
INT_NUMBER "2"
COMMA ","
WHITESPACE " "
ERROR
AT "@"
ERROR
COMMA ","
WHITESPACE " "
ERROR
R_BRACK "]"
ERROR
COMMA ","
WHITESPACE " "
TRAIT
TRAIT_KW "trait"
ERROR
COMMA ","
WHITESPACE " "
LET_STMT
LET_KW "let"
ERROR
R_PAREN ")"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
error 16: expected expression
error 17: expected R_BRACK
error 17: expected SEMICOLON
error 17: expected expression
error 25: expected a name
error 26: expected `;`, `{`, or `(`
error 30: expected pattern
error 31: expected SEMICOLON
error 53: expected expression
error 54: expected SEMICOLON
error 54: expected expression
error 60: expected type
error 60: expected `{`
error 60: expected expression
error 65: expected pattern
error 65: expected SEMICOLON
error 65: expected expression
error 92: expected expression
error 93: expected SEMICOLON
error 93: expected expression
error 95: expected expression
error 96: expected expression
error 103: expected a name
error 104: expected `{`
error 108: expected pattern
error 108: expected SEMICOLON
error 108: expected expression

View File

@ -0,0 +1,44 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
BANG "!"
WHITESPACE " "
TOKEN_TREE
L_PAREN "("
WHITESPACE "\n "
IDENT "bar"
COMMA ","
WHITESPACE " "
STRING "\"baz\""
COMMA ","
WHITESPACE " "
INT_NUMBER "1"
COMMA ","
WHITESPACE " "
FLOAT_NUMBER "2.0"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
COMMENT "//~ ERROR incorrect close delimiter"
WHITESPACE "\n"
ERROR
R_CURLY "}"
WHITESPACE "\n"
error 49: unmatched `}`
error 92: unmatched `}`

View File

@ -0,0 +1,321 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "T"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
L_PAREN "("
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
QUESTION "?"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Sized"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
FOR_TYPE
FOR_KW "for"
GENERIC_PARAM_LIST
L_ANGLE "<"
LIFETIME_PARAM
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait"
GENERIC_ARG_LIST
L_ANGLE "<"
LIFETIME_ARG
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
R_PAREN ")"
R_ANGLE ">"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
COLON ":"
WHITESPACE " "
DYN_TRAIT_TYPE
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PAREN_TYPE
L_PAREN "("
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
QUESTION "?"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Sized"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
FOR_TYPE
FOR_KW "for"
GENERIC_PARAM_LIST
L_ANGLE "<"
LIFETIME_PARAM
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait"
GENERIC_ARG_LIST
L_ANGLE "<"
LIFETIME_ARG
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
R_PAREN ")"
ERROR
R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PAREN_TYPE
L_PAREN "("
ERROR
QUESTION "?"
EXPR_STMT
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "Sized"
ERROR
R_PAREN ")"
WHITESPACE " "
ERROR
PLUS "+"
WHITESPACE " "
EXPR_STMT
TUPLE_EXPR
L_PAREN "("
FOR_EXPR
FOR_KW "for"
PATH_PAT
PATH
PATH_SEGMENT
L_ANGLE "<"
ERROR
LIFETIME_IDENT "'a"
R_ANGLE ">"
WHITESPACE " "
BIN_EXPR
BIN_EXPR
BIN_EXPR
BIN_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait"
L_ANGLE "<"
ERROR
LIFETIME_IDENT "'a"
R_ANGLE ">"
ERROR
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
PAREN_EXPR
L_PAREN "("
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_PAREN ")"
R_ANGLE ">"
ERROR
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
COLON ":"
WHITESPACE " "
DYN_TRAIT_TYPE
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PAREN_TYPE
L_PAREN "("
FOR_TYPE
FOR_KW "for"
GENERIC_PARAM_LIST
L_ANGLE "<"
LIFETIME_PARAM
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait"
GENERIC_ARG_LIST
L_ANGLE "<"
LIFETIME_ARG
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
QUESTION "?"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Sized"
R_PAREN ")"
ERROR
R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 88: expected COMMA
error 88: expected R_ANGLE
error 121: expected SEMICOLON
error 121: expected expression
error 140: expected type
error 141: expected R_PAREN
error 141: expected COMMA
error 141: expected R_ANGLE
error 141: expected SEMICOLON
error 146: expected SEMICOLON
error 146: expected expression
error 148: expected expression
error 155: expected type
error 158: expected IN_KW
error 165: expected expression
error 168: expected expression
error 179: expected expression
error 180: expected a block
error 180: expected COMMA
error 180: expected expression
error 180: expected R_PAREN
error 180: expected SEMICOLON
error 215: expected COMMA
error 215: expected R_ANGLE
error 235: expected SEMICOLON
error 235: expected expression

View File

@ -0,0 +1,204 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
ENUM
ENUM_KW "enum"
WHITESPACE " "
NAME
IDENT "Test"
WHITESPACE " "
VARIANT_LIST
L_CURLY "{"
WHITESPACE "\n "
VARIANT
NAME
IDENT "Var1"
COMMA ","
WHITESPACE "\n "
VARIANT
NAME
IDENT "Var2"
TUPLE_FIELD_LIST
L_PAREN "("
TUPLE_FIELD
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "String"
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
VARIANT
NAME
IDENT "Var3"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "abc"
COLON ":"
WHITESPACE " "
ERROR
L_CURLY "{"
R_CURLY "}"
ERROR
COMMA ","
WHITESPACE " "
COMMENT "//~ ERROR: expected type, found `{`"
WHITESPACE "\n "
R_CURLY "}"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
COMMENT "// recover..."
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "a"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "1"
SEMICOLON ";"
WHITESPACE "\n "
ENUM
ENUM_KW "enum"
WHITESPACE " "
NAME
IDENT "Test2"
WHITESPACE " "
VARIANT_LIST
L_CURLY "{"
WHITESPACE "\n "
VARIANT
NAME
IDENT "Fine"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
ENUM
ENUM_KW "enum"
WHITESPACE " "
NAME
IDENT "Test3"
WHITESPACE " "
VARIANT_LIST
L_CURLY "{"
WHITESPACE "\n "
VARIANT
NAME
IDENT "StillFine"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE "\n "
RECORD_FIELD
NAME
IDENT "def"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
EXPR_STMT
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
ENUM
COMMENT "// fail again"
WHITESPACE "\n "
ENUM_KW "enum"
WHITESPACE " "
NAME
IDENT "Test4"
WHITESPACE " "
VARIANT_LIST
L_CURLY "{"
WHITESPACE "\n "
VARIANT
NAME
IDENT "Nope"
TUPLE_FIELD_LIST
L_PAREN "("
TUPLE_FIELD
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
WHITESPACE " "
ERROR
ERROR
L_CURLY "{"
R_CURLY "}"
ERROR
R_PAREN ")"
WHITESPACE " "
COMMENT "//~ ERROR: found `{`"
WHITESPACE "\n "
COMMENT "//~^ ERROR: found `{`"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n "
COMMENT "// still recover later"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "bad_syntax"
WHITESPACE " "
EQ "="
WHITESPACE " "
ERROR
UNDERSCORE "_"
SEMICOLON ";"
WHITESPACE " "
COMMENT "//~ ERROR: expected expression, found reserved identifier `_`"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 95: expected type
error 95: expected COMMA
error 96: expected field
error 98: expected field declaration
error 371: expected COMMA
error 372: expected a type
error 372: expected R_PAREN
error 372: expected COMMA
error 372: expected enum variant
error 374: expected enum variant
error 508: expected expression

View File

@ -0,0 +1,49 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "T"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Clone"
R_ANGLE ">"
WHITESPACE "\n"
IMPL
IMPL_KW "impl"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "T"
R_ANGLE ">"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "OnceCell"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "T"
R_ANGLE ">"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 14: expected trait or type
error 14: expected `{`

View File

@ -0,0 +1,29 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE "\n "
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE " "
WHERE_PRED
FOR_KW "for"
GENERIC_PARAM_LIST
L_ANGLE "<"
LIFETIME_PARAM
LIFETIME
LIFETIME_IDENT "'a"
R_ANGLE ">"
WHITESPACE "\n"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 26: expected type
error 26: expected colon

View File

@ -0,0 +1,36 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
PARAM
IDENT_PAT
NAME
IDENT "a"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "A"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "a"
DOT "."
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 21: expected field name or number

View File

@ -0,0 +1,205 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
MATCH_EXPR
MATCH_KW "match"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
MATCH_ARM_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
ATTR
POUND "#"
ERROR
BANG "!"
ARRAY_EXPR
L_BRACK "["
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "doc"
ARG_LIST
L_PAREN "("
LITERAL
STRING "\"Not allowed here\""
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
EXPR_STMT
MATCH_EXPR
MATCH_KW "match"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
MATCH_ARM_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
ATTR
POUND "#"
ERROR
BANG "!"
ARRAY_EXPR
L_BRACK "["
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "doc"
ARG_LIST
L_PAREN "("
LITERAL
STRING "\"Nor here\""
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n\n "
MATCH_EXPR
MATCH_KW "match"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
MATCH_ARM_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_ARM
ATTR
POUND "#"
L_BRACK "["
META
PATH
PATH_SEGMENT
NAME_REF
IDENT "cfg"
TOKEN_TREE
L_PAREN "("
IDENT "test"
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n "
ATTR
POUND "#"
ERROR
BANG "!"
ARRAY_EXPR
L_BRACK "["
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "doc"
ARG_LIST
L_PAREN "("
LITERAL
STRING "\"Nor here\""
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 52: expected `[`
error 52: expected pattern
error 53: expected FAT_ARROW
error 78: expected `,`
error 161: expected `[`
error 161: expected pattern
error 162: expected FAT_ARROW
error 232: expected `[`
error 232: expected pattern
error 233: expected FAT_ARROW
error 250: expected `,`

View File

@ -0,0 +1,68 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_EXPR
MATCH_KW "match"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
MATCH_ARM_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
ATTR
POUND "#"
L_BRACK "["
META
PATH
PATH_SEGMENT
NAME_REF
IDENT "cfg"
TOKEN_TREE
L_PAREN "("
IDENT "test"
R_PAREN ")"
R_BRACK "]"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 80: expected pattern
error 80: expected FAT_ARROW
error 80: expected expression

View File

@ -0,0 +1,96 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
REF_KW "ref"
WHITESPACE " "
ERROR
BOX_KW "box"
WHITESPACE " "
EXPR_STMT
BIN_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "i"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
MUT_KW "mut"
WHITESPACE " "
ERROR
BOX_KW "box"
WHITESPACE " "
EXPR_STMT
BIN_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "i"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
REF_KW "ref"
WHITESPACE " "
MUT_KW "mut"
WHITESPACE " "
ERROR
BOX_KW "box"
WHITESPACE " "
EXPR_STMT
BIN_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "i"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n\n"
error 24: expected a name
error 27: expected SEMICOLON
error 48: expected a name
error 51: expected SEMICOLON
error 76: expected a name
error 79: expected SEMICOLON

Some files were not shown because too many files have changed in this diff Show More