Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8733 | turbocat | 1 | /* |
2 | * Tiny BASIC |
||
3 | * Parser Header |
||
4 | * |
||
5 | * Released as Public Domain by Damian Gareth Walker 2019 |
||
6 | * Created: 08-Aug-2019 |
||
7 | */ |
||
8 | |||
9 | |||
10 | #ifndef __PARSER_H__ |
||
11 | #define __PARSER_H__ |
||
12 | |||
13 | |||
14 | /* pre-requisite headers */ |
||
15 | #include "statement.h" |
||
16 | #include "errors.h" |
||
17 | #include "options.h" |
||
18 | #include "tokeniser.h" |
||
19 | |||
20 | |||
21 | /* |
||
22 | * Data Declarations |
||
23 | */ |
||
24 | |||
25 | |||
26 | /* the parser */ |
||
27 | typedef struct parser_data ParserData; |
||
28 | typedef struct parser Parser; |
||
29 | typedef struct parser { |
||
30 | |||
31 | /* Properties */ |
||
32 | ParserData *priv; /* parser's private data */ |
||
33 | |||
34 | /* |
||
35 | * Public methods |
||
36 | */ |
||
37 | |||
38 | /* |
||
39 | * Parse the whole program |
||
40 | * params: |
||
41 | * Parser* The parser to use |
||
42 | * INPUT* The input file to parse |
||
43 | * returns: |
||
44 | * ProgramNode* The parsed program |
||
45 | */ |
||
46 | ProgramNode *(*parse) (Parser *); |
||
47 | |||
48 | /* |
||
49 | * Return the current source line we're parsing |
||
50 | * params: |
||
51 | * Parser* The parser to use |
||
52 | * returns: |
||
53 | * int the line returned |
||
54 | */ |
||
55 | int (*get_line) (Parser *); |
||
56 | |||
57 | /* |
||
58 | * Return the label of the source line we're parsing |
||
59 | * params: |
||
60 | * Parser* The parser to use |
||
61 | * returns: |
||
62 | * int the label returned |
||
63 | */ |
||
64 | int (*get_label) (Parser *); |
||
65 | |||
66 | /* |
||
67 | * Destroy this parser object |
||
68 | * params: |
||
69 | * Parser* the doomed parser |
||
70 | */ |
||
71 | void (*destroy) (Parser *); |
||
72 | |||
73 | } Parser; |
||
74 | |||
75 | |||
76 | /* |
||
77 | * Function Declarations |
||
78 | */ |
||
79 | |||
80 | |||
81 | /* |
||
82 | * Constructor |
||
83 | * params: |
||
84 | * ErrorHandler* the error handler to use |
||
85 | * LanguageOptions* the language options to use |
||
86 | * FILE* the input file |
||
87 | * returns: |
||
88 | * Parser* the new parser |
||
89 | */ |
||
90 | Parser *new_Parser (ErrorHandler *, LanguageOptions *, FILE *); |
||
91 | |||
92 | |||
93 | #endif |