5642: Grammar updates r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-08-01 11:49:36 +00:00 committed by GitHub
commit cf17366df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 150 additions and 151 deletions

24
Cargo.lock generated
View File

@ -279,9 +279,9 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
[[package]]
name = "drop_bomb"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69b26e475fd29098530e709294e94e661974c851aed42512793f120fed4e199f"
checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1"
[[package]]
name = "either"
@ -1622,9 +1622,9 @@ checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
[[package]]
name = "tracing"
version = "0.1.17"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9"
checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178"
dependencies = [
"cfg-if",
"tracing-attributes",
@ -1644,9 +1644,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.11"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f"
checksum = "b2734b5a028fa697686f16c6d18c2c6a3c7e41513f9a213abb6754c4acb3c8d7"
dependencies = [
"lazy_static",
]
@ -1674,9 +1674,9 @@ dependencies = [
[[package]]
name = "tracing-subscriber"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4f5dd7095c2481b7b3cbed71c8de53085fb3542bc3c2b4c73cba43e8f11c7ba"
checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc"
dependencies = [
"ansi_term",
"chrono",
@ -1708,9 +1708,9 @@ dependencies = [
[[package]]
name = "ungrammar"
version = "0.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee12e4891ab3acc2d95d5023022ace22020247bb8a8d1ece875a443f7dab37d"
checksum = "c4e20e58a08ee1bcf8a4695cf74550cf054d6c489105f594beacb2c684210aad"
[[package]]
name = "unicode-bidi"
@ -1833,9 +1833,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "write-json"
version = "0.1.0"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b3f9a784c809a99e38d2e825907617cb03bd880d5421153bc4548e9317f59d0"
checksum = "06069a848f95fceae3e5e03c0ddc8cb78452b56654ee0c8e68f938cf790fb9e3"
[[package]]
name = "ws2_32-sys"

View File

@ -68,7 +68,7 @@ fn generate_fn_def_assist(
let fn_params_without_lifetime: Vec<_> = param_list
.params()
.filter_map(|param| match param.ty() {
Some(ast::Type::ReferenceType(ascribed_type))
Some(ast::Type::RefType(ascribed_type))
if ascribed_type.lifetime_token() == None =>
{
Some(ascribed_type.amp_token()?.text_range().end())

View File

@ -94,7 +94,7 @@ pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
.map(TypeRef::Path)
.unwrap_or(TypeRef::Error)
}
ast::Type::PointerType(inner) => {
ast::Type::PtrType(inner) => {
let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
TypeRef::RawPtr(Box::new(inner_ty), mutability)
@ -105,13 +105,13 @@ pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
ast::Type::SliceType(inner) => {
TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())))
}
ast::Type::ReferenceType(inner) => {
ast::Type::RefType(inner) => {
let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
TypeRef::Reference(Box::new(inner_ty), mutability)
}
ast::Type::InferType(_inner) => TypeRef::Placeholder,
ast::Type::FnPointerType(inner) => {
ast::Type::FnPtrType(inner) => {
let ret_ty = inner
.ret_type()
.and_then(|rt| rt.ty())

View File

@ -157,7 +157,7 @@ fn rename_to_self(
}
let first_param = params.params().next()?;
let mutable = match first_param.ty() {
Some(ast::Type::ReferenceType(rt)) => rt.mut_token().is_some(),
Some(ast::Type::RefType(rt)) => rt.mut_token().is_some(),
_ => return None, // not renaming other types
};

View File

@ -546,7 +546,7 @@ fn highlight_element(
T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
HighlightTag::Macro.into()
}
T![*] if element.parent().and_then(ast::PointerType::cast).is_some() => {
T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => {
HighlightTag::Keyword.into()
}
T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {

View File

@ -117,7 +117,7 @@ fn pointer_type(p: &mut Parser) {
};
type_no_bounds(p);
m.complete(p, POINTER_TYPE);
m.complete(p, PTR_TYPE);
}
fn array_or_slice_type(p: &mut Parser) {
@ -163,7 +163,7 @@ fn reference_type(p: &mut Parser) {
p.eat(LIFETIME);
p.eat(T![mut]);
type_no_bounds(p);
m.complete(p, REFERENCE_TYPE);
m.complete(p, REF_TYPE);
}
// test placeholder_type
@ -201,7 +201,7 @@ fn fn_pointer_type(p: &mut Parser) {
// test fn_pointer_type_with_ret
// type F = fn() -> ();
opt_fn_ret_type(p);
m.complete(p, FN_POINTER_TYPE);
m.complete(p, FN_PTR_TYPE);
}
pub(super) fn for_binder(p: &mut Parser) {

View File

@ -143,12 +143,12 @@ pub enum SyntaxKind {
TUPLE_TYPE,
NEVER_TYPE,
PATH_TYPE,
POINTER_TYPE,
PTR_TYPE,
ARRAY_TYPE,
SLICE_TYPE,
REFERENCE_TYPE,
REF_TYPE,
INFER_TYPE,
FN_POINTER_TYPE,
FN_PTR_TYPE,
FOR_TYPE,
IMPL_TRAIT_TYPE,
DYN_TRAIT_TYPE,

View File

@ -1006,10 +1006,10 @@ pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!
pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnPointerType {
pub struct FnPtrType {
pub(crate) syntax: SyntaxNode,
}
impl FnPointerType {
impl FnPtrType {
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
@ -1059,20 +1059,20 @@ pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PointerType {
pub struct PtrType {
pub(crate) syntax: SyntaxNode,
}
impl PointerType {
impl PtrType {
pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ReferenceType {
pub struct RefType {
pub(crate) syntax: SyntaxNode,
}
impl ReferenceType {
impl RefType {
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
support::token(&self.syntax, T![lifetime])
@ -1263,15 +1263,15 @@ pub enum GenericArg {
pub enum Type {
ArrayType(ArrayType),
DynTraitType(DynTraitType),
FnPointerType(FnPointerType),
FnPtrType(FnPtrType),
ForType(ForType),
ImplTraitType(ImplTraitType),
InferType(InferType),
NeverType(NeverType),
ParenType(ParenType),
PathType(PathType),
PointerType(PointerType),
ReferenceType(ReferenceType),
PtrType(PtrType),
RefType(RefType),
SliceType(SliceType),
TupleType(TupleType),
}
@ -1377,8 +1377,8 @@ impl ast::NameOwner for AssocItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ExternItem {
Fn(Fn),
Static(Static),
MacroCall(MacroCall),
Static(Static),
}
impl ast::AttrsOwner for ExternItem {}
impl ast::NameOwner for ExternItem {}
@ -2434,8 +2434,8 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl AstNode for FnPointerType {
fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE }
impl AstNode for FnPtrType {
fn can_cast(kind: SyntaxKind) -> bool { kind == FN_PTR_TYPE }
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
@ -2500,8 +2500,8 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl AstNode for PointerType {
fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
impl AstNode for PtrType {
fn can_cast(kind: SyntaxKind) -> bool { kind == PTR_TYPE }
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
@ -2511,8 +2511,8 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl AstNode for ReferenceType {
fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE }
impl AstNode for RefType {
fn can_cast(kind: SyntaxKind) -> bool { kind == REF_TYPE }
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
@ -2786,8 +2786,8 @@ fn from(node: ArrayType) -> Type { Type::ArrayType(node) }
impl From<DynTraitType> for Type {
fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) }
}
impl From<FnPointerType> for Type {
fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) }
impl From<FnPtrType> for Type {
fn from(node: FnPtrType) -> Type { Type::FnPtrType(node) }
}
impl From<ForType> for Type {
fn from(node: ForType) -> Type { Type::ForType(node) }
@ -2807,11 +2807,11 @@ fn from(node: ParenType) -> Type { Type::ParenType(node) }
impl From<PathType> for Type {
fn from(node: PathType) -> Type { Type::PathType(node) }
}
impl From<PointerType> for Type {
fn from(node: PointerType) -> Type { Type::PointerType(node) }
impl From<PtrType> for Type {
fn from(node: PtrType) -> Type { Type::PtrType(node) }
}
impl From<ReferenceType> for Type {
fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) }
impl From<RefType> for Type {
fn from(node: RefType) -> Type { Type::RefType(node) }
}
impl From<SliceType> for Type {
fn from(node: SliceType) -> Type { Type::SliceType(node) }
@ -2822,9 +2822,9 @@ fn from(node: TupleType) -> Type { Type::TupleType(node) }
impl AstNode for Type {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE
| INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE
| SLICE_TYPE | TUPLE_TYPE => true,
ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
| NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE
| TUPLE_TYPE => true,
_ => false,
}
}
@ -2832,15 +2832,15 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }),
FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }),
FN_PTR_TYPE => Type::FnPtrType(FnPtrType { syntax }),
FOR_TYPE => Type::ForType(ForType { syntax }),
IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
INFER_TYPE => Type::InferType(InferType { syntax }),
NEVER_TYPE => Type::NeverType(NeverType { syntax }),
PAREN_TYPE => Type::ParenType(ParenType { syntax }),
PATH_TYPE => Type::PathType(PathType { syntax }),
POINTER_TYPE => Type::PointerType(PointerType { syntax }),
REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }),
PTR_TYPE => Type::PtrType(PtrType { syntax }),
REF_TYPE => Type::RefType(RefType { syntax }),
SLICE_TYPE => Type::SliceType(SliceType { syntax }),
TUPLE_TYPE => Type::TupleType(TupleType { syntax }),
_ => return None,
@ -2851,15 +2851,15 @@ fn syntax(&self) -> &SyntaxNode {
match self {
Type::ArrayType(it) => &it.syntax,
Type::DynTraitType(it) => &it.syntax,
Type::FnPointerType(it) => &it.syntax,
Type::FnPtrType(it) => &it.syntax,
Type::ForType(it) => &it.syntax,
Type::ImplTraitType(it) => &it.syntax,
Type::InferType(it) => &it.syntax,
Type::NeverType(it) => &it.syntax,
Type::ParenType(it) => &it.syntax,
Type::PathType(it) => &it.syntax,
Type::PointerType(it) => &it.syntax,
Type::ReferenceType(it) => &it.syntax,
Type::PtrType(it) => &it.syntax,
Type::RefType(it) => &it.syntax,
Type::SliceType(it) => &it.syntax,
Type::TupleType(it) => &it.syntax,
}
@ -3332,24 +3332,24 @@ fn syntax(&self) -> &SyntaxNode {
impl From<Fn> for ExternItem {
fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
}
impl From<Static> for ExternItem {
fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
}
impl From<MacroCall> for ExternItem {
fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) }
}
impl From<Static> for ExternItem {
fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
}
impl AstNode for ExternItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN | STATIC | MACRO_CALL => true,
FN | MACRO_CALL | STATIC => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
FN => ExternItem::Fn(Fn { syntax }),
STATIC => ExternItem::Static(Static { syntax }),
MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }),
STATIC => ExternItem::Static(Static { syntax }),
_ => return None,
};
Some(res)
@ -3357,8 +3357,8 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
fn syntax(&self) -> &SyntaxNode {
match self {
ExternItem::Fn(it) => &it.syntax,
ExternItem::Static(it) => &it.syntax,
ExternItem::MacroCall(it) => &it.syntax,
ExternItem::Static(it) => &it.syntax,
}
}
}
@ -3925,7 +3925,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl std::fmt::Display for FnPointerType {
impl std::fmt::Display for FnPtrType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
@ -3955,12 +3955,12 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl std::fmt::Display for PointerType {
impl std::fmt::Display for PtrType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl std::fmt::Display for ReferenceType {
impl std::fmt::Display for RefType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}

View File

@ -39,7 +39,7 @@ SOURCE_FILE@0..389
IDENT@39..46 "builder"
COLON@46..47
WHITESPACE@47..48
REFERENCE_TYPE@48..54
REF_TYPE@48..54
AMP@48..49
MUT_KW@49..52
WHITESPACE@52..53
@ -56,7 +56,7 @@ SOURCE_FILE@0..389
IDENT@56..62 "tokens"
COLON@62..63
WHITESPACE@63..64
REFERENCE_TYPE@64..72
REF_TYPE@64..72
AMP@64..65
SLICE_TYPE@65..72
L_BRACK@65..66
@ -126,7 +126,7 @@ SOURCE_FILE@0..389
IDENT@144..147 "idx"
COLON@147..148
WHITESPACE@148..149
REFERENCE_TYPE@149..159
REF_TYPE@149..159
AMP@149..150
MUT_KW@150..153
WHITESPACE@153..154

View File

@ -15,7 +15,7 @@ SOURCE_FILE@0..239
LIFETIME@18..20 "\'a"
R_ANGLE@20..21 ">"
WHITESPACE@21..22 " "
REFERENCE_TYPE@22..29
REF_TYPE@22..29
AMP@22..23 "&"
LIFETIME@23..25 "\'a"
WHITESPACE@25..26 " "
@ -44,7 +44,7 @@ SOURCE_FILE@0..239
WHITESPACE@52..53 " "
TUPLE_TYPE@53..63
L_PAREN@53..54 "("
REFERENCE_TYPE@54..61
REF_TYPE@54..61
AMP@54..55 "&"
LIFETIME@55..57 "\'a"
WHITESPACE@57..58 " "
@ -107,12 +107,12 @@ SOURCE_FILE@0..239
LIFETIME@124..126 "\'b"
R_ANGLE@126..127 ">"
WHITESPACE@127..128 " "
FN_POINTER_TYPE@128..148
FN_PTR_TYPE@128..148
FN_KW@128..130 "fn"
PARAM_LIST@130..148
L_PAREN@130..131 "("
PARAM@131..138
REFERENCE_TYPE@131..138
REF_TYPE@131..138
AMP@131..132 "&"
LIFETIME@132..134 "\'a"
WHITESPACE@134..135 " "
@ -124,7 +124,7 @@ SOURCE_FILE@0..239
COMMA@138..139 ","
WHITESPACE@139..140 " "
PARAM@140..147
REFERENCE_TYPE@140..147
REF_TYPE@140..147
AMP@140..141 "&"
LIFETIME@141..143 "\'b"
WHITESPACE@143..144 " "
@ -178,12 +178,12 @@ SOURCE_FILE@0..239
LIFETIME@200..202 "\'c"
R_ANGLE@202..203 ">"
WHITESPACE@203..204 " "
FN_POINTER_TYPE@204..227
FN_PTR_TYPE@204..227
FN_KW@204..206 "fn"
PARAM_LIST@206..227
L_PAREN@206..207 "("
PARAM@207..212
REFERENCE_TYPE@207..212
REF_TYPE@207..212
AMP@207..208 "&"
LIFETIME@208..210 "\'a"
WHITESPACE@210..211 " "
@ -195,7 +195,7 @@ SOURCE_FILE@0..239
COMMA@212..213 ","
WHITESPACE@213..214 " "
PARAM@214..219
REFERENCE_TYPE@214..219
REF_TYPE@214..219
AMP@214..215 "&"
LIFETIME@215..217 "\'b"
WHITESPACE@217..218 " "
@ -207,7 +207,7 @@ SOURCE_FILE@0..239
COMMA@219..220 ","
WHITESPACE@220..221 " "
PARAM@221..226
REFERENCE_TYPE@221..226
REF_TYPE@221..226
AMP@221..222 "&"
LIFETIME@222..224 "\'c"
WHITESPACE@224..225 " "

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..14
WHITESPACE@6..7 " "
EQ@7..8 "="
WHITESPACE@8..9 " "
POINTER_TYPE@9..12
PTR_TYPE@9..12
STAR@9..10 "*"
TUPLE_TYPE@10..12
L_PAREN@10..11 "("

View File

@ -42,7 +42,7 @@ SOURCE_FILE@0..54
PARAM_LIST@40..49
L_PAREN@40..41 "("
PARAM@41..48
REFERENCE_TYPE@41..48
REF_TYPE@41..48
AMP@41..42 "&"
LIFETIME@42..44 "\'a"
WHITESPACE@44..45 " "

View File

@ -31,7 +31,7 @@ SOURCE_FILE@0..39
COMMA@19..20 ","
WHITESPACE@20..21 " "
PARAM@21..25
REFERENCE_TYPE@21..25
REF_TYPE@21..25
AMP@21..22 "&"
PATH_TYPE@22..25
PATH@22..25
@ -41,7 +41,7 @@ SOURCE_FILE@0..39
COMMA@25..26 ","
WHITESPACE@26..27 " "
PARAM@27..31
REFERENCE_TYPE@27..31
REF_TYPE@27..31
AMP@27..28 "&"
PATH_TYPE@28..31
PATH@28..31

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..36
WHITESPACE@6..7 " "
EQ@7..8 "="
WHITESPACE@8..9 " "
POINTER_TYPE@9..16
PTR_TYPE@9..16
STAR@9..10 "*"
MUT_KW@10..13 "mut"
WHITESPACE@13..14 " "
@ -24,7 +24,7 @@ SOURCE_FILE@0..36
WHITESPACE@24..25 " "
EQ@25..26 "="
WHITESPACE@26..27 " "
POINTER_TYPE@27..34
PTR_TYPE@27..34
STAR@27..28 "*"
MUT_KW@28..31 "mut"
WHITESPACE@31..32 " "

View File

@ -22,7 +22,7 @@ SOURCE_FILE@0..69
SELF_KW@18..22 "self"
COLON@22..23 ":"
WHITESPACE@23..24 " "
REFERENCE_TYPE@24..29
REF_TYPE@24..29
AMP@24..25 "&"
PATH_TYPE@25..29
PATH@25..29

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..113
WHITESPACE@6..7 " "
EQ@7..8 "="
WHITESPACE@8..9 " "
FN_POINTER_TYPE@9..13
FN_PTR_TYPE@9..13
FN_KW@9..11 "fn"
PARAM_LIST@11..13
L_PAREN@11..12 "("
@ -22,7 +22,7 @@ SOURCE_FILE@0..113
WHITESPACE@21..22 " "
EQ@22..23 "="
WHITESPACE@23..24 " "
FN_POINTER_TYPE@24..35
FN_PTR_TYPE@24..35
UNSAFE_KW@24..30 "unsafe"
WHITESPACE@30..31 " "
FN_KW@31..33 "fn"
@ -39,7 +39,7 @@ SOURCE_FILE@0..113
WHITESPACE@43..44 " "
EQ@44..45 "="
WHITESPACE@45..46 " "
FN_POINTER_TYPE@46..68
FN_PTR_TYPE@46..68
UNSAFE_KW@46..52 "unsafe"
WHITESPACE@52..53 " "
ABI@53..63
@ -61,7 +61,7 @@ SOURCE_FILE@0..113
WHITESPACE@76..77 " "
EQ@77..78 "="
WHITESPACE@78..79 " "
FN_POINTER_TYPE@79..111
FN_PTR_TYPE@79..111
ABI@79..89
EXTERN_KW@79..85 "extern"
WHITESPACE@85..86 " "

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..54
WHITESPACE@6..7 " "
EQ@7..8 "="
WHITESPACE@8..9 " "
REFERENCE_TYPE@9..12
REF_TYPE@9..12
AMP@9..10 "&"
TUPLE_TYPE@10..12
L_PAREN@10..11 "("
@ -22,7 +22,7 @@ SOURCE_FILE@0..54
WHITESPACE@20..21 " "
EQ@21..22 "="
WHITESPACE@22..23 " "
REFERENCE_TYPE@23..34
REF_TYPE@23..34
AMP@23..24 "&"
LIFETIME@24..31 "\'static"
WHITESPACE@31..32 " "
@ -39,7 +39,7 @@ SOURCE_FILE@0..54
WHITESPACE@42..43 " "
EQ@43..44 "="
WHITESPACE@44..45 " "
REFERENCE_TYPE@45..52
REF_TYPE@45..52
AMP@45..46 "&"
MUT_KW@46..49 "mut"
WHITESPACE@49..50 " "

View File

@ -21,7 +21,7 @@ SOURCE_FILE@0..35
PARAM_LIST@15..29
L_PAREN@15..16 "("
PARAM@16..28
REFERENCE_TYPE@16..28
REF_TYPE@16..28
AMP@16..17 "&"
MUT_KW@17..20 "mut"
WHITESPACE@20..21 " "

View File

@ -15,7 +15,7 @@ SOURCE_FILE@0..121
LIFETIME@13..15 "\'a"
R_ANGLE@15..16 ">"
WHITESPACE@16..17 " "
FN_POINTER_TYPE@17..27
FN_PTR_TYPE@17..27
FN_KW@17..19 "fn"
PARAM_LIST@19..21
L_PAREN@19..20 "("
@ -45,7 +45,7 @@ SOURCE_FILE@0..121
LIFETIME@42..44 "\'a"
R_ANGLE@44..45 ">"
WHITESPACE@45..46 " "
FN_POINTER_TYPE@46..80
FN_PTR_TYPE@46..80
UNSAFE_KW@46..52 "unsafe"
WHITESPACE@52..53 " "
ABI@53..63
@ -57,7 +57,7 @@ SOURCE_FILE@0..121
PARAM_LIST@66..74
L_PAREN@66..67 "("
PARAM@67..73
REFERENCE_TYPE@67..73
REF_TYPE@67..73
AMP@67..68 "&"
LIFETIME@68..70 "\'a"
WHITESPACE@70..71 " "
@ -98,7 +98,7 @@ SOURCE_FILE@0..121
GENERIC_ARG_LIST@110..119
L_ANGLE@110..111 "<"
TYPE_ARG@111..118
REFERENCE_TYPE@111..118
REF_TYPE@111..118
AMP@111..112 "&"
LIFETIME@112..114 "\'a"
WHITESPACE@114..115 " "

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..21
WHITESPACE@6..7 " "
EQ@7..8 "="
WHITESPACE@8..9 " "
FN_POINTER_TYPE@9..19
FN_PTR_TYPE@9..19
FN_KW@9..11 "fn"
PARAM_LIST@11..13
L_PAREN@11..12 "("

View File

@ -47,7 +47,7 @@ SOURCE_FILE@0..64
UNDERSCORE@50..51 "_"
COLON@51..52 ":"
WHITESPACE@52..53 " "
REFERENCE_TYPE@53..58
REF_TYPE@53..58
AMP@53..54 "&"
LIFETIME@54..56 "\'a"
WHITESPACE@56..57 " "

View File

@ -21,7 +21,7 @@ SOURCE_FILE@0..57
IDENT@23..29 "format"
COLON@29..30 ":"
WHITESPACE@30..31 " "
POINTER_TYPE@31..40
PTR_TYPE@31..40
STAR@31..32 "*"
CONST_KW@32..37 "const"
WHITESPACE@37..38 " "

View File

@ -27,7 +27,7 @@ SOURCE_FILE@0..43
WHITESPACE@25..26 " "
AS_KW@26..28 "as"
WHITESPACE@28..29 " "
POINTER_TYPE@29..39
PTR_TYPE@29..39
STAR@29..30 "*"
CONST_KW@30..35 "const"
WHITESPACE@35..36 " "

View File

@ -6,7 +6,7 @@ SOURCE_FILE@0..40
IDENT@6..7 "A"
COLON@7..8 ":"
WHITESPACE@8..9 " "
REFERENCE_TYPE@9..15
REF_TYPE@9..15
AMP@9..10 "&"
SLICE_TYPE@10..15
L_BRACK@10..11 "["

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..55
WHITESPACE@8..9 " "
EQ@9..10 "="
WHITESPACE@10..11 " "
FN_POINTER_TYPE@11..23
FN_PTR_TYPE@11..23
FN_KW@11..13 "fn"
PARAM_LIST@13..23
L_PAREN@13..14 "("
@ -33,7 +33,7 @@ SOURCE_FILE@0..55
WHITESPACE@33..34 " "
EQ@34..35 "="
WHITESPACE@35..36 " "
FN_POINTER_TYPE@36..53
FN_PTR_TYPE@36..53
FN_KW@36..38 "fn"
PARAM_LIST@38..53
L_PAREN@38..39 "("

View File

@ -7,7 +7,7 @@ SOURCE_FILE@0..23
WHITESPACE@8..9 " "
EQ@9..10 "="
WHITESPACE@10..11 " "
FN_POINTER_TYPE@11..21
FN_PTR_TYPE@11..21
FN_KW@11..13 "fn"
PARAM_LIST@13..21
L_PAREN@13..14 "("

View File

@ -99,7 +99,7 @@ SOURCE_FILE@0..1598
IDENT@117..121 "addr"
COLON@121..122 ":"
WHITESPACE@122..123 " "
POINTER_TYPE@123..138
PTR_TYPE@123..138
STAR@123..124 "*"
CONST_KW@124..129 "const"
WHITESPACE@129..130 " "
@ -164,7 +164,7 @@ SOURCE_FILE@0..1598
IDENT@204..211 "address"
COLON@211..212 ":"
WHITESPACE@212..213 " "
POINTER_TYPE@213..228
PTR_TYPE@213..228
STAR@213..214 "*"
CONST_KW@214..219 "const"
WHITESPACE@219..220 " "
@ -278,7 +278,7 @@ SOURCE_FILE@0..1598
IDENT@382..389 "address"
COLON@389..390 ":"
WHITESPACE@390..391 " "
POINTER_TYPE@391..404
PTR_TYPE@391..404
STAR@391..392 "*"
MUT_KW@392..395 "mut"
WHITESPACE@395..396 " "
@ -295,7 +295,7 @@ SOURCE_FILE@0..1598
IDENT@429..440 "address_len"
COLON@440..441 ":"
WHITESPACE@441..442 " "
POINTER_TYPE@442..456
PTR_TYPE@442..456
STAR@442..443 "*"
MUT_KW@443..446 "mut"
WHITESPACE@446..447 " "
@ -375,7 +375,7 @@ SOURCE_FILE@0..1598
IDENT@609..615 "optval"
COLON@615..616 ":"
WHITESPACE@616..617 " "
POINTER_TYPE@617..630
PTR_TYPE@617..630
STAR@617..618 "*"
MUT_KW@618..621 "mut"
WHITESPACE@621..622 " "
@ -393,7 +393,7 @@ SOURCE_FILE@0..1598
IDENT@654..660 "optlen"
COLON@660..661 ":"
WHITESPACE@661..662 " "
POINTER_TYPE@662..678
PTR_TYPE@662..678
STAR@662..663 "*"
MUT_KW@663..666 "mut"
WHITESPACE@666..667 " "
@ -474,7 +474,7 @@ SOURCE_FILE@0..1598
IDENT@784..789 "value"
COLON@789..790 ":"
WHITESPACE@790..791 " "
POINTER_TYPE@791..806
PTR_TYPE@791..806
STAR@791..792 "*"
CONST_KW@792..797 "const"
WHITESPACE@797..798 " "
@ -540,7 +540,7 @@ SOURCE_FILE@0..1598
IDENT@905..912 "address"
COLON@912..913 ":"
WHITESPACE@913..914 " "
POINTER_TYPE@914..927
PTR_TYPE@914..927
STAR@914..915 "*"
MUT_KW@915..918 "mut"
WHITESPACE@918..919 " "
@ -557,7 +557,7 @@ SOURCE_FILE@0..1598
IDENT@952..963 "address_len"
COLON@963..964 ":"
WHITESPACE@964..965 " "
POINTER_TYPE@965..979
PTR_TYPE@965..979
STAR@965..966 "*"
MUT_KW@966..969 "mut"
WHITESPACE@969..970 " "
@ -609,7 +609,7 @@ SOURCE_FILE@0..1598
IDENT@1028..1031 "buf"
COLON@1031..1032 ":"
WHITESPACE@1032..1033 " "
POINTER_TYPE@1033..1048
PTR_TYPE@1033..1048
STAR@1033..1034 "*"
CONST_KW@1034..1039 "const"
WHITESPACE@1039..1040 " "
@ -655,7 +655,7 @@ SOURCE_FILE@0..1598
IDENT@1099..1103 "addr"
COLON@1103..1104 ":"
WHITESPACE@1104..1105 " "
POINTER_TYPE@1105..1120
PTR_TYPE@1105..1120
STAR@1105..1106 "*"
CONST_KW@1106..1111 "const"
WHITESPACE@1111..1112 " "
@ -720,7 +720,7 @@ SOURCE_FILE@0..1598
IDENT@1207..1210 "buf"
COLON@1210..1211 ":"
WHITESPACE@1211..1212 " "
POINTER_TYPE@1212..1227
PTR_TYPE@1212..1227
STAR@1212..1213 "*"
CONST_KW@1213..1218 "const"
WHITESPACE@1218..1219 " "
@ -801,7 +801,7 @@ SOURCE_FILE@0..1598
IDENT@1327..1330 "buf"
COLON@1330..1331 ":"
WHITESPACE@1331..1332 " "
POINTER_TYPE@1332..1345
PTR_TYPE@1332..1345
STAR@1332..1333 "*"
MUT_KW@1333..1336 "mut"
WHITESPACE@1336..1337 " "
@ -847,7 +847,7 @@ SOURCE_FILE@0..1598
IDENT@1398..1402 "addr"
COLON@1402..1403 ":"
WHITESPACE@1403..1404 " "
POINTER_TYPE@1404..1419
PTR_TYPE@1404..1419
STAR@1404..1405 "*"
MUT_KW@1405..1408 "mut"
WHITESPACE@1408..1409 " "
@ -865,7 +865,7 @@ SOURCE_FILE@0..1598
IDENT@1441..1448 "addrlen"
COLON@1448..1449 ":"
WHITESPACE@1449..1450 " "
POINTER_TYPE@1450..1466
PTR_TYPE@1450..1466
STAR@1450..1451 "*"
MUT_KW@1451..1454 "mut"
WHITESPACE@1454..1455 " "
@ -918,7 +918,7 @@ SOURCE_FILE@0..1598
IDENT@1515..1518 "buf"
COLON@1518..1519 ":"
WHITESPACE@1519..1520 " "
POINTER_TYPE@1520..1533
PTR_TYPE@1520..1533
STAR@1520..1521 "*"
MUT_KW@1521..1524 "mut"
WHITESPACE@1524..1525 " "

View File

@ -242,7 +242,7 @@ SOURCE_FILE@0..3813
IDENT@649..650 "x"
COLON@650..651 ":"
WHITESPACE@651..652 " "
REFERENCE_TYPE@652..663
REF_TYPE@652..663
AMP@652..653 "&"
PATH_TYPE@653..663
PATH@653..663
@ -1579,7 +1579,7 @@ SOURCE_FILE@0..3813
IDENT@2873..2878 "union"
COLON@2878..2879 ":"
WHITESPACE@2879..2880 " "
REFERENCE_TYPE@2880..2901
REF_TYPE@2880..2901
AMP@2880..2881 "&"
LIFETIME@2881..2887 "\'union"
WHITESPACE@2887..2888 " "

View File

@ -96,7 +96,7 @@ SOURCE_FILE@0..519
IDENT@87..93 "format"
COLON@93..94 ":"
WHITESPACE@94..95 " "
POINTER_TYPE@95..104
PTR_TYPE@95..104
STAR@95..96 "*"
CONST_KW@96..101 "const"
WHITESPACE@101..102 " "
@ -163,7 +163,7 @@ SOURCE_FILE@0..519
R_BRACK@152..153 "]"
WHITESPACE@153..154 " "
PARAM@154..166
REFERENCE_TYPE@154..166
REF_TYPE@154..166
AMP@154..155 "&"
MUT_KW@155..158 "mut"
WHITESPACE@158..159 " "

View File

@ -102,7 +102,7 @@ SOURCE_FILE@0..88
PARAM_LIST@76..83
L_PAREN@76..77 "("
PARAM@77..82
REFERENCE_TYPE@77..82
REF_TYPE@77..82
AMP@77..78 "&"
PATH_TYPE@78..82
PATH@78..82

View File

@ -140,9 +140,9 @@ SOURCE_FILE@0..170
IDENT@121..122 "a"
COLON@122..123 ":"
WHITESPACE@123..124 " "
REFERENCE_TYPE@124..131
REF_TYPE@124..131
AMP@124..125 "&"
REFERENCE_TYPE@125..131
REF_TYPE@125..131
AMP@125..126 "&"
PATH_TYPE@126..131
PATH@126..131

View File

@ -20,7 +20,7 @@ SOURCE_FILE@0..126
UNDERSCORE@22..23 "_"
COLON@23..24 ":"
WHITESPACE@24..25 " "
POINTER_TYPE@25..32
PTR_TYPE@25..32
STAR@25..26 "*"
MUT_KW@26..29 "mut"
WHITESPACE@29..30 " "
@ -49,7 +49,7 @@ SOURCE_FILE@0..126
UNDERSCORE@50..51 "_"
COLON@51..52 ":"
WHITESPACE@52..53 " "
POINTER_TYPE@53..60
PTR_TYPE@53..60
STAR@53..54 "*"
MUT_KW@54..57 "mut"
WHITESPACE@57..58 " "
@ -81,7 +81,7 @@ SOURCE_FILE@0..126
UNDERSCORE@80..81 "_"
COLON@81..82 ":"
WHITESPACE@82..83 " "
POINTER_TYPE@83..90
PTR_TYPE@83..90
STAR@83..84 "*"
MUT_KW@84..87 "mut"
WHITESPACE@87..88 " "

View File

@ -143,9 +143,9 @@ SOURCE_FILE@0..137
IDENT@120..121 "a"
COLON@121..122 ":"
WHITESPACE@122..123 " "
REFERENCE_TYPE@123..130
REF_TYPE@123..130
AMP@123..124 "&"
REFERENCE_TYPE@124..130
REF_TYPE@124..130
AMP@124..125 "&"
PATH_TYPE@125..130
PATH@125..130

View File

@ -42,7 +42,7 @@ SOURCE_FILE@0..374
PARAM_LIST@41..50
L_PAREN@41..42 "("
PARAM@42..49
REFERENCE_TYPE@42..49
REF_TYPE@42..49
AMP@42..43 "&"
LIFETIME@43..45 "\'a"
WHITESPACE@45..46 " "
@ -85,7 +85,7 @@ SOURCE_FILE@0..374
LIFETIME@86..88 "\'a"
R_ANGLE@88..89 ">"
WHITESPACE@89..90 " "
REFERENCE_TYPE@90..95
REF_TYPE@90..95
AMP@90..91 "&"
LIFETIME@91..93 "\'a"
WHITESPACE@93..94 " "
@ -138,7 +138,7 @@ SOURCE_FILE@0..374
WHITESPACE@144..145 " "
PAREN_TYPE@145..152
L_PAREN@145..146 "("
REFERENCE_TYPE@146..151
REF_TYPE@146..151
AMP@146..147 "&"
LIFETIME@147..149 "\'a"
WHITESPACE@149..150 " "
@ -160,7 +160,7 @@ SOURCE_FILE@0..374
PARAM_LIST@156..165
L_PAREN@156..157 "("
PARAM@157..164
REFERENCE_TYPE@157..164
REF_TYPE@157..164
AMP@157..158 "&"
LIFETIME@158..160 "\'a"
WHITESPACE@160..161 " "
@ -205,7 +205,7 @@ SOURCE_FILE@0..374
WHITESPACE@206..207 " "
SLICE_TYPE@207..214
L_BRACK@207..208 "["
REFERENCE_TYPE@208..213
REF_TYPE@208..213
AMP@208..209 "&"
LIFETIME@209..211 "\'a"
WHITESPACE@211..212 " "
@ -250,7 +250,7 @@ SOURCE_FILE@0..374
IDENT@240..242 "_t"
COLON@242..243 ":"
WHITESPACE@243..244 " "
REFERENCE_TYPE@244..246
REF_TYPE@244..246
AMP@244..245 "&"
PATH_TYPE@245..246
PATH@245..246
@ -275,7 +275,7 @@ SOURCE_FILE@0..374
PATH@266..280
PATH_SEGMENT@266..280
L_ANGLE@266..267 "<"
REFERENCE_TYPE@267..272
REF_TYPE@267..272
AMP@267..268 "&"
LIFETIME@268..270 "\'a"
WHITESPACE@270..271 " "
@ -347,12 +347,12 @@ SOURCE_FILE@0..374
LIFETIME@342..344 "\'b"
R_ANGLE@344..345 ">"
WHITESPACE@345..346 " "
FN_POINTER_TYPE@346..362
FN_PTR_TYPE@346..362
FN_KW@346..348 "fn"
PARAM_LIST@348..362
L_PAREN@348..349 "("
PARAM@349..354
REFERENCE_TYPE@349..354
REF_TYPE@349..354
AMP@349..350 "&"
LIFETIME@350..352 "\'a"
WHITESPACE@352..353 " "
@ -364,7 +364,7 @@ SOURCE_FILE@0..374
COMMA@354..355 ","
WHITESPACE@355..356 " "
PARAM@356..361
REFERENCE_TYPE@356..361
REF_TYPE@356..361
AMP@356..357 "&"
LIFETIME@357..359 "\'b"
WHITESPACE@359..360 " "

View File

@ -15,6 +15,6 @@ flate2 = "1.0"
pico-args = "0.3.1"
proc-macro2 = "1.0.8"
quote = "1.0.2"
ungrammar = "0.1.0"
ungrammar = "1.1.1"
walkdir = "2.3.1"
write-json = "0.1.0"

View File

@ -113,12 +113,12 @@ pub(crate) struct KindsSrc<'a> {
"TUPLE_TYPE",
"NEVER_TYPE",
"PATH_TYPE",
"POINTER_TYPE",
"PTR_TYPE",
"ARRAY_TYPE",
"SLICE_TYPE",
"REFERENCE_TYPE",
"REF_TYPE",
"INFER_TYPE",
"FN_POINTER_TYPE",
"FN_PTR_TYPE",
"FOR_TYPE",
"IMPL_TRAIT_TYPE",
"DYN_TRAIT_TYPE",

View File

@ -10,7 +10,7 @@
use proc_macro2::{Punct, Spacing};
use quote::{format_ident, quote};
use ungrammar::{Grammar, Rule};
use ungrammar::{rust_grammar, Grammar, Rule};
use crate::{
ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC},
@ -19,9 +19,7 @@
};
pub fn generate_syntax(mode: Mode) -> Result<()> {
let grammar = include_str!("rust.ungram")
.parse::<Grammar>()
.unwrap_or_else(|err| panic!("\n \x1b[91merror\x1b[0m: {}\n", err));
let grammar = rust_grammar();
let ast = lower(&grammar);
let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS);
@ -538,6 +536,7 @@ fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option<Vec<String>> {
for alternative in alternatives {
match alternative {
Rule::Node(it) => variants.push(grammar[*it].name.clone()),
Rule::Token(it) if grammar[*it].name == ";" => (),
_ => return None,
}
}
@ -591,8 +590,8 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, label: Option<&String>, r
| "index"
| "base"
| "value"
| "target_type"
| "target_trait"
| "trait"
| "self_ty"
);
if manually_implemented {
return;