internal: move inline parser tests to parser crate

This commit is contained in:
Aleksey Kladov 2021-12-26 18:19:09 +03:00
parent 0f74758fea
commit b360ea91f2
636 changed files with 11161 additions and 101 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 lex_valid() {
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 lex_valid() {
}
#[test]
fn lex_invalid() {
fn lex_err() {
for case in TestCase::list("lexer/err") {
let actual = lex(&case.text);
expect_file![case.txt].assert_eq(&actual)
@ -40,7 +42,7 @@ fn lex(text: &str) -> String {
}
#[test]
fn parse_valid() {
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);
@ -49,7 +51,16 @@ fn parse_valid() {
}
#[test]
fn parse_invalid() {
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);
@ -57,6 +68,15 @@ fn parse_invalid() {
}
}
#[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();

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,27 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "T"
WHITESPACE " "
EQ "="
WHITESPACE " "
SLICE_TYPE
L_BRACK "["
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
ERROR
INT_NUMBER "92"
ERROR
R_BRACK "]"
ERROR
SEMICOLON ";"
WHITESPACE "\n"
error 12: expected `;` or `]`
error 12: expected SEMICOLON
error 13: expected an item
error 15: expected an item
error 16: expected an item

View file

@ -0,0 +1,28 @@
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 "
ERROR
LABEL
LIFETIME
LIFETIME_IDENT "'loop"
COLON ":"
WHITESPACE " "
IMPL
IMPL_KW "impl"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 22: expected a loop
error 27: expected type
error 27: expected `{`

View file

@ -0,0 +1,17 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "T"
WHITESPACE " "
EQ "="
WHITESPACE " "
PTR_TYPE
STAR "*"
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
error 10: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)

View file

@ -0,0 +1,79 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Type"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait1"
WHITESPACE " "
FOR_KW "for"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "T"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
IMPL
IMPL_KW "impl"
WHITESPACE " "
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "NotType"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Trait2"
WHITESPACE " "
FOR_KW "for"
WHITESPACE " "
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "NotType"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 38: expected trait or type
error 38: expected `{`
error 70: expected trait or type
error 70: expected `{`

View file

@ -0,0 +1,23 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "F"
WHITESPACE " "
EQ "="
WHITESPACE " "
UNSAFE_KW "unsafe"
WHITESPACE " "
ERROR
L_PAREN "("
ERROR
R_PAREN ")"
ERROR
SEMICOLON ";"
WHITESPACE "\n"
error 15: expected `fn`
error 15: expected SEMICOLON
error 16: expected an item
error 17: expected an item
error 18: expected an item

View file

@ -0,0 +1,37 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE " "
ERROR
UNSAFE_KW "unsafe"
WHITESPACE " "
ERROR
L_CURLY "{"
WHITESPACE " "
R_CURLY "}"
WHITESPACE " "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "bar"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
error 11: expected an item
error 18: expected an item

View file

@ -0,0 +1,32 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
BLOCK_EXPR
ASYNC_KW "async"
WHITESPACE " "
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
error 27: expected SEMICOLON

View file

@ -0,0 +1,26 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
ERROR
VISIBILITY
PUB_KW "pub"
WHITESPACE " "
EXPR_STMT
LITERAL
INT_NUMBER "92"
SEMICOLON ";"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
error 14: expected an item

View file

@ -0,0 +1,21 @@
SOURCE_FILE
STATIC
STATIC_KW "static"
WHITESPACE " "
ERROR
UNDERSCORE "_"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "5"
SEMICOLON ";"
WHITESPACE "\n"
error 7: expected a name

View file

@ -0,0 +1,49 @@
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 "
RECORD_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "S"
WHITESPACE " "
RECORD_EXPR_FIELD_LIST
L_CURLY "{"
WHITESPACE " "
RECORD_EXPR_FIELD
NAME_REF
IDENT "field"
WHITESPACE " "
RANGE_EXPR
DOT2 ".."
CALL_EXPR
PATH_EXPR
PATH
PATH
PATH_SEGMENT
NAME_REF
IDENT "S"
COLON2 "::"
PATH_SEGMENT
NAME_REF
IDENT "default"
ARG_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
error 25: expected COLON

View file

@ -0,0 +1,31 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE " "
RECORD_FIELD
NAME
IDENT "f"
WHITESPACE " "
RECORD_FIELD
VISIBILITY
PUB_KW "pub"
WHITESPACE " "
NAME
IDENT "g"
COLON ":"
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
error 12: expected COLON
error 12: expected type
error 12: expected COMMA

View file

@ -0,0 +1,14 @@
SOURCE_FILE
USE
USE_KW "use"
WHITESPACE " "
USE_TREE
PATH
PATH
PATH_SEGMENT
NAME_REF
CRATE_KW "crate"
COLON2 "::"
SEMICOLON ";"
WHITESPACE "\n"
error 11: expected identifier

View file

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

View file

@ -0,0 +1,29 @@
SOURCE_FILE
USE
USE_KW "use"
WHITESPACE " "
USE_TREE
USE_TREE_LIST
L_CURLY "{"
USE_TREE
PATH
PATH_SEGMENT
NAME_REF
IDENT "a"
COMMA ","
WHITESPACE " "
USE_TREE
PATH
PATH_SEGMENT
NAME_REF
IDENT "b"
COMMA ","
WHITESPACE " "
USE_TREE
PATH
PATH_SEGMENT
NAME_REF
IDENT "c"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,63 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "for_trait"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "F"
R_ANGLE ">"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE "\n"
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE "\n "
WHERE_PRED
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 "F"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Fn"
PARAM_LIST
L_PAREN "("
PARAM
REF_TYPE
AMP "&"
LIFETIME
LIFETIME_IDENT "'a"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "str"
R_PAREN ")"
WHITESPACE "\n"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,60 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "F"
WHITESPACE " "
EQ "="
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Fn"
PARAM_LIST
L_PAREN "("
PARAM
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE " "
PARAM
REF_TYPE
AMP "&"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE " "
PARAM
REF_TYPE
AMP "&"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
COMMA ","
WHITESPACE " "
PARAM
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
R_PAREN ")"
R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,38 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
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"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_ANGLE ">"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,128 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "S"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "a"
PARAM_LIST
L_PAREN "("
SELF_PARAM
NAME
SELF_KW "self"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "b"
PARAM_LIST
L_PAREN "("
SELF_PARAM
AMP "&"
NAME
SELF_KW "self"
COMMA ","
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "c"
PARAM_LIST
L_PAREN "("
SELF_PARAM
AMP "&"
LIFETIME
LIFETIME_IDENT "'a"
WHITESPACE " "
NAME
SELF_KW "self"
COMMA ","
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "d"
PARAM_LIST
L_PAREN "("
SELF_PARAM
AMP "&"
LIFETIME
LIFETIME_IDENT "'a"
WHITESPACE " "
MUT_KW "mut"
WHITESPACE " "
NAME
SELF_KW "self"
COMMA ","
WHITESPACE " "
PARAM
IDENT_PAT
NAME
IDENT "x"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "e"
PARAM_LIST
L_PAREN "("
SELF_PARAM
MUT_KW "mut"
WHITESPACE " "
NAME
SELF_KW "self"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,53 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
GENERIC_PARAM_LIST
L_ANGLE "<"
TYPE_PARAM
NAME
IDENT "T"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
LIFETIME
LIFETIME_IDENT "'a"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
QUESTION "?"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Sized"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
L_PAREN "("
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
R_PAREN ")"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
TYPE_BOUND
TILDE "~"
CONST_KW "const"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Drop"
R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,98 @@
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 " "
PATH_PAT
PATH
PATH
PATH_SEGMENT
NAME_REF
IDENT "foo"
COLON2 "::"
PATH_SEGMENT
NAME_REF
IDENT "Bar"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
PATH_PAT
PATH
PATH_SEGMENT
COLON2 "::"
NAME_REF
IDENT "Bar"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
RECORD_PAT
PATH
PATH_SEGMENT
NAME_REF
IDENT "Bar"
WHITESPACE " "
RECORD_PAT_FIELD_LIST
L_CURLY "{"
WHITESPACE " "
REST_PAT
DOT2 ".."
WHITESPACE " "
R_CURLY "}"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
TUPLE_STRUCT_PAT
PATH
PATH_SEGMENT
NAME_REF
IDENT "Bar"
L_PAREN "("
REST_PAT
DOT2 ".."
R_PAREN ")"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_EXPR
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,26 @@
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
LOOP_EXPR
LOOP_KW "loop"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,21 @@
SOURCE_FILE
EXTERN_BLOCK
UNSAFE_KW "unsafe"
WHITESPACE " "
ABI
EXTERN_KW "extern"
WHITESPACE " "
STRING "\"C\""
WHITESPACE " "
EXTERN_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
EXTERN_BLOCK
ABI
EXTERN_KW "extern"
WHITESPACE " "
EXTERN_ITEM_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,60 @@
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
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "x"
DOT "."
NAME_REF
IDENT "foo"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
FIELD_EXPR
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "x"
DOT "."
NAME_REF
INT_NUMBER "0"
DOT "."
NAME_REF
IDENT "bar"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
CALL_EXPR
FIELD_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "x"
DOT "."
NAME_REF
INT_NUMBER "0"
ARG_LIST
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,33 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "Foo"
WHITESPACE " "
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE " "
WHERE_PRED
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Foo"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,35 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "M"
WHITESPACE " "
EQ "="
WHITESPACE " "
PTR_TYPE
STAR "*"
MUT_KW "mut"
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "C"
WHITESPACE " "
EQ "="
WHITESPACE " "
PTR_TYPE
STAR "*"
MUT_KW "mut"
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,13 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "Never"
WHITESPACE " "
EQ "="
WHITESPACE " "
NEVER_TYPE
BANG "!"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,38 @@
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 "
LOOP_EXPR
LOOP_KW "loop"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
CONTINUE_EXPR
CONTINUE_KW "continue"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
CONTINUE_EXPR
CONTINUE_KW "continue"
WHITESPACE " "
LIFETIME
LIFETIME_IDENT "'l"
SEMICOLON ";"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,21 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "T"
WHITESPACE " "
EQ "="
WHITESPACE " "
ARRAY_TYPE
L_BRACK "["
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE " "
LITERAL
INT_NUMBER "92"
R_BRACK "]"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -0,0 +1,76 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "S"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "a"
PARAM_LIST
L_PAREN "("
SELF_PARAM
NAME
SELF_KW "self"
COLON ":"
WHITESPACE " "
REF_TYPE
AMP "&"
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Self"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "b"
PARAM_LIST
L_PAREN "("
SELF_PARAM
MUT_KW "mut"
WHITESPACE " "
NAME
SELF_KW "self"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Box"
GENERIC_ARG_LIST
L_ANGLE "<"
TYPE_ARG
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Self"
R_ANGLE ">"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,45 @@
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
PREFIX_EXPR
STAR "*"
PREFIX_EXPR
STAR "*"
REF_EXPR
AMP "&"
LITERAL
INT_NUMBER "1"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
PREFIX_EXPR
BANG "!"
PREFIX_EXPR
BANG "!"
LITERAL
TRUE_KW "true"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
PREFIX_EXPR
MINUS "-"
PREFIX_EXPR
MINUS "-"
LITERAL
INT_NUMBER "1"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,81 @@
SOURCE_FILE
IMPL
IMPL_KW "impl"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "F"
WHITESPACE " "
ASSOC_ITEM_LIST
L_CURLY "{"
WHITESPACE "\n "
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "A"
WHITESPACE " "
EQ "="
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
SEMICOLON ";"
WHITESPACE "\n "
CONST
CONST_KW "const"
WHITESPACE " "
NAME
IDENT "B"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
WHITESPACE " "
EQ "="
WHITESPACE " "
LITERAL
INT_NUMBER "92"
SEMICOLON ";"
WHITESPACE "\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 "
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "bar"
PARAM_LIST
L_PAREN "("
SELF_PARAM
AMP "&"
NAME
SELF_KW "self"
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

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