File tree 5 files changed +38
-32
lines changed
5 files changed +38
-32
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,11 @@ bool jsil_languaget::parse(
62
62
parse_path=path;
63
63
64
64
// parsing
65
+ jsil_parsert jsil_parser{message_handler};
65
66
jsil_parser.clear ();
66
67
jsil_parser.set_file (path);
67
68
jsil_parser.in =&instream;
68
- jsil_parser.log .set_message_handler (message_handler);
69
69
70
- jsil_scanner_init ();
71
70
bool result=jsil_parser.parse ();
72
71
73
72
// save result
@@ -137,12 +136,10 @@ bool jsil_languaget::to_expr(
137
136
std::istringstream instream (code);
138
137
139
138
// parsing
140
-
139
+ jsil_parsert jsil_parser{message_handler};
141
140
jsil_parser.clear ();
142
141
jsil_parser.set_file (irep_idt ());
143
142
jsil_parser.in =&instream;
144
- jsil_parser.log .set_message_handler (message_handler);
145
- jsil_scanner_init ();
146
143
147
144
bool result=jsil_parser.parse ();
148
145
Original file line number Diff line number Diff line change 10
10
// / Jsil Language
11
11
12
12
#include " jsil_parser.h"
13
-
14
- jsil_parsert jsil_parser;
15
-
16
- extern char *yyjsiltext;
17
-
18
- int yyjsilerror (const std::string &error)
19
- {
20
- jsil_parser.parse_error (error, yyjsiltext);
21
- return 0 ;
22
- }
Original file line number Diff line number Diff line change 16
16
17
17
#include " jsil_parse_tree.h"
18
18
19
- int yyjsilparse ();
19
+ class jsil_parsert ;
20
+ int yyjsilparse (jsil_parsert &);
21
+ void jsil_scanner_init (jsil_parsert &);
20
22
21
23
class jsil_parsert :public parsert
22
24
{
23
25
public:
26
+ explicit jsil_parsert (message_handlert &message_handler)
27
+ : parsert(message_handler)
28
+ {
29
+ }
30
+
24
31
jsil_parse_treet parse_tree;
25
32
26
33
virtual bool parse () override
27
34
{
28
- return yyjsilparse ()!=0 ;
35
+ jsil_scanner_init (*this );
36
+ return yyjsilparse (*this ) != 0 ;
29
37
}
30
38
31
39
virtual void clear () override
@@ -41,9 +49,4 @@ class jsil_parsert:public parsert
41
49
std::string string_literal;
42
50
};
43
51
44
- extern jsil_parsert jsil_parser;
45
-
46
- int yyjsilerror (const std::string &error);
47
- void jsil_scanner_init ();
48
-
49
52
#endif // CPROVER_JSIL_JSIL_PARSER_H
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
8
int yyjsillex ();
9
9
extern char *yyjsiltext;
10
10
11
+ static jsil_parsert *jsil_parser;
12
+ int yyjsilparse (void );
13
+ int yyjsilparse (jsil_parsert &_jsil_parser)
14
+ {
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);
22
+ return 0 ;
23
+ }
24
+
11
25
#define YYSTYPE unsigned
12
26
#define YYSTYPE_IS_TRIVIAL 1
13
27
Original file line number Diff line number Diff line change 17
17
#include < ansi-c/literals/convert_float_literal.h>
18
18
#include < ansi-c/literals/convert_string_literal.h>
19
19
20
- #define PARSER jsil_parser
20
+ #define PARSER (* jsil_parser)
21
21
#define YYSTYPE unsigned
22
22
23
23
#include " jsil_parser.h"
24
24
#include " jsil_y.tab.h"
25
25
// extern int yyjsildebug;
26
26
27
+ static jsil_parsert *jsil_parser;
28
+ void jsil_scanner_init (jsil_parsert &_jsil_parser)
29
+ {
30
+ jsil_parser = &_jsil_parser;
31
+ YY_FLUSH_BUFFER;
32
+ BEGIN (0 );
33
+ }
34
+
35
+ int yyjsilerror (const std::string &error);
36
+
27
37
#define loc () \
28
38
{ newstack (yyjsillval); PARSER.set_source_location (parser_stack (yyjsillval)); }
29
39
@@ -71,14 +81,6 @@ string_lit ["]{s_char}*["]
71
81
%x STRING_LITERAL_COMMENT
72
82
%x STATEMENTS
73
83
74
- %{
75
- void jsil_scanner_init ()
76
- {
77
- // yyjsildebug=1;
78
- YY_FLUSH_BUFFER;
79
- BEGIN (0 );
80
- }
81
- %}
82
84
/* %option debug */
83
85
84
86
%%
You can’t perform that action at this time.
0 commit comments