Joos1W Compiler Framework
All Classes Functions Typedefs Pages
Joos1W.cc
1 #include "grammar/Joos1WGrammar.h"
2 #include "parsetree/ParseTree.h"
3 
4 using Node = parsetree::Node;
5 using Operator = parsetree::Operator;
6 using Literal = parsetree::Literal;
7 using Identifier = parsetree::Identifier;
8 using Modifier = parsetree::Modifier;
9 using BasicType = parsetree::BasicType;
10 
11 Node* Joos1WLexer::make_poison(YYLTYPE& loc) {
12  void* bytes = alloc.allocate_bytes(sizeof(Node));
13  return new(bytes) Node(make_range(loc), Node::Type::Poison);
14 }
15 
16 Node* Joos1WLexer::make_operator(YYLTYPE& loc, Operator::Type type) {
17  void* bytes = alloc.allocate_bytes(sizeof(Operator));
18  return new(bytes) Operator(make_range(loc), type);
19 }
20 
21 Node* Joos1WLexer::make_literal(YYLTYPE& loc, Literal::Type type,
22  char const* value) {
23  void* bytes = alloc.allocate_bytes(sizeof(Literal));
24  return new(bytes) Literal(make_range(loc), alloc, type, value);
25 }
26 
27 Node* Joos1WLexer::make_identifier(YYLTYPE& loc, char const* name) {
28  void* bytes = alloc.allocate_bytes(sizeof(Identifier));
29  return new(bytes) Identifier(make_range(loc), alloc, name);
30 }
31 
32 Node* Joos1WLexer::make_modifier(YYLTYPE& loc, Modifier::Type type) {
33  void* bytes = alloc.allocate_bytes(sizeof(Modifier));
34  return new(bytes) Modifier(make_range(loc), type);
35 }
36 
37 Node* Joos1WLexer::make_basic_type(YYLTYPE& loc, BasicType::Type type) {
38  void* bytes = alloc.allocate_bytes(sizeof(BasicType));
39  return new(bytes) BasicType(make_range(loc), type);
40 }