/*---------------------------------------------------------------------------- ChucK Concurrent, On-the-fly Audio Programming Language Compiler and Virtual Machine Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. http://chuck.stanford.edu/ http://chuck.cs.princeton.edu/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U.S.A.-----------------------------------------------------------------------------*/ //-----------------------------------------------------------------------------// file: chuck_absyn.cpp// desc: chuck abstract syntax//// author: Ge Wang (ge@ccrma.stanford.edu | gewang@cs.princeton.edu)// date: Autumn 2002//-----------------------------------------------------------------------------#include "chuck_absyn.h"#include "chuck_utils.h"#include "chuck_errmsg.h"#include <stdlib.h>#include <stdio.h> a_Program new_program( a_Section section, int pos ){ a_Program a = (a_Program)checked_malloc( sizeof( struct a_Program_ ) ); a->section = section; a->linepos = pos; return a;} a_Program append_program( a_Program program, a_Section section, int pos ){ a_Program a = new_program( section, pos ); a_Program current; current = program->next; if (current == NULL) { program->next = a; return program; } while (1) { if (current->next == NULL) { current->next = a; break; } else { current = current->next; } } return program;} a_Section new_section_stmt( a_Stmt_List list, int pos ){ a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_ ) ); a->s_type = ae_section_stmt; a->stmt_list = list; a->linepos = pos; return a;} a_Section new_section_func_def( a_Func_Def func_def, int pos ){ a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_) ); a->s_type = ae_section_func; a->func_def = func_def; a->linepos = pos; return a;} a_Section new_section_class_def( a_Class_Def class_def, int pos ){ a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_) ); a->s_type = ae_section_class; a->class_def = class_def; a->linepos = pos; return a;} a_Stmt_List new_stmt_list( a_Stmt stmt, int pos ){ a_Stmt_List a = (a_Stmt_List)checked_malloc( sizeof( struct a_Stmt_List_ ) ); a->stmt = stmt; a->next = NULL; a->linepos = pos; return a;} a_Stmt_List append_stmt_list( a_Stmt_List stmt_list, a_Stmt stmt, int pos ){ a_Stmt_List a = new_stmt_list( stmt, pos ); a_Stmt_List current; current = stmt_list->next; if (current == NULL) { stmt_list->next = a; return stmt_list; } while (1) { if (current->next == NULL) { current->next = a; break; } else { current = current->next; } } return stmt_list;} a_Stmt new_stmt_from_expression( a_Exp exp, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_exp; a->stmt_exp = exp; a->linepos = pos; return a;} a_Stmt new_stmt_from_code( a_Stmt_List stmt_list, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_code; a->stmt_code.stmt_list = stmt_list; a->linepos = pos; a->stmt_code.linepos = pos; a->stmt_code.self = a; return a;} a_Stmt new_stmt_from_if( a_Exp cond, a_Stmt if_body, a_Stmt else_body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_if; a->stmt_if.cond = cond; a->stmt_if.if_body = if_body; a->stmt_if.else_body = else_body; a->linepos = pos; a->stmt_if.linepos = pos; a->stmt_if.self = a; return a;} a_Stmt new_stmt_from_while( a_Exp cond, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_while; a->stmt_while.is_do = 0; a->stmt_while.cond = cond; a->stmt_while.body = body; a->linepos = pos; a->stmt_while.linepos = pos; a->stmt_while.self = a; return a;} a_Stmt new_stmt_from_do_while( a_Exp cond, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_while; a->stmt_while.is_do = 1; a->stmt_while.cond = cond; a->stmt_while.body = body; a->linepos = pos; a->stmt_while.linepos = pos; a->stmt_while.self = a; return a;} a_Stmt new_stmt_from_until( a_Exp cond, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_until; a->stmt_until.is_do = 0; a->stmt_until.cond = cond; a->stmt_until.body = body; a->linepos = pos; a->stmt_until.linepos = pos; a->stmt_until.self = a; return a;} a_Stmt new_stmt_from_do_until( a_Exp cond, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_until; a->stmt_until.is_do = 1; a->stmt_until.cond = cond; a->stmt_until.body = body; a->linepos = pos; a->stmt_until.linepos = pos; a->stmt_until.self = a; return a;} a_Stmt new_stmt_from_for( a_Stmt c1, a_Stmt c2, a_Exp c3, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_for; a->stmt_for.c1 = c1; a->stmt_for.c2 = c2; a->stmt_for.c3 = c3; a->stmt_for.body = body; a->linepos = pos; a->stmt_for.linepos = pos; a->stmt_for.self = a; return a;} a_Stmt new_stmt_from_loop( a_Exp cond, a_Stmt body, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_loop; a->stmt_loop.cond = cond; a->stmt_loop.body = body; a->linepos = pos; a->stmt_loop.linepos = pos; a->stmt_loop.self = a; return a;} a_Stmt new_stmt_from_switch( a_Exp val, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_switch; a->stmt_switch.val = val; a->linepos = pos; a->stmt_switch.linepos = pos; a->stmt_switch.self = a; return a;} a_Stmt new_stmt_from_break( int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_break; a->linepos = pos; a->stmt_break.linepos = pos; a->stmt_break.self = a; return a;} a_Stmt new_stmt_from_continue( int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_continue; a->linepos = pos; a->stmt_continue.linepos = pos; a->stmt_continue.self = a; return a;} a_Stmt new_stmt_from_return( a_Exp exp, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_return; a->stmt_return.val = exp; a->linepos = pos; a->stmt_return.linepos = pos; a->stmt_return.self = a; return a;} a_Stmt new_stmt_from_label( c_str xid, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_gotolabel; a->stmt_gotolabel.name = insert_symbol( xid ); a->linepos = pos; a->stmt_gotolabel.linepos = pos; a->stmt_gotolabel.self = a; return a;} a_Stmt new_stmt_from_case( a_Exp exp, int pos ){ a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_case; a->stmt_case.exp = exp; a->linepos = pos; a->stmt_case.linepos = pos; a->stmt_case.self = a; return a;} a_Exp append_expression( a_Exp list, a_Exp exp, int pos ){ a_Exp current; current = list->next; if (current == NULL) { list->next = exp; return list; } while (1) { if (current->next == NULL) { current->next = exp; break; } else { current = current->next; } } return list;} a_Exp new_exp_from_binary( a_Exp lhs, ae_Operator oper, a_Exp rhs, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_binary; a->s_meta = ae_meta_value; a->binary.lhs = lhs; a->binary.op = oper; a->binary.rhs = rhs; a->linepos = pos; a->binary.linepos = pos; a->binary.self = a; return a;} a_Exp new_exp_from_unary( ae_Operator oper, a_Exp exp, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = exp->s_meta; a->unary.op = oper; a->unary.exp = exp; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a;} a_Exp new_exp_from_unary2( ae_Operator oper, a_Type_Decl type, a_Array_Sub array, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = ae_meta_value; a->unary.op = oper; a->unary.type = type; a->unary.array = array; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a;} a_Exp new_exp_from_unary3( ae_Operator oper, a_Stmt code, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = ae_meta_value; a->unary.op = oper; a->unary.code = code; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a;} a_Exp new_exp_from_cast( a_Type_Decl type, a_Exp exp, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_cast; a->s_meta = ae_meta_value; a->cast.type = type; a->cast.exp = exp; a->linepos = pos; a->cast.linepos = pos; a->cast.self = a; return a;} a_Exp new_exp_from_array( a_Exp base, a_Array_Sub indices, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_array; a->s_meta = ae_meta_var; a->array.base = base; a->array.indices = indices; a->linepos = pos; a->array.linepos = pos; a->array.self = a; return a;} a_Exp new_exp_from_func_call( a_Exp base, a_Exp args, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_func_call; a->s_meta = ae_meta_value; a->func_call.func = base; a->func_call.args = args; a->linepos = pos; a->func_call.linepos = pos; a->func_call.self = a; return a;} a_Exp new_exp_from_member_dot( a_Exp base, c_str xid, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_dot_member; a->s_meta = ae_meta_var; a->dot_member.base = base; a->dot_member.xid = insert_symbol( xid ); a->linepos = pos; a->dot_member.linepos = pos; a->dot_member.self = a; return a;} a_Exp new_exp_from_postfix( a_Exp base, ae_Operator op, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_postfix; a->s_meta = ae_meta_var; a->postfix.exp = base; a->postfix.op = op; a->linepos = pos; a->postfix.linepos = pos; a->postfix.self = a; return a;} a_Exp new_exp_from_dur( a_Exp base, a_Exp unit, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_dur; a->s_meta = ae_meta_value; a->dur.base = base; a->dur.unit = unit; a->linepos = pos; a->dur.linepos = pos; a->dur.self = a; return a;} a_Exp new_exp_from_id( c_str xid, int pos ){ a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_primary; a->s_meta = ae_meta_var; a->primary.s_type = ae_primary_var; a->primary.var = insert_symbol( xid ); a->linepos = pos; a->primary.linepos = pos; a->primary.self = a; return a;}Lines 1–500 of 1025. Load more
/*---------------------------------------------------------------------------- ChucK Concurrent, On-the-fly Audio Programming Language Compiler and Virtual Machine Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. http://chuck.stanford.edu/ http://chuck.cs.princeton.edu/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U.S.A. -----------------------------------------------------------------------------*/ //----------------------------------------------------------------------------- // file: chuck_absyn.cpp // desc: chuck abstract syntax // // author: Ge Wang (ge@ccrma.stanford.edu | gewang@cs.princeton.edu) // date: Autumn 2002 //----------------------------------------------------------------------------- #include "chuck_absyn.h" #include "chuck_utils.h" #include "chuck_errmsg.h" #include <stdlib.h> #include <stdio.h> a_Program new_program( a_Section section, int pos ) { a_Program a = (a_Program)checked_malloc( sizeof( struct a_Program_ ) ); a->section = section; a->linepos = pos; return a; } a_Program append_program( a_Program program, a_Section section, int pos ) { a_Program a = new_program( section, pos ); a_Program current; current = program->next; if (current == NULL) { program->next = a; return program; } while (1) { if (current->next == NULL) { current->next = a; break; } else { current = current->next; } } return program; } a_Section new_section_stmt( a_Stmt_List list, int pos ) { a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_ ) ); a->s_type = ae_section_stmt; a->stmt_list = list; a->linepos = pos; return a; } a_Section new_section_func_def( a_Func_Def func_def, int pos ) { a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_) ); a->s_type = ae_section_func; a->func_def = func_def; a->linepos = pos; return a; } a_Section new_section_class_def( a_Class_Def class_def, int pos ) { a_Section a = (a_Section)checked_malloc( sizeof( struct a_Section_) ); a->s_type = ae_section_class; a->class_def = class_def; a->linepos = pos; return a; } a_Stmt_List new_stmt_list( a_Stmt stmt, int pos ) { a_Stmt_List a = (a_Stmt_List)checked_malloc( sizeof( struct a_Stmt_List_ ) ); a->stmt = stmt; a->next = NULL; a->linepos = pos; return a; } a_Stmt_List append_stmt_list( a_Stmt_List stmt_list, a_Stmt stmt, int pos ) { a_Stmt_List a = new_stmt_list( stmt, pos ); a_Stmt_List current; current = stmt_list->next; if (current == NULL) { stmt_list->next = a; return stmt_list; } while (1) { if (current->next == NULL) { current->next = a; break; } else { current = current->next; } } return stmt_list; } a_Stmt new_stmt_from_expression( a_Exp exp, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_exp; a->stmt_exp = exp; a->linepos = pos; return a; } a_Stmt new_stmt_from_code( a_Stmt_List stmt_list, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_code; a->stmt_code.stmt_list = stmt_list; a->linepos = pos; a->stmt_code.linepos = pos; a->stmt_code.self = a; return a; } a_Stmt new_stmt_from_if( a_Exp cond, a_Stmt if_body, a_Stmt else_body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_if; a->stmt_if.cond = cond; a->stmt_if.if_body = if_body; a->stmt_if.else_body = else_body; a->linepos = pos; a->stmt_if.linepos = pos; a->stmt_if.self = a; return a; } a_Stmt new_stmt_from_while( a_Exp cond, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_while; a->stmt_while.is_do = 0; a->stmt_while.cond = cond; a->stmt_while.body = body; a->linepos = pos; a->stmt_while.linepos = pos; a->stmt_while.self = a; return a; } a_Stmt new_stmt_from_do_while( a_Exp cond, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_while; a->stmt_while.is_do = 1; a->stmt_while.cond = cond; a->stmt_while.body = body; a->linepos = pos; a->stmt_while.linepos = pos; a->stmt_while.self = a; return a; } a_Stmt new_stmt_from_until( a_Exp cond, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_until; a->stmt_until.is_do = 0; a->stmt_until.cond = cond; a->stmt_until.body = body; a->linepos = pos; a->stmt_until.linepos = pos; a->stmt_until.self = a; return a; } a_Stmt new_stmt_from_do_until( a_Exp cond, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_until; a->stmt_until.is_do = 1; a->stmt_until.cond = cond; a->stmt_until.body = body; a->linepos = pos; a->stmt_until.linepos = pos; a->stmt_until.self = a; return a; } a_Stmt new_stmt_from_for( a_Stmt c1, a_Stmt c2, a_Exp c3, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_for; a->stmt_for.c1 = c1; a->stmt_for.c2 = c2; a->stmt_for.c3 = c3; a->stmt_for.body = body; a->linepos = pos; a->stmt_for.linepos = pos; a->stmt_for.self = a; return a; } a_Stmt new_stmt_from_loop( a_Exp cond, a_Stmt body, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_loop; a->stmt_loop.cond = cond; a->stmt_loop.body = body; a->linepos = pos; a->stmt_loop.linepos = pos; a->stmt_loop.self = a; return a; } a_Stmt new_stmt_from_switch( a_Exp val, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_switch; a->stmt_switch.val = val; a->linepos = pos; a->stmt_switch.linepos = pos; a->stmt_switch.self = a; return a; } a_Stmt new_stmt_from_break( int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_break; a->linepos = pos; a->stmt_break.linepos = pos; a->stmt_break.self = a; return a; } a_Stmt new_stmt_from_continue( int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_continue; a->linepos = pos; a->stmt_continue.linepos = pos; a->stmt_continue.self = a; return a; } a_Stmt new_stmt_from_return( a_Exp exp, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_return; a->stmt_return.val = exp; a->linepos = pos; a->stmt_return.linepos = pos; a->stmt_return.self = a; return a; } a_Stmt new_stmt_from_label( c_str xid, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_gotolabel; a->stmt_gotolabel.name = insert_symbol( xid ); a->linepos = pos; a->stmt_gotolabel.linepos = pos; a->stmt_gotolabel.self = a; return a; } a_Stmt new_stmt_from_case( a_Exp exp, int pos ) { a_Stmt a = (a_Stmt)checked_malloc( sizeof( struct a_Stmt_ ) ); a->s_type = ae_stmt_case; a->stmt_case.exp = exp; a->linepos = pos; a->stmt_case.linepos = pos; a->stmt_case.self = a; return a; } a_Exp append_expression( a_Exp list, a_Exp exp, int pos ) { a_Exp current; current = list->next; if (current == NULL) { list->next = exp; return list; } while (1) { if (current->next == NULL) { current->next = exp; break; } else { current = current->next; } } return list; } a_Exp new_exp_from_binary( a_Exp lhs, ae_Operator oper, a_Exp rhs, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_binary; a->s_meta = ae_meta_value; a->binary.lhs = lhs; a->binary.op = oper; a->binary.rhs = rhs; a->linepos = pos; a->binary.linepos = pos; a->binary.self = a; return a; } a_Exp new_exp_from_unary( ae_Operator oper, a_Exp exp, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = exp->s_meta; a->unary.op = oper; a->unary.exp = exp; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a; } a_Exp new_exp_from_unary2( ae_Operator oper, a_Type_Decl type, a_Array_Sub array, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = ae_meta_value; a->unary.op = oper; a->unary.type = type; a->unary.array = array; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a; } a_Exp new_exp_from_unary3( ae_Operator oper, a_Stmt code, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_unary; a->s_meta = ae_meta_value; a->unary.op = oper; a->unary.code = code; a->linepos = pos; a->unary.linepos = pos; a->unary.self = a; return a; } a_Exp new_exp_from_cast( a_Type_Decl type, a_Exp exp, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_cast; a->s_meta = ae_meta_value; a->cast.type = type; a->cast.exp = exp; a->linepos = pos; a->cast.linepos = pos; a->cast.self = a; return a; } a_Exp new_exp_from_array( a_Exp base, a_Array_Sub indices, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_array; a->s_meta = ae_meta_var; a->array.base = base; a->array.indices = indices; a->linepos = pos; a->array.linepos = pos; a->array.self = a; return a; } a_Exp new_exp_from_func_call( a_Exp base, a_Exp args, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_func_call; a->s_meta = ae_meta_value; a->func_call.func = base; a->func_call.args = args; a->linepos = pos; a->func_call.linepos = pos; a->func_call.self = a; return a; } a_Exp new_exp_from_member_dot( a_Exp base, c_str xid, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_dot_member; a->s_meta = ae_meta_var; a->dot_member.base = base; a->dot_member.xid = insert_symbol( xid ); a->linepos = pos; a->dot_member.linepos = pos; a->dot_member.self = a; return a; } a_Exp new_exp_from_postfix( a_Exp base, ae_Operator op, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_postfix; a->s_meta = ae_meta_var; a->postfix.exp = base; a->postfix.op = op; a->linepos = pos; a->postfix.linepos = pos; a->postfix.self = a; return a; } a_Exp new_exp_from_dur( a_Exp base, a_Exp unit, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_dur; a->s_meta = ae_meta_value; a->dur.base = base; a->dur.unit = unit; a->linepos = pos; a->dur.linepos = pos; a->dur.self = a; return a; } a_Exp new_exp_from_id( c_str xid, int pos ) { a_Exp a = (a_Exp)checked_malloc( sizeof( struct a_Exp_ ) ); a->s_type = ae_exp_primary; a->s_meta = ae_meta_var; a->primary.s_type = ae_primary_var; a->primary.var = insert_symbol( xid ); a->linepos = pos; a->primary.linepos = pos; a->primary.self = a; return a; }