## parse-tree.pkg
# Compiled by:
#
src/lib/c-kit/src/parser/c-parser.sublib### "So in grad school my thesis work was fairly theoretical
### (hierarchies of recursive functions), but I also began
### to get more into the practical aspects."
###
### -- Dennis Ritchie
package parse_tree
: (weak) Parsetree # Parsetree is from
src/lib/c-kit/src/parser/parse-tree.api{
Qualifier = CONST
| VOLATILE;
Storage
= TYPEDEF
| STATIC
| EXTERN
| REGISTER
| AUTO;
Operator
= PLUS
| MINUS | TIMES | DIVIDE | MOD
| GT | LT | GTE | LTE | EQ | NEQ | AND | OR
| BIT_OR | BIT_AND | BIT_XOR | LSHIFT | RSHIFT
| STAR | ADDR_OF | DOT | ARROW | SUB | SIZEOF
| PRE_INC | POST_INC | PRE_DEC | POST_DEC | COMMA
| NOT | NEGATE | BIT_NOT | ASSIGN
| PLUS_ASSIGN | MINUS_ASSIGN | TIMES_ASSIGN | DIV_ASSIGN
| MOD_ASSIGN | XOR_ASSIGN | OR_ASSIGN | AND_ASSIGN
| LSHIFT_ASSIGN | RSHIFT_ASSIGN
| UPLUS
| SIZEOF_TYPE Ctype
| OPERATOR_EXT Operator_Ext
also Expression
= EMPTY_EXPR
| INT_CONST large_int::Int
| REAL_CONST Float
| STRING String
| ID String
| UNOP (Operator, Expression)
| BINOP (Operator, Expression, Expression)
| QUESTION_COLON (Expression, Expression, Expression)
| CALL (Expression, List( Expression ))
| CAST (Ctype, Expression)
| INIT_LIST List( Expression )
| MARKEXPRESSION ((line_number_db::Location, Expression))
| EXPR_EXT Expression_Ext
also Specifier
= VOID
| ELLIPSES
| SIGNED
| UNSIGNED
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| FRACTIONAL
| WHOLENUM
| SATURATE
| NONSATURATE
| ARRAY (Expression, Ctype)
| POINTER Ctype
| FUNCTION
{ ret_type: Ctype,
parameters: List( (Decltype, Declarator) ) }
| ENUM
{ tag_opt: Null_Or( String ),
enumerators: List( (String, Expression) ),
trailing_comma: Bool } # TRUE if there was there a trailing comma in the declaration
| STRUCT
{ is_struct: Bool, # struct or union; TRUE => struct
tag_opt: Null_Or( String ), # optional tag
members: List( (Ctype, List( (Declarator, Expression) )) ) } # member specs
| TYPEDEF_NAME String
| STRUCT_TAG
{ is_struct: Bool, # ???
name: String }
| ENUM_TAG String
| SPEC_EXT Specifier_Ext
also Declarator # Constructor suffix: "Decr"
= EMPTY_DECR
| ELLIPSES_DECR
| VAR_DECR String
| ARRAY_DECR (Declarator, Expression)
| POINTER_DECR Declarator
| QUAL_DECR (Qualifier, Declarator)
| FUNC_DECR (Declarator, List ((Decltype, Declarator)))
| MARKDECLARATOR ((line_number_db::Location, Declarator))
| DECR_EXT Declarator_Ext
# supports extensions of C in which expressions contain statements
also Statement
= DECL Declaration
| EXPR Expression
| COMPOUND List( Statement )
| WHILE (Expression, Statement)
| DO (Expression, Statement)
| FOR (Expression, Expression, Expression, Statement)
| LABELED (String, Statement)
| CASE_LABEL (Expression, Statement)
| DEFAULT_LABEL Statement
| GOTO String
| BREAK
| CONTINUE
| RETURN Expression
| IF_THEN (Expression, Statement)
| IF_THEN_ELSE (Expression, Statement, Statement)
| SWITCH (Expression, Statement)
| MARKSTATEMENT ((line_number_db::Location, Statement))
| STAT_EXT Statement_Ext
also Declaration
= DECLARATION (Decltype, List ((Declarator, Expression)))
| MARKDECLARATION ((line_number_db::Location, Declaration))
| DECLARATION_EXT Declaration_Ext
also External_Decl
= EXTERNAL_DECL Declaration
| FUN
# record?
{ ret_type: Decltype, # return type
fun_decr: Declarator, # function name declarator
kr_params: List( Declaration ), # K&R-style parameter declarations
body: Statement } # function body
| MARKEXTERNAL_DECL (line_number_db::Location, External_Decl)
| EXTERNAL_DECL_EXT External_Decl_Ext
withtype Ctype =
{ qualifiers: List( Qualifier ),
specifiers: List( Specifier ) }
also Decltype =
{ qualifiers: List( Qualifier ),
specifiers: List( Specifier ),
storage: List( Storage ) }
also External_Decl_Ext = parse_tree_ext::External_Decl_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Declaration_Ext = parse_tree_ext::Declaration_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Statement_Ext = parse_tree_ext::Statement_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Declarator_Ext = parse_tree_ext::Declarator_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Specifier_Ext = parse_tree_ext::Specifier_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Expression_Ext = parse_tree_ext::Expression_Ext (Specifier, Declarator, Ctype, Decltype, Operator, Expression, Statement)
also Operator_Ext = parse_tree_ext::Operator_Ext;
}; # package parse_tree