]> pd.if.org Git - lice/blob - parse.h
autocommit for files dated 2014-11-17 20:15:26
[lice] / parse.h
1 #ifndef LICE_PARSE_HDR
2 #define LICE_PARSE_HDR
3 #include "ast.h"
4
5 /*
6  * Function: parse_enumeration
7  *  Parse an enumeration
8  *
9  * Returns:
10  *  A data type containing that enumeration definition
11  */
12 data_type_t *parse_enumeration(void);
13
14 /*
15  * Function: parse_union
16  *  Parse a union
17  *
18  * Returns:
19  *  A data type containing that union definition
20  */
21 data_type_t *parse_union(void);
22
23 /*
24  * Function: parse_structure
25  *  Parse a structure
26  *
27  * Returns:
28  *  A data type containing that structure definition
29  */
30 data_type_t *parse_structure(void);
31
32 /*
33  * Fucntion: parse_typeof
34  *  Parse typeof operator
35  *
36  * Returns:
37  *  The data type that represents the type of the expression supplied
38  *  as the operand to the typeof operator.
39  */
40 data_type_t *parse_typeof(void);
41
42 /*
43  * Function: parse_typedef_find
44  *  Search the parser typedef table for a typedef
45  *
46  * Parameters:
47  *  string - The key of the type to search in the typedef table
48  *
49  * Returns:
50  *  The data type representing that typedef if found, otherwise NULL.
51  */
52 data_type_t *parse_typedef_find(const char *string);
53
54 /*
55  * Function: parse_run
56  *  Main entry point for the parser.
57  *
58  * Returns:
59  *  Will produce a list of AST toplevel expressions which can be handed
60  *  down to the code generator one at a time.
61  */
62 list_t *parse_run(void);
63
64 /*
65  * Function: parse_init
66  *  Main initialization for the global parser context.
67  *
68  * Remarks:
69  *  This must be called before calling <parse_run>.
70  */
71 void parse_init(void);
72
73 /*
74  * Function: parse_expect
75  *  When expecting language punctuation, this function is assumed to
76  *  ensure that the following lexer state does indeed contain that
77  *  punctuator.
78  *
79  * Parameters:
80  *  punct   - A character literal of the punctuation.
81  *
82  * Remarks:
83  *  If the passed punctuator isn't resolved as the current lexer state
84  *  a lexer error is raised.
85  */
86 void parse_expect(char punct);
87
88 /*
89  * Function: parse_next
90  *  Reads the next token in the token stream and determines if it's
91  *  the token specified by the argument, ungetting the token if it is,
92  *  ignoring it if it isn't.
93  *
94  * Parameters:
95  *  ch - The token to check
96  *
97  * Returns:
98  *  true if the token passed matches the next token in the token stream,
99  *  false otherwise.
100  *
101  * Remarks:
102  *  This will advance lexer state only if the token specified as a
103  *  parameter isn't determined as the next token in the token stream.
104  */
105 bool parse_next(int ch);
106
107 /*
108  * Function: parse_expression_evaluate
109  *  Reads a conditional expression and evaluates it as an integer constant
110  *  expression if it one.
111  *
112  * Returns:
113  *  An integer constant value of the evaluation of the integer constant
114  *  expression.
115  *
116  * Remarks:
117  *  Will raise a compilation error if it isn't a valid integer constant
118  *  expression.
119  */
120 int parse_expression_evaluate(void);
121
122 /* TODO: remove */
123 void parse_semantic_assignable(data_type_t *to, data_type_t *from);
124 ast_t       *parse_expression_assignment(void);
125
126 #endif