Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
19773f88
Commit
19773f88
authored
21 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
force flex buffer flush after an error
parent
6974762c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
MathEval/parser.cpp
+23
-16
23 additions, 16 deletions
MathEval/parser.cpp
MathEval/parser.y
+8
-1
8 additions, 1 deletion
MathEval/parser.y
MathEval/scanner.cpp
+4
-2
4 additions, 2 deletions
MathEval/scanner.cpp
MathEval/scanner.l
+3
-1
3 additions, 1 deletion
MathEval/scanner.l
with
38 additions
and
20 deletions
MathEval/parser.cpp
+
23
−
16
View file @
19773f88
...
@@ -54,7 +54,14 @@ int yyerror (char *s);
...
@@ -54,7 +54,14 @@ int yyerror (char *s);
is generated by scanner generator). */
is generated by scanner generator). */
int
yylex
(
void
);
int
yylex
(
void
);
#line 41 "parser.y"
/* Function used to flush the internal flex buffer when we exit
prematurely (i.e., in case of a parse error) so that the next time
we call the scanner, all is nicely reset. Without this, the
behaviour of the next call after an error is unpredictable. */
int
force_buffer_flush
(
void
);
#line 48 "parser.y"
#ifndef YYSTYPE
#ifndef YYSTYPE
typedef
union
{
typedef
union
{
Node
*
node
;
Node
*
node
;
...
@@ -128,8 +135,8 @@ static const short yyrhs[] =
...
@@ -128,8 +135,8 @@ static const short yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static
const
short
yyrline
[]
=
static
const
short
yyrline
[]
=
{
{
0
,
64
,
72
,
7
5
,
7
8
,
8
2
,
8
6
,
9
0
,
9
4
,
98
,
0
,
71
,
7
8
,
8
1
,
8
4
,
8
8
,
9
2
,
9
6
,
100
,
104
,
10
2
,
1
06
10
8
,
1
12
};
};
#endif
#endif
...
@@ -915,76 +922,75 @@ yyreduce:
...
@@ -915,76 +922,75 @@ yyreduce:
switch
(
yyn
)
{
switch
(
yyn
)
{
case
1
:
case
1
:
#line
64
"parser.y"
#line
71
"parser.y"
{
{
matheval_root
=
yyvsp
[
-
1
].
node
;
matheval_root
=
yyvsp
[
-
1
].
node
;
yyerrok
;
return
1
;
return
1
;
;
;
break
;}
break
;}
case
2
:
case
2
:
#line 7
2
"parser.y"
#line 7
8
"parser.y"
{
{
yyval
.
node
=
yyvsp
[
0
].
node
;
yyval
.
node
=
yyvsp
[
0
].
node
;
;
;
break
;}
break
;}
case
3
:
case
3
:
#line
75
"parser.y"
#line
81
"parser.y"
{
{
yyval
.
node
=
yyvsp
[
0
].
node
;
yyval
.
node
=
yyvsp
[
0
].
node
;
;
;
break
;}
break
;}
case
4
:
case
4
:
#line
7
8 "parser.y"
#line 8
4
"parser.y"
{
{
/* Create addition binary operator node. */
/* Create addition binary operator node. */
yyval
.
node
=
node_create
(
'b'
,
'+'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'b'
,
'+'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
5
:
case
5
:
#line 8
2
"parser.y"
#line 8
8
"parser.y"
{
{
/* Create subtraction binary operator node. */
/* Create subtraction binary operator node. */
yyval
.
node
=
node_create
(
'b'
,
'-'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'b'
,
'-'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
6
:
case
6
:
#line
86
"parser.y"
#line
92
"parser.y"
{
{
/* Create multiplication binary operator node. */
/* Create multiplication binary operator node. */
yyval
.
node
=
node_create
(
'b'
,
'*'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'b'
,
'*'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
7
:
case
7
:
#line 9
0
"parser.y"
#line 9
6
"parser.y"
{
{
/* Create division binary operator node. */
/* Create division binary operator node. */
yyval
.
node
=
node_create
(
'b'
,
'/'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'b'
,
'/'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
8
:
case
8
:
#line
94
"parser.y"
#line
100
"parser.y"
{
{
/* Create minus unary operator node. */
/* Create minus unary operator node. */
yyval
.
node
=
node_create
(
'u'
,
'-'
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'u'
,
'-'
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
9
:
case
9
:
#line
98
"parser.y"
#line
104
"parser.y"
{
{
/* Create exponentiation unary operator node. */
/* Create exponentiation unary operator node. */
yyval
.
node
=
node_create
(
'b'
,
'^'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
yyval
.
node
=
node_create
(
'b'
,
'^'
,
yyvsp
[
-
2
].
node
,
yyvsp
[
0
].
node
);
;
;
break
;}
break
;}
case
10
:
case
10
:
#line 10
2
"parser.y"
#line 10
8
"parser.y"
{
{
/* Create function node. */
/* Create function node. */
yyval
.
node
=
node_create
(
'f'
,
yyvsp
[
-
3
].
record
,
yyvsp
[
-
1
].
node
);
yyval
.
node
=
node_create
(
'f'
,
yyvsp
[
-
3
].
record
,
yyvsp
[
-
1
].
node
);
;
;
break
;}
break
;}
case
11
:
case
11
:
#line 1
06
"parser.y"
#line 1
12
"parser.y"
{
{
yyval
.
node
=
yyvsp
[
-
1
].
node
;
yyval
.
node
=
yyvsp
[
-
1
].
node
;
;
;
...
@@ -1222,7 +1228,7 @@ yyreturn:
...
@@ -1222,7 +1228,7 @@ yyreturn:
#endif
#endif
return
yyresult
;
return
yyresult
;
}
}
#line 11
1
"parser.y"
#line 11
7
"parser.y"
int
yyerror
(
char
*
s
)
int
yyerror
(
char
*
s
)
...
@@ -1230,5 +1236,6 @@ int yyerror(char* s)
...
@@ -1230,5 +1236,6 @@ int yyerror(char* s)
/* Indicate parsing error through appropriate flag and stop
/* Indicate parsing error through appropriate flag and stop
parsing. */
parsing. */
matheval_ok
=
0
;
matheval_ok
=
0
;
force_buffer_flush
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
MathEval/parser.y
+
8
−
1
View file @
19773f88
...
@@ -35,6 +35,13 @@ int yyerror (char *s);
...
@@ -35,6 +35,13 @@ int yyerror (char *s);
/* Function used to tokenize string representing function (this function
/* Function used to tokenize string representing function (this function
is generated by scanner generator). */
is generated by scanner generator). */
int yylex (void);
int yylex (void);
/* Function used to flush the internal flex buffer when we exit
prematurely (i.e., in case of a parse error) so that the next time
we call the scanner, all is nicely reset. Without this, the
behaviour of the next call after an error is unpredictable. */
int force_buffer_flush(void);
%}
%}
/* Parser semantic values type. */
/* Parser semantic values type. */
...
@@ -63,7 +70,6 @@ int yylex (void);
...
@@ -63,7 +70,6 @@ int yylex (void);
input
input
: expression '\n' {
: expression '\n' {
matheval_root = $1;
matheval_root = $1;
yyerrok;
return 1;
return 1;
}
}
;
;
...
@@ -115,5 +121,6 @@ int yyerror(char* s)
...
@@ -115,5 +121,6 @@ int yyerror(char* s)
/* Indicate parsing error through appropriate flag and stop
/* Indicate parsing error through appropriate flag and stop
parsing. */
parsing. */
matheval_ok = 0;
matheval_ok = 0;
force_buffer_flush();
return 0;
return 0;
}
}
This diff is collapsed.
Click to expand it.
MathEval/scanner.cpp
+
4
−
2
View file @
19773f88
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
/* A lexical scanner generated by flex */
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
/* Scanner skeleton version:
* $Header: /cvsroot/gmsh/MathEval/scanner.cpp,v 1.
3
2004-05-12 18:
38
:4
4
geuzaine Exp $
* $Header: /cvsroot/gmsh/MathEval/scanner.cpp,v 1.
4
2004-05-12 18:
57
:4
8
geuzaine Exp $
*/
*/
#define FLEX_SCANNER
#define FLEX_SCANNER
...
@@ -1704,3 +1704,5 @@ static int input_from_string (char *buffer, int max_size)
...
@@ -1704,3 +1704,5 @@ static int input_from_string (char *buffer, int max_size)
return
count
;
return
count
;
}
}
int
force_buffer_flush
()
{
YY_FLUSH_BUFFER
;
}
This diff is collapsed.
Click to expand it.
MathEval/scanner.l
+
3
−
1
View file @
19773f88
...
@@ -124,3 +124,5 @@ static int input_from_string (char *buffer, int max_size)
...
@@ -124,3 +124,5 @@ static int input_from_string (char *buffer, int max_size)
return count;
return count;
}
}
int force_buffer_flush() { YY_FLUSH_BUFFER; }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment