[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes in templates needed to enhance pure parser
From: |
Aubin Mahé |
Subject: |
Changes in templates needed to enhance pure parser |
Date: |
Fri, 6 Dec 2002 00:13:48 +0100 |
Hello,
I have made some changes in bison templates to enhance pure parser but
bison 1.75 is harder to customize.
1) A question
Where are bison.simple and bison.hairy?
The man says:
/usr/local/share/bison/bison.simple simple parser
/usr/local/share/bison/bison.hairy complicated parser
Under cygwin, these files don't exist.
I have rebuild bison by hand, from bison-1.75.tar.gz but without any
changes.
2) A suggestion about the YYPARSE_PARAM parameter.
It may be strongly typed. 'void *' is an old "C" stuff which can easily
avoided in C++.
Here a fragment of Makefile to 'sed' the result of bison:
$(YACC_FILES): Expression.y
bison --debug --output yaccgen/yExpression.cpp
--defines=yaccgen/yExpression.h Expression.y
sed 's/YYPARSE_PARAM_ARG void \*YYPARSE_PARAM/YYPARSE_PARAM_ARG
YYPARSE_PARAM/g' yaccgen/yExpression.cpp > yaccgen/yExpression.cpp2
sed 's/int yyparse (void \*)/int yyparse(YYPARSE_PARAM)/g'
yaccgen/yExpression.cpp2 > yaccgen/yExpression.cpp
rm -f yaccgen/yExpression.cpp2
Here is a fragment of the associated grammar file:
...
#define YYERROR_VERBOSE
#define YYSTYPE std::string
#define YYPARSE_PARAM Evaluator & e
#define yyerror( X ) e.setErrorMsg( X )
%}
%pure_parser
%token IDENTIFIER
...
%token BETWEEN
%token SCOPE
%%
Expression
: Expression OR Expression { e.push( new Or ( e.popExpression(),
e.popExpression())); }
| Expression AND Expression { e.push( new And( e.popExpression(),
e.popExpression())); }
| '(' Expression ')'
...
;
...
Is it possible to change the internally used template to avoid the 'sed'
replacements?
3) Under Solaris, with an antique bsd yacc, I have used '-P myParser'
option after customizing myParser (a copy of bison.simple) to avoid the
'sed' commands in Makefile and it works.
I think it may be easy to change this into bison 1.75 too.
Hope this can be a contribution,
Aubin Mahé
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Changes in templates needed to enhance pure parser,
Aubin Mahé <=