rust/crates/libsyntax2/src/grammar.ron
2018-08-27 10:12:28 +03:00

459 lines
10 KiB
Plaintext

Grammar(
single_byte_tokens: [
[";", "SEMI"],
[",", "COMMA"],
["(", "L_PAREN"],
[")", "R_PAREN"],
["{", "L_CURLY"],
["}", "R_CURLY"],
["[", "L_BRACK"],
["]", "R_BRACK"],
["<", "L_ANGLE"],
[">", "R_ANGLE"],
["@", "AT"],
["#", "POUND"],
["~", "TILDE"],
["?", "QUESTION"],
["$", "DOLLAR"],
["&", "AMP"],
["|", "PIPE"],
["+", "PLUS"],
["*", "STAR"],
["/", "SLASH"],
["^", "CARET"],
["%", "PERCENT"],
],
multi_byte_tokens: [
[".", "DOT"],
["..", "DOTDOT"],
["...", "DOTDOTDOT"],
["..=", "DOTDOTEQ"],
[":", "COLON"],
["::", "COLONCOLON"],
["=", "EQ"],
["==", "EQEQ"],
["=>", "FAT_ARROW"],
["!", "EXCL"],
["!=", "NEQ"],
["-", "MINUS"],
["->", "THIN_ARROW"],
["<=", "LTEQ"],
[">=", "GTEQ"],
["+=", "PLUSEQ"],
["-=", "MINUSEQ"],
["|=", "PIPEEQ"],
["&=", "AMPEQ"],
["^=", "CARETEQ"],
["/=", "SLASHEQ"],
["*=", "STAREQ"],
["&&", "AMPAMP"],
["||", "PIPEPIPE"],
["<<", "SHL"],
[">>", "SHR"],
["<<=", "SHLEQ"],
[">>=", "SHREQ"],
],
keywords: [
"use",
"fn",
"struct",
"enum",
"trait",
"impl",
"dyn",
"true",
"false",
"as",
"extern",
"crate",
"mod",
"pub",
"self",
"super",
"in",
"where",
"for",
"loop",
"while",
"continue",
"break",
"if",
"else",
"match",
"const",
"static",
"mut",
"unsafe",
"type",
"ref",
"let",
"move",
"return",
],
contextual_keywords: [
"auto",
"default",
"union",
],
tokens: [
"ERROR",
"IDENT",
"UNDERSCORE",
"WHITESPACE",
"INT_NUMBER",
"FLOAT_NUMBER",
"LIFETIME",
"CHAR",
"BYTE",
"STRING",
"RAW_STRING",
"BYTE_STRING",
"RAW_BYTE_STRING",
"COMMENT",
"DOC_COMMENT",
"SHEBANG",
],
nodes: [
"ROOT",
"STRUCT_DEF",
"ENUM_DEF",
"FN_DEF",
"EXTERN_CRATE_ITEM",
"MODULE",
"USE_ITEM",
"STATIC_DEF",
"CONST_DEF",
"TRAIT_DEF",
"IMPL_ITEM",
"TYPE_DEF",
"MACRO_CALL",
"TOKEN_TREE",
"PAREN_TYPE",
"TUPLE_TYPE",
"NEVER_TYPE",
"PATH_TYPE",
"POINTER_TYPE",
"ARRAY_TYPE",
"SLICE_TYPE",
"REFERENCE_TYPE",
"PLACEHOLDER_TYPE",
"FN_POINTER_TYPE",
"FOR_TYPE",
"IMPL_TRAIT_TYPE",
"DYN_TRAIT_TYPE",
"REF_PAT",
"BIND_PAT",
"PLACEHOLDER_PAT",
"PATH_PAT",
"STRUCT_PAT",
"FIELD_PAT_LIST",
"TUPLE_STRUCT_PAT",
"TUPLE_PAT",
"SLICE_PAT",
"RANGE_PAT",
// atoms
"TUPLE_EXPR",
"ARRAY_EXPR",
"PAREN_EXPR",
"PATH_EXPR",
"LAMBDA_EXPR",
"IF_EXPR",
"LOOP_EXPR",
"FOR_EXPR",
"WHILE_EXPR",
"CONTINUE_EXPR",
"BREAK_EXPR",
"LABEL",
"BLOCK_EXPR",
"RETURN_EXPR",
"MATCH_EXPR",
"MATCH_ARM_LIST",
"MATCH_ARM",
"MATCH_GUARD",
"STRUCT_LIT",
"NAMED_FIELD_LIST",
"NAMED_FIELD",
// postfix
"CALL_EXPR",
"INDEX_EXPR",
"METHOD_CALL_EXPR",
"FIELD_EXPR",
"TRY_EXPR",
"CAST_EXPR",
// unary
"REF_EXPR",
"PREFIX_EXPR",
"RANGE_EXPR", // just weird
"BIN_EXPR",
"BLOCK",
"EXTERN_BLOCK",
"EXTERN_ITEM_LIST",
"ENUM_VARIANT",
"NAMED_FIELD_DEF_LIST",
"NAMED_FIELD_DEF",
"POS_FIELD_LIST",
"POS_FIELD",
"ENUM_VARIANT_LIST",
"ITEM_LIST",
"ATTR",
"META_ITEM", // not an item actually
"USE_TREE",
"USE_TREE_LIST",
"PATH",
"PATH_SEGMENT",
"LITERAL",
"ALIAS",
"VISIBILITY",
"WHERE_CLAUSE",
"WHERE_PRED",
"ABI",
"NAME",
"NAME_REF",
"LET_STMT",
"EXPR_STMT",
"TYPE_PARAM_LIST",
"LIFETIME_PARAM",
"TYPE_PARAM",
"TYPE_ARG_LIST",
"LIFETIME_ARG",
"TYPE_ARG",
"ASSOC_TYPE_ARG",
"PARAM_LIST",
"PARAM",
"SELF_PARAM",
"ARG_LIST",
],
ast: {
"Root": (
collections: [
["functions", "FnDef"],
["modules", "Module"],
]
),
"FnDef": (
traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
],
options: [
["param_list", "ParamList"],
["body", "Block"],
],
),
"StructDef": (
traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
],
collections: [
["fields", "NamedFieldDef"]
]
),
"NamedFieldDef": ( traits: ["NameOwner", "AttrsOwner"] ),
"EnumDef": ( traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
] ),
"TraitDef": ( traits: ["NameOwner", "AttrsOwner"] ),
"Module": (
traits: ["NameOwner", "AttrsOwner"],
collections: [
["modules", "Module"]
]
),
"ConstDef": ( traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
] ),
"StaticDef": ( traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
] ),
"TypeDef": ( traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
] ),
"ImplItem": (),
"ParenType": (),
"TupleType": (),
"NeverType": (),
"PathType": (),
"PointerType": (),
"ArrayType": (),
"SliceType": (),
"ReferenceType": (),
"PlaceholderType": (),
"FnPointerType": (),
"ForType": (),
"ImplTraitType": (),
"DynTraitType": (),
"TypeRef": ( enum: [
"ParenType",
"TupleType",
"NeverType",
"PathType",
"PointerType",
"ArrayType",
"SliceType",
"ReferenceType",
"PlaceholderType",
"FnPointerType",
"ForType",
"ImplTraitType",
"DynTraitType",
]),
"NominalDef": (
enum: ["StructDef", "EnumDef"],
traits: [
"NameOwner",
"TypeParamsOwner",
"AttrsOwner"
],
),
"TupleExpr": (),
"ArrayExpr": (),
"ParenExpr": (),
"PathExpr": (),
"LambdaExpr": (),
"IfExpr": (),
"LoopExpr": (),
"ForExpr": (),
"WhileExpr": (),
"ContinueExpr": (),
"BreakExpr": (),
"Label": (),
"BlockExpr": (),
"ReturnExpr": (),
"MatchExpr": (),
"MatchArmList": (),
"MatchArm": (),
"MatchGuard": (),
"StructLit": (),
"NamedFieldList": (),
"NamedField": (),
"CallExpr": (),
"IndexExpr": (),
"MethodCallExpr": (),
"FieldExpr": (),
"TryExpr": (),
"CastExpr": (),
"RefExpr": (),
"PrefixExpr": (),
"RangeExpr": (),
"BinExpr": (),
"Expr": (
enum: [
"TupleExpr",
"ArrayExpr",
"ParenExpr",
"PathExpr",
"LambdaExpr",
"IfExpr",
"LoopExpr",
"ForExpr",
"WhileExpr",
"ContinueExpr",
"BreakExpr",
"Label",
"BlockExpr",
"ReturnExpr",
"MatchExpr",
"MatchArmList",
"MatchArm",
"MatchGuard",
"StructLit",
"NamedFieldList",
"NamedField",
"CallExpr",
"IndexExpr",
"MethodCallExpr",
"FieldExpr",
"TryExpr",
"CastExpr",
"RefExpr",
"PrefixExpr",
"RangeExpr",
"BinExpr",
],
),
"RefPat": (),
"BindPat": ( traits: ["NameOwner"] ),
"PlaceholderPat": (),
"PathPat": (),
"StructPat": (),
"FieldPatList": (),
"TupleStructPat": (),
"TuplePat": (),
"SlicePat": (),
"RangePat": (),
"Pat": (
enum: [
"RefPat",
"BindPat",
"PlaceholderPat",
"PathPat",
"StructPat",
"FieldPatList",
"TupleStructPat",
"TuplePat",
"SlicePat",
"RangePat",
],
),
"Name": (),
"NameRef": (),
"Attr": ( options: [ ["value", "TokenTree"] ] ),
"TokenTree": (),
"TypeParamList": ( collections: [ ["type_params", "TypeParam" ] ]),
"TypeParam": ( traits: ["NameOwner"] ),
"WhereClause": (),
"ExprStmt": (),
"LetStmt": ( options: [
["pat", "Pat"],
["initializer", "Expr"],
]),
"Stmt": (
enum: ["ExprStmt", "LetStmt"],
),
"Block": (
options: [["expr", "Expr"]],
collections: [
["statements", "Stmt"],
]
),
"ParamList": (
collections: [
["params", "Param"]
]
),
"Param": (
options: [["pat", "Pat"]],
)
},
)