summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/parse/tiger-factory.hxx
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/parse/tiger-factory.hxx
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/parse/tiger-factory.hxx')
-rw-r--r--tiger-compiler/src/parse/tiger-factory.hxx272
1 files changed, 272 insertions, 0 deletions
diff --git a/tiger-compiler/src/parse/tiger-factory.hxx b/tiger-compiler/src/parse/tiger-factory.hxx
new file mode 100644
index 0000000..39d8531
--- /dev/null
+++ b/tiger-compiler/src/parse/tiger-factory.hxx
@@ -0,0 +1,272 @@
+#pragma once
+#include <parse/tiger-factory.hh>
+
+namespace parse
+{
+ inline ast::IntExp* make_IntExp(const location& location, int num)
+ {
+ return new ast::IntExp(location, num);
+ }
+
+ inline ast::StringExp* make_StringExp(const location& location,
+ std::string string)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of StringExp).
+ return new ast::StringExp(location, string);
+ }
+
+ inline ast::ObjectExp* make_ObjectExp(const location& location,
+ ast::NameTy* type_name)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of Object).
+ return new ast::ObjectExp(location, type_name);
+ }
+
+ inline ast::CallExp* make_CallExp(const location& location,
+ misc::symbol name,
+ ast::exps_type* args)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of CallExp).
+ return new ast::CallExp(location, name, args);
+ }
+
+ inline ast::MethodCallExp* make_MethodCallExp(const location& location,
+ misc::symbol name,
+ ast::exps_type* args,
+ ast::Var* object)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of MethodCallExp).
+ return new ast::MethodCallExp(location, name, args, object);
+ }
+
+ inline ast::RecordExp* make_RecordExp(const location& location,
+ ast::NameTy* type_name,
+ ast::fieldinits_type* fields)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of RecordExp).
+ return new ast::RecordExp(location, type_name, fields);
+ }
+
+ inline ast::ArrayExp* make_ArrayExp(const location& location,
+ ast::NameTy* type_name,
+ ast::Exp* size,
+ ast::Exp* init)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of ArrayExp).
+ return new ast::ArrayExp(location, type_name, size, init);
+ }
+
+ inline ast::NilExp* make_NilExp(const location& location)
+ {
+ return new ast::NilExp(location);
+ }
+
+ inline ast::SeqExp* make_SeqExp(const location& location,
+ ast::exps_type* exps)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of SeqExp).
+ return new ast::SeqExp(location, exps);
+ }
+
+ inline ast::AssignExp*
+ make_AssignExp(const location& location, ast::Var* var, ast::Exp* exp)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of AssignExp).
+ return new ast::AssignExp(location, var, exp);
+ }
+
+ inline ast::IfExp* make_IfExp(const location& location,
+ ast::Exp* test,
+ ast::Exp* thenclause,
+ ast::Exp* elseclause)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of IfExp).
+ return new ast::IfExp(location, test, thenclause, elseclause);
+ }
+
+ inline ast::IfExp*
+ make_IfExp(const location& location, ast::Exp* test, ast::Exp* thenclause)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of IfExp).
+ return new ast::IfExp(location, test, thenclause);
+ }
+
+ inline ast::WhileExp*
+ make_WhileExp(const location& location, ast::Exp* test, ast::Exp* body)
+ {
+ return new ast::WhileExp(location, test, body);
+ }
+
+ inline ast::ForExp* make_ForExp(const location& location,
+ ast::VarDec* vardec,
+ ast::Exp* hi,
+ ast::Exp* body)
+ {
+ return new ast::ForExp(location, vardec, hi, body);
+ }
+
+ inline ast::BreakExp* make_BreakExp(const location& location)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of BreakExp).
+ return new ast::BreakExp(location);
+ }
+
+ inline ast::LetExp*
+ make_LetExp(const location& location, ast::ChunkList* decs, ast::Exp* body)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of LetExp).
+ return new ast::LetExp(location, decs, body);
+ }
+
+ inline ast::OpExp* make_OpExp(const location& location,
+ ast::Exp* left,
+ ast::OpExp::Oper oper,
+ ast::Exp* right)
+ {
+ return new ast::OpExp(location, left, oper, right);
+ }
+
+ inline ast::CastExp*
+ make_CastExp(const location& location, ast::Exp* exp, ast::Ty* ty)
+ {
+ return new ast::CastExp(location, exp, ty);
+ }
+
+ inline ast::SimpleVar* make_SimpleVar(const location& location,
+ misc::symbol name)
+ {
+ return new ast::SimpleVar(location, name);
+ }
+
+ inline ast::FieldVar*
+ make_FieldVar(const location& location, ast::Var* var, misc::symbol name)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of FieldVar).
+ return new ast::FieldVar(location, var, name);
+ }
+
+ inline ast::SubscriptVar*
+ make_SubscriptVar(const location& location, ast::Var* var, ast::Exp* index)
+ {
+ return new ast::SubscriptVar(location, var, index);
+ }
+
+ /* Use expansion parameter pack to handle one or empty arguments */
+ template <class... T> inline ast::exps_type* make_exps_type(T... exps)
+ {
+ return new ast::exps_type{exps...};
+ }
+
+ inline ast::ChunkList* make_ChunkList(const location& location)
+ {
+ return new ast::ChunkList(location);
+ }
+
+ inline ast::TypeChunk* make_TypeChunk(const location& location)
+ {
+ return new ast::TypeChunk(location);
+ }
+
+ inline ast::TypeDec*
+ make_TypeDec(const location& location, misc::symbol name, ast::Ty* ty)
+ {
+ return new ast::TypeDec(location, name, ty);
+ }
+
+ inline ast::RecordTy* make_RecordTy(const location& location,
+ ast::fields_type* fields)
+ {
+ // FIXME DONE: Some code was deleted here (Constructor of RecordTy).
+ return new ast::RecordTy(location, fields);
+ }
+
+ inline ast::ArrayTy* make_ArrayTy(const location& location,
+ ast::NameTy* base_type)
+ {
+ return new ast::ArrayTy(location, base_type);
+ }
+
+ template <class... T> inline ast::fields_type* make_fields_type(T... types)
+ {
+ return new ast::fields_type{types...};
+ }
+
+ inline ast::Field* make_Field(const location& location,
+ misc::symbol name,
+ ast::NameTy* type_name)
+ {
+ return new ast::Field(location, name, type_name);
+ }
+
+ inline ast::NameTy* make_NameTy(const location& location, misc::symbol name)
+ {
+ return new ast::NameTy(location, name);
+ }
+
+ template <class... T>
+ inline ast::fieldinits_type* make_fieldinits_type(T... inits_types)
+ {
+ return new ast::fieldinits_type{inits_types...};
+ }
+
+ inline ast::FieldInit*
+ make_FieldInit(const location& location, misc::symbol name, ast::Exp* init)
+ {
+ return new ast::FieldInit(location, name, init);
+ }
+
+ inline ast::ClassTy* make_ClassTy(const location& location,
+ ast::NameTy* super,
+ ast::ChunkList* decs)
+ {
+ return new ast::ClassTy(location, super, decs);
+ }
+
+ inline ast::VarChunk* make_VarChunk(const location& location)
+ {
+ return new ast::VarChunk(location);
+ }
+
+ inline ast::VarDec* make_VarDec(const location& location,
+ misc::symbol name,
+ ast::NameTy* type_name,
+ ast::Exp* init)
+ {
+ return new ast::VarDec(location, name, type_name, init);
+ }
+
+ inline ast::MethodChunk* make_MethodChunk(const location& location)
+ {
+ return new ast::MethodChunk(location);
+ }
+
+ inline ast::MethodDec* make_MethodDec(const location& location,
+ misc::symbol name,
+ ast::VarChunk* formals,
+ ast::NameTy* result,
+ ast::Exp* body)
+ {
+ return new ast::MethodDec(location, name, formals, result, body);
+ }
+
+ inline ast::FunctionDec* make_FunctionDec(const location& location,
+ misc::symbol name,
+ ast::VarChunk* formals,
+ ast::NameTy* result,
+ ast::Exp* body)
+ {
+ return new ast::FunctionDec(location, name, formals, result, body);
+ }
+
+ template <class... T> inline ast::FunctionChunk* make_FunctionChunk(T... args)
+ {
+ return new ast::FunctionChunk(args...);
+ }
+
+ // For the custom tiger extension
+ inline ast::AssertExp* make_AssertExp(const location& location,
+ ast::Exp* condition)
+ {
+ return new ast::AssertExp(location, condition);
+ }
+} // namespace parse