Skip to content

Commit 9fa56e2

Browse files
committed
(parser) fix: remove unexistant keywords
1 parent 7a95098 commit 9fa56e2

File tree

5 files changed

+7
-40
lines changed

5 files changed

+7
-40
lines changed

src/lexer/types/keywords.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ impl_keywords!(
6868
Int Type "int",
6969
Long Type "long",
7070
Null Literal "NULL",
71-
Nullptr Literal "nullptr",
7271
Register Storage "register",
7372
Restrict Storage "restrict",
7473
Return Control "return",
@@ -82,8 +81,6 @@ impl_keywords!(
8281
ThreadLocal Storage "thread_local",
8382
True Literal "true",
8483
Typedef Storage "typedef",
85-
Typeof Operator "typeof",
86-
TypeofUnqual Operator "typeof_unqual",
8784
Union Type "union",
8885
Unsigned Type "unsigned",
8986
Void Type "void",

src/parser/keyword/functions.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,13 @@ pub enum FunctionKeyword {
1717
///
1818
/// Yields the size in bytes of the object representation of the argument
1919
/// (the argument is of type type).
20-
// TODO: works without parens
20+
// TODO: works without parents
2121
Sizeof,
2222
/// Static assert
2323
///
2424
/// The constant expression is evaluated at compile time and compared to
2525
/// zero.
2626
StaticAssert,
27-
/// Type of
28-
///
29-
/// Returns the type of a variable, *with* the qualifiers
30-
///
31-
/// # Examples
32-
///
33-
/// `typeof(const int)` is `const int`
34-
///
35-
/// ```c
36-
/// static long int a;
37-
/// typeof(a) b = 1; // b is of type `static long int`
38-
/// ```
39-
Typeof,
40-
/// Type of unqualified
41-
///
42-
/// Returns the type of a variable, *without* the qualifiers
43-
///
44-
/// # Examples
45-
///
46-
/// `typeof(const int)` is `int`
47-
///
48-
/// ```c
49-
/// static long int a;
50-
/// typeof(a) b = 1; // b is of type `long int`
51-
/// ```
52-
TypeofUnqual,
5327
}
5428

5529
impl PushInNode for FunctionKeyword {
@@ -68,7 +42,5 @@ display!(
6842
Self::Alignof => "alignof".fmt(f),
6943
Self::Sizeof => "sizeof".fmt(f),
7044
Self::StaticAssert => "static_assert".fmt(f),
71-
Self::Typeof => "typeof".fmt(f),
72-
Self::TypeofUnqual => "typeof_unqual".fmt(f),
7345
}
7446
);

src/parser/keyword/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn handle_keyword(
4343
KeywordParsing::CtrlFlow(_)
4444
| KeywordParsing::False
4545
| KeywordParsing::Func(_)
46-
| KeywordParsing::Nullptr
46+
| KeywordParsing::Null
4747
| KeywordParsing::True => AstPushContext::None,
4848
};
4949
if current.can_push_leaf_with_ctx(ast_push_ctx) {

src/parser/keyword/sort.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub enum KeywordParsing {
104104
/// Function keyword: `sizeof`, `static_assert`, ...
105105
Func(Func),
106106
/// `NULL` constant
107-
Nullptr,
107+
Null,
108108
/// Keywords that need to be pushed in an existing control flow block
109109
Pushable(PushableKeyword),
110110
/// Boolean constant `true`
@@ -117,7 +117,7 @@ impl PushInNode for KeywordParsing {
117117
Self::Func(func) => func.push_in_node(node),
118118
Self::Attr(attr) => attr.push_in_node(node),
119119
Self::CtrlFlow(ctrl) => ctrl.push_in_node(node),
120-
Self::Nullptr => node.push_block_as_leaf(Ast::Leaf(Literal::Nullptr)),
120+
Self::Null => node.push_block_as_leaf(Ast::Leaf(Literal::Null)),
121121
Self::True => node.push_block_as_leaf(Ast::Leaf(Literal::ConstantBool(true))),
122122
Self::False => node.push_block_as_leaf(Ast::Leaf(Literal::ConstantBool(false))),
123123
Self::Pushable(pushable) => pushable.push_in_node(node),
@@ -132,11 +132,9 @@ impl TryFrom<(Keyword, Context)> for KeywordParsing {
132132
// constants
133133
Keyword::True => Self::True,
134134
Keyword::False => Self::False,
135-
Keyword::Null | Keyword::Nullptr => Self::Nullptr,
135+
Keyword::Null => Self::Null,
136136
// functions
137137
Keyword::Sizeof => Self::Func(Func::Sizeof),
138-
Keyword::Typeof => Self::Func(Func::Typeof),
139-
Keyword::TypeofUnqual => Self::Func(Func::TypeofUnqual),
140138
Keyword::Alignof | Keyword::UAlignof => Self::Func(Func::Alignof),
141139
Keyword::StaticAssert | Keyword::UStaticAssert => Self::Func(Func::StaticAssert),
142140
// pushable

src/parser/literal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum Literal {
3434
/// Boolean constant: `true` or `false`
3535
ConstantBool(bool),
3636
/// `NULL` constant
37-
Nullptr,
37+
Null,
3838
/// Number constant
3939
Number(Number),
4040
/// String constant
@@ -46,7 +46,7 @@ display!(
4646
self,
4747
f,
4848
match self {
49-
Self::Nullptr => "NULL".fmt(f),
49+
Self::Null => "NULL".fmt(f),
5050
Self::Char(val) => write!(f, "'{val}'"),
5151
Self::Str(val) => write!(f, "\"{val}\""),
5252
Self::Number(val) => val.fmt(f),

0 commit comments

Comments
 (0)