--- /dev/null
+/* types, of pointers to corresponding structs */
+typedef struct A_stm_ *A_stm;
+typedef struct A_exp_ *A_exp;
+typedef struct A_expList_ *A_expList;
+
+/* binary operation */
+typedef enum { A_plus, A_minus, A_times, A_div } A_binop;
+
+/* statement */
+struct A_stm_ {
+ /* types: compound, assign, print */
+ enum { A_compoundStm, A_assignStm, A_printStm } type;
+ union {
+ struct { A_stm stm1, stm2; } compound;
+ struct { char *id; A_exp exp; } assign;
+ struct { A_expList exps; } print;
+ } u;
+};
+
+/* statement constrctor functions */
+A_stm A_CompoundStm ( A_stm stm1, A_stm stm2 );
+A_stm A_AssignStm ( char *id, A_exp exp );
+A_stm A_PrintStm ( A_expList exps );
+
+/* expression */
+struct A_exp_ {
+ /* types: id, number, operation, sequence */
+ enum { A_idExp, A_numExp, A_opExp, A_eseqExp } type;
+ union {
+ char *id;
+ int num;
+ struct { A_exp exp1; A_binop op; A_exp exp2; } op;
+ struct { A_stm stm; A_exp exp; } eseq;
+ } u;
+};
+
+/* expression constructor functions */
+A_exp A_IdExp ( char *id );
+A_exp A_NumExp ( int num );
+A_exp A_OpExp ( A_exp exp1, A_binop op, A_exp exp2 );
+A_exp A_EseqExp ( A_stm stm, A_exp exp );
+
+/* expression list */
+struct A_expList_ {
+ /* types: pair, last */
+ enum { A_pairExpList, A_lastExpList } type;
+ union {
+ struct { A_exp head; A_expList tail; } pair;
+ A_exp last;
+ } u;
+};
+
+/* expression list constructor functions */
+A_expList A_PairExpList (A_exp head, A_expList tail);
+A_expList A_LastExplist (A_exp last);
--- /dev/null
+# include <stdlib.h>
+# include "A.h"
+
+/*
+ * node constructor functions
+ */
+
+/* A_CompoundStm - returns a compound statement of stm1, stm2 */
+A_stm A_CompoundStm (A_stm stm1, A_stm stm2) {
+ A_stm s = malloc(sizeof(*s));
+ s->type = A_compoundStm;
+ s->u.compound.stm1 = stm1;
+ s->u.compound.stm2 = stm2;
+ return s;
+}
+
+/* A_AssignStm - returns a assign statement of id, exp */
+A_stm A_AssignStm (char *id, A_exp exp) {
+ A_stm s = malloc(sizeof(*s));
+ s->type = A_assignStm;
+ s->u.assign.id = id;
+ s->u.assign.exp = exp;
+ return s;
+}
+
+/* A_PrintStm - returns a print statement of exps */
+A_stm A_PrintStm (A_expList exps) {
+ A_stm s = malloc(sizeof(*s));
+ s->type = A_printStm;
+ s->u.print.exps = exps;
+ return s;
+}
+
+/* A_IdExp - returns an id expression of id */
+A_exp A_IdExp (char *id) {
+ A_exp e = malloc(sizeof(*e));
+ e->type = A_idExp;
+ e->u.id = id;
+ return e;
+}
+
+/* A_NumExp - returns a number expression of num */
+A_exp A_NumExp (int num) {
+ A_exp e = malloc(sizeof(*e));
+ e->type = A_numExp;
+ e->u.num = num;
+ return e;
+}
+
+/* A_OpExp - returns an operation expression of exp1, op, exp2 */
+A_exp A_OpExp (A_exp exp1, A_binop op, A_exp exp2) {
+ A_exp e = malloc(sizeof(*e));
+ e->type = A_opExp;
+ e->u.op.exp1 = exp1;
+ e->u.op.op = op;
+ e->u.op.exp2 = exp2;
+ return e;
+}
+
+/* A_EseqExp - returns a seqeunce expression of stm, exp */
+A_exp A_EseqExp (A_stm stm, A_exp exp) {
+ A_exp e = malloc(sizeof(*e));
+ e->type = A_eseqExp;
+ e->u.eseq.stm = stm;
+ e->u.eseq.exp = exp;
+ return e;
+}
+
+/* A_PairExpList - returns a list expression pair of head, tail */
+A_expList A_PairExpList (A_exp head, A_expList tail) {
+ A_expList l = malloc(sizeof(*l));
+ l->type = A_pairExpList;
+ l->u.pair.head = head;
+ l->u.pair.tail = tail;
+ return l;
+}
+
+/* A_LastExpList - returns a expression list end of last */
+A_expList A_LastExpList (A_exp last) {
+ A_expList l = malloc(sizeof(*l));
+ l->type = A_lastExpList;
+ l->u.last = last;
+ return l;
+}
+
+int main (int argc, char** argv) {
+ return 0;
+}