File tree Expand file tree Collapse file tree 4 files changed +155
-155
lines changed Expand file tree Collapse file tree 4 files changed +155
-155
lines changed Original file line number Diff line number Diff line change 10
10
// / Jsil Language
11
11
12
12
#include " jsil_parser.h"
13
+
14
+ int yyjsillex_init_extra (jsil_parsert *, void **);
15
+ int yyjsillex_destroy (void *);
16
+ int yyjsilparse (jsil_parsert &, void *);
17
+
18
+ bool jsil_parsert::parse ()
19
+ {
20
+ void *scanner;
21
+ yyjsillex_init_extra (this , &scanner);
22
+ bool parse_fail = yyjsilparse (*this , scanner) != 0 ;
23
+ yyjsillex_destroy (scanner);
24
+ return parse_fail;
25
+ }
Original file line number Diff line number Diff line change 16
16
17
17
#include " jsil_parse_tree.h"
18
18
19
- class jsil_parsert ;
20
- int yyjsilparse (jsil_parsert &);
21
- void jsil_scanner_init (jsil_parsert &);
22
-
23
19
class jsil_parsert :public parsert
24
20
{
25
21
public:
@@ -30,13 +26,9 @@ class jsil_parsert:public parsert
30
26
31
27
jsil_parse_treet parse_tree;
32
28
33
- virtual bool parse () override
34
- {
35
- jsil_scanner_init (*this );
36
- return yyjsilparse (*this ) != 0 ;
37
- }
29
+ bool parse () override ;
38
30
39
- virtual void clear () override
31
+ void clear () override
40
32
{
41
33
parsert::clear ();
42
34
parse_tree.clear ();
Original file line number Diff line number Diff line change 1
1
%{
2
2
3
3
// #define YYDEBUG 1
4
- #define PARSER (* jsil_parser)
4
+ #define PARSER jsil_parser
5
5
6
6
#include " jsil_parser.h"
7
7
8
- int yyjsillex ();
9
- extern char *yyjsiltext ;
8
+ int yyjsillex (unsigned *, void * );
9
+ char *yyjsilget_text ( void *) ;
10
10
11
- static jsil_parsert *jsil_parser;
12
- int yyjsilparse (void );
13
- int yyjsilparse (jsil_parsert &_jsil_parser)
11
+ int yyjsilerror (
12
+ jsil_parsert &jsil_parser,
13
+ void *scanner,
14
+ const std::string &error)
14
15
{
15
- jsil_parser = &_jsil_parser;
16
- return yyjsilparse ();
17
- }
18
-
19
- int yyjsilerror (const std::string &error)
20
- {
21
- jsil_parser->parse_error (error, yyjsiltext);
16
+ jsil_parser.parse_error (error, yyjsilget_text (scanner));
22
17
return 0 ;
23
18
}
24
19
@@ -43,9 +38,14 @@ int yyjsilerror(const std::string &error)
43
38
// unreachable code
44
39
#pragma warning(disable:4702)
45
40
#endif
41
+ %}
42
+
43
+ %define api.pure full
44
+ %parse-param {jsil_parsert &jsil_parser}
45
+ %parse-param {void *scanner}
46
+ %lex-param {void *scanner}
46
47
47
48
/* ** token declaration **************************************************/
48
- %}
49
49
50
50
/* ** special scanner reports ***/
51
51
You can’t perform that action at this time.
0 commit comments