HANDBOOK / CASE STUDY / The Compiler /

# Abstract Syntax

Here is the definition of the abstract representation of MiniLAX programs:

    003  'type' DECL
    004     dcl(IDENT, DEF, POS)

    005  'type' DECLLIST
    006     decllist(DECL, DECLLIST)
    007     nil

    008  'type' DEF
    009     variable(TYPE)
    010     valueparam(TYPE)
    011     varparam(TYPE)
    012     proc(Formals: DECLLIST, Locals: DECLLIST, STMT)

    013  'type' TYPE
    014     integer
    015     real
    016     boolean
    017     array(INT, INT, TYPE)
    018     none

    019  'type' STMT
    020     assign(DESIG, EXPR, POS)
    021     read(DESIG, POS)
    022     write(EXPR, POS)
    023     call(IDENT, EXPRLIST, POS)
    024     if(EXPR, STMT, STMT, POS)
    025     while(EXPR, STMT, POS)
    026     seq(STMT, STMT)

    027  'type' DESIG
    028     id(IDENT, POS)
    029     subscr(DESIG, EXPR, POS)
    030     none

    031  'type' EXPR
    032     binary(OP, EXPR, EXPR, POS)
    033     opnot(EXPR, POS)
    034     int(INT)
    035     float(FLOAT)
    036     true
    037     false
    038     desig(DESIG)

    039  'type' EXPRLIST
    040     exprlist(EXPR, EXPRLIST, POS)
    041     nil(POS)

    042  'type' OP
    043     less
    044     plus
    045     mult