1+
2+ #if !defined (PARSE_EXPRESSION_DECLARATION_HXX)
3+ #define PARSE_EXPRESSION_DECLARATION_HXX
4+ #include " wheel_parser/config.hxx"
5+ #include " contracts_declaration.hxx"
6+ #include " wheel_parser/ast/nodes.hxx"
7+ #include < wheel_lexer/kind.hxx>
8+ #include " wheel_parser/parser_utils.hxx"
9+
10+ WHEEL_PARSER_FUNCTIONS_BEGIN_NAMESPACE
11+ using wheel_parser::ast::ExpressionNode;
12+ using wheel_parser::ast::LiteralExpression;
13+ using wheel_parser::ast::IdentifierExpression;
14+ using wheel_lexer::TokenKind;
15+
16+ PARSE_BEGIN (parse_expression_declaration, ExpressionNode)
17+ using Kind = TokenKind;
18+ auto current_token = contract.state.current_token;
19+ auto arena = &contract.arena;
20+ auto interner = &contract.interner;
21+
22+ switch (current_token.kind) {
23+ case TokenKind::INT_LITERAL:
24+ case TokenKind::FLOAT_LITERAL:
25+ case TokenKind::STRING_LITERAL:
26+ case TokenKind::RAW_STRING_LITERAL:
27+ return arena->allocate <LiteralExpression>(
28+ copy_token (*arena, current_token)
29+ );
30+
31+ case TokenKind::IDENT:
32+ return arena->allocate <IdentifierExpression>(
33+ copy_token (*arena, current_token),
34+ interner->intern (current_token.str )
35+ );
36+
37+ default :
38+ return nullptr ;
39+ }
40+
41+ PARSE_END
42+
43+
44+ WHEEL_PARSER_FUNCTIONS_END_NAMESPACE
45+
46+ #endif
0 commit comments