Re: How to construct a BNF for a language mechanically and incrementally?

2009-12-30 Thread Derek M Jones
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.

Re: Return from recursive processing is incomplete

2009-09-07 Thread Derek M Jones
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

Re: Question about GLR parsing with bison 2.3

2008-06-03 Thread Derek M Jones
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.

Re: VCG visualization

2008-04-26 Thread Derek M Jones
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

Re: VCG visualization

2008-04-24 Thread Derek M Jones
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

Re: shift/reduce conflict with unary

2007-08-21 Thread 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

Re: shift/reduce conflict with unary

2007-08-21 Thread 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

Re: How to solve this kind of ambiguities?

2006-08-03 Thread Derek M Jones
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

Re: Problem generating code from bison

2006-05-31 Thread Derek M Jones
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

Re: Reducing conflict: Was: Exceeded limits of %dprec/%merge?

2006-05-20 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-19 Thread Derek M Jones
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

Re: Reducing conflict: Was: Exceeded limits of %dprec/%merge?

2006-05-19 Thread Derek M Jones
. 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

Re: Exceeded limits of %dprec/%merge?

2006-05-19 Thread Derek M Jones
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

Book: LR parsing: theory and practice

2006-05-19 Thread Derek M Jones
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

Reducing conflict: Was: Exceeded limits of %dprec/%merge?

2006-05-19 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-19 Thread Derek M Jones
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.

Re: Exceeded limits of %dprec/%merge?

2006-05-18 Thread Derek M Jones
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: Exceeded limits of %dprec/%merge?

2006-05-18 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-18 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-17 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-17 Thread Derek M Jones
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

Re: Exceeded limits of %dprec/%merge?

2006-05-17 Thread Derek M Jones
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

Exceeded limits of %dprec/%merge?

2006-05-16 Thread Derek M Jones
(*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

Re: Google summer of code

2006-05-09 Thread 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

Re: Google summer of code

2006-05-08 Thread Derek M Jones
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

Re: Multiple, different, %merge of a token sequence

2006-05-02 Thread Derek M Jones
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

Re: Multiple, different, %merge of a token sequence

2006-05-02 Thread Derek M Jones
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

Multiple, different, %merge of a token sequence

2006-05-01 Thread Derek M Jones
{ printf("%s\n", "statement\n"); } ; %% static int yylex (void) { char c = *input ? *input++ : 0; asprintf (&yylval, "%c", c); return (isalpha(c) && (c != 'S')) ? ID

Re: Reduce if you can behavior wanted

2006-04-29 Thread Derek M Jones
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

Reduce if you can behavior wanted

2006-04-28 Thread Derek M Jones
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

Re: merge function called AFTER user actions

2005-09-26 Thread Derek M Jones
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

Re: merge function called AFTER user actions

2005-09-26 Thread 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

merge function called AFTER user actions

2005-09-22 Thread Derek M Jones
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

Re: can we generate a C++ parser with Bison?

2005-07-27 Thread Derek M Jones
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

Invalid confirmation string

2005-04-29 Thread Derek M Jones
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

Ambiguity involving two parse stacks reducing on the same rule

2005-03-09 Thread Derek M Jones
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

Re: x + (y) + z

2005-03-08 Thread Derek M Jones
; factor { asprintf (&$$, "u+%s", $2); } | '-' factor { asprintf (&$$, "u-%s", $2); } | ID ; %% static int yylex () { char c = *input ? *input++ : 0; asprintf (&yylval, "%c", c

Re: x + (y) + z

2005-03-07 Thread Derek M Jones
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 __

Re: x + (y) + z

2005-03-07 Thread Derek M Jones
). > >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

Re: x + (y) + z

2005-03-06 Thread Derek M Jones
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 ___

Re: x + (y) + z

2005-03-06 Thread Derek M Jones
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 ___

Re: x + (y) + z

2005-03-06 Thread Derek M Jones
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

Re: x + (y) + z

2005-03-06 Thread Derek M Jones
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

Re: x + (y) + z

2005-03-05 Thread Derek M Jones
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 +). > &

Re: x + (y) + z

2005-03-04 Thread Derek M Jones
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

Re: x + (y) + z

2005-03-04 Thread Derek M Jones
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

x + (y) + z

2005-03-03 Thread Derek M Jones
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

Re: Forcing multiple parse stacks to 'reduce'

2005-03-02 Thread Derek M Jones
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:

Re: Forcing multiple parse stacks to 'reduce'

2005-03-01 Thread Derek M Jones
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

Re: Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Derek M Jones
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.

Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Derek M Jones
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