Peng Yu,
Why Bison/Flex are not good at Fortran? What is special for Fortran's grammar?
Parsing Fortran is not that hard it is the lexical analysis that
is very fiddly. Read about my recent attempts here:
shape-of-code.coding-guidelines.com/2009/12/parsing-fortran-95
--
Derek M.
Philip,
No problem i got a the book LEX and YACC o'reilly:
http://oreilly.com/catalog/9781565920002/
Flex & Bison is now available (17 years more up todate)
http://oreilly.com/catalog/9780596155971/
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Sof
have
not been able to spend enough time to figure out how to do what
I would like.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp://www.knosof.
have never tried
to write one.
There do seem to be some tools out there (never tried any of them)
http://rw4.cs.uni-sb.de/~sander/html/gsvcg1.html
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED
Paulo,
I am on a Mac and I would like to know if anybody has any suggestion
on a free software to visualize vcg files resulting from bison output
or convert them to a bitmap file.
I find graphviz useful for this kind of thing
http://www.graphviz.org/
--
Derek M. Jones
ken sequences).
Try to think in terms of a push down automata that has to decide what
to do given its current state and the next token. In the case of
the C++ grammar there are no shift/reduce decision conflicts (I'm
assuming you copied it correctly).
--
Derek M. Jones
_expression XOR unary_expression
;
unary_expression
: NUMBER
| PLUS NUMBER %prec UPLUS
| BIT_NOT NUMBER
| NOT NUMBER
;
I hope someone can help me with this. Thanks.
--
Derek M. Jones tel: +44 (0) 1252 52
ved
it this way.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp://www.knosof.co.uk
___
help-bis
input it expects.
I think you also need to learn more about C.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghtt
xer can now return
0 to indicate no more tokens.
In the above example all the parse stacks eventually get very upset
over that if token and I eventually end up with a syntax error :-(
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd
than making them happen.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp://www.knosof.co.uk
___
help-bison@gn
.
On the subject of new features. I have just been bitten (again)
by not being able to execute any actions in when multiple parse
stacks are in existence. Having a way of specifying a non-deferred
action would solve a recurring problem of mine.
--
Derek M. Jones tel
eason why I
think %merge (or some generic version) is more appropriate.
Populating my .y file with all these %merges, just in case ...,
would be a pain.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTE
UK=on&StoreAlibris=on&StoreAmazon=on&StoreAmazonCA=on&StoreAmazonUK=on&StoreAmazonDE=on&StoreAmazonFR=on&StoreAntiqbook=on&StoreBiblio=on&StoreBibliophile=on&StoreBibliopoly=on&StoreBooksandcollectibles=on&StoreHalf=on&StoreILAB=on&StoreMaremagnum
s that one is a typedef-name and the other an identifier.
I'm not sure how practical this might be in practice. I think I
prefer the ability to resolve the conflict with a
my_reportAmbiguity function.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Kn
yyZ0,
YYSTYPE yyZ1)
{
...
return yyZ0;
}
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp://www.knosof.
are deferred.
Now I cannot get it to happen on the full grammar, let alone the
cut down one :-(
Suggestions welcome.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conforman
re resolving the issue in my_reportAmbiguity provides
a much neater solution.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing
flict? We are a peace loving group of people. Why not ambiguity
resolution, or ambiguity hint, ambiguity suggestion/recommendation?
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Appli
ested enough to
actually write the implementation.
I did look into implementing it, but ended up with scrambled brain.
Perhaps if Satya Kiran does a good job of documenting Bison
internals I will have more luck figuring out what needs to be done.
--
Derek M. Jones tel
act 1 from the yyrule value that gets printed out. It is
off by one compared to the listing that appears in the .output file.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conforman
oping to dynamically catch all the ambiguities so they
could be counted and analyzed in more detail (I plan to turn
all by %dprecs into %merge).
Thanks for looking at the problem. I will probably stick with
my slight grammar change solution for the time being.
--
Derek
(*input ? *input++ : 0);
while (isspace(c))
c = *input++;
asprintf (&yylval, "%c", c);
printf("> %c\n", c);
return (c == 'I') ? INT : (isalpha(c) ? IDENT : c);
}
int main (void)
{
yydebug=1;
printf ("%i\n", yyparse ());
}
--
Derek M. Jones
software
was an arm and a leg, but because the users got to have so
few goes at compiling in a day.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp
he largest amount of input (up to some limit) without
generating any other syntax errors.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testinghttp://www.kn
ou will need that too. I suspect however that you'll
eventually need reference counting regardless of this bug. You may even
need it now for tokens.
My quick fix was to not free up any parse trees inside the merge
functions.
--
Derek M. Jones tel: +44 (0) 1252
Joel,
Make sure you are running at least Bison 2.1. If the results still don't
make sense to you, post again and I'll look harder at this.
In the future, please tell us what version of Bison you are running.
Ok, will do. Yes, I am running version 2.1.
--
Dere
{
printf("%s\n", "statement\n");
} ;
%%
static int yylex (void)
{
char c = *input ? *input++ : 0;
asprintf (&yylval, "%c", c);
return (isalpha(c) && (c != 'S')) ? ID
turned and
push it back to be reread next time yyparse is called. I have not
yet come across any C source where this does not work.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards C
on */
c = (*input ? *input++ : 0);
while (isspace(c))
c = *input++;
asprintf (&yylval, "%c", c);
printf("> %c\n", c);
return (c == 'I') ? INT : (isalpha(c) ? IDENT : c);
}
int main (void)
{
yydebug=1;
printf ("%i\n", yyparse ());
}
--
Dere
e merge function. That's how bison is intended to work.
I cannot find any statement about this 'intended' way of working in
the documentation.
The practical use of glr parsers is very new. It is to be expected
that new features will be added as experience grows.
--
Derek M Jones
Joel,
Does anybody know why the decision was made to have the %merge
function called last? This choice seems to be very suboptimal.
The merge function's job is to merge the semantic values constructed by
the two actions. If it were called before the actions, what would it
merge?
Ok, so
All,
I have finally gotten around to trying to do something
sensible with my C grammar (see discussion during February).
Just to remind you all, %merge was used to disambiguate
situations like:
(x) * y;
ie, is this a cast of *y to type x, or a multiplication of
x by y?
In most cases the expres
he answer is no.
Consider the translation unit:
#include "necessary_stuff.h"
void f(void)
{
g(i); /* does this call the function g or define the object i to have type g? */
}
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Kno
anybody know if the mailing list has had a change of software?
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing http://w
27;a'
e -> 'a' 'a'
v -> e e
Adding a %merge to the second production involving
v removes the parse stack resolution ambiguity (or at least
passes it off to a user supplied function). This ambiguity
cannot be resolved using %dprec because at the point
; factor { asprintf (&$$, "u+%s", $2); }
| '-' factor { asprintf (&$$, "u-%s", $2); }
| ID
;
%%
static int yylex ()
{
char c = *input ? *input++ : 0;
asprintf (&yylval, "%c", c
single %merge. I thought at
least two are required?
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing http://www.knosof.co.uk
__
).
>
>Have you looked at `%merge'?
That option has the limits on its use as %dprec.
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformanc
mcpeak/elkhound/
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing http://www.knosof.co.uk
___
grammar
rewrites)
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing http://www.knosof.co.uk
___
ce:
static int (foo); static
ie a declaration and the first token from a second declaration. %gooa
would get me out of this hole without a big grammar rewrite.
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd
ber-names. I.e., instead of
>%token type-name number-name
>you write
>%token token-type-name
>%%
>type-name: token-type-name;
>number-name: token-type-name;
>
>You then get a correct GLR parse, and can try to sort out the ambiguity
>later.
I
Hans,
>At 20:41 + 2005/03/03, Derek M Jones wrote:
>>The statement (y)+z can be parsed as casting
>>+z to the type y, or as adding y to z. A couple of
>>%dprecs solve this problem (I think the cast is the
>>common case for - and a binary expression for +).
>
&
o be
selected. Picking the common case means that there is
less work which has to be undone later in the semantics phase.
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applicati
a symbol table.
It also contains lots of shift/reduce and reduce/reduce
conflicts, and if I was writing a more conventional grammar
I would want to remove these.
derek
--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd
production. When two or
more ambiguous parses are encountered the weights
of the various productions involved would be added
up and the one with the greatest weight selected.
derek
--
Derek M Jones tel: +44 (0) 1252 520
667
Knowledge Software Ltd
es. Performance is not
an issue (not that I think that nondeterministic parsing would
be a performance bottleneck).
derek
--
Derek M Jones tel: +44 (0) 1252 520
667
Knowledge Software Ltdmailto:
tion.
Bison is correct not to perform the reductions I was
expecting. Until a {, or EOF, is seen it does not it does not
know whether it is dealing with a function definition or a
list of declarations.
derek
--
Derek M Jones tel: +44 (0) 1252 520
667
Know
ursion).
I am guessing that some form of lazy evaluation is being used
internally by Bison. After all, in most cases an end-of-file
indicator is used to force reductions.
>Alternatively, you might try an entirely new approach to your whole program
>setup.
thence reductions to the accept state?
derek
--
Derek M Jones tel: +44 (0) 1252 520
667
Knowledge Software Ltdmailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing
51 matches
Mail list logo