Re: When to free RHS tokens?

2016-12-27 Thread John Levine
>forvalues_cmd: >FORVALUES IDENT "=" NUMBER "(" NUMBER ")" NUMBER "{" STRING_LITERAL "}" >{ >// do I need to free() or del tokens $3, $5, $7, $9 and $11? No. Bison tokens live in an array, no allocation or deallocation needed. If the lexer or parser puts a pointer to an allocated thi

Re: [Question] - Is it a good idea to parse groff with Bison?

2015-11-07 Thread John Levine
>Do you believe that its a good idea to use Bison for this?. Probably not. Groff syntax is really simple, and the nesting is kludgy enough that I'd suggest doing it by hand rather than trying to force it into bison. You'll also probably find that parsing groff is about 5% of the work, and figuri

Re: Is handwritten faster?

2015-10-02 Thread John Levine
In article you write: >Hey Adam, > >My two cents is to paraphrase John Levine's Flex & Bison book (ha! I almost >said Adam Levine!): No prob, I've been called worse. >- yes, after tweaking, your manual parser will probably be faster. >- but that assumes you put all the necessary time into tweak

Re: Using bison without Flex

2015-04-23 Thread John Levine
In article you write: > >> On 23 Apr 2015, at 16:34, brahim sahbi wrote: > >> can we use bison without flex by describing grammatical >> rules for tokens(like number <- list_of_digits). > >A lexer like generated by Flex scans forward to find the longest match which >may require significant looka

Re: QUESTION: what does LR(0) mean? and what's behind the name LR0.c ?

2014-10-06 Thread John Levine
In article <1412583978.11745.yahoomailba...@web126104.mail.ne1.yahoo.com> you write: >Hi, I'm going through the bison code, and I'm curious as to the name of the >source code file LR0.c . > >Seems like this file creates the states. After they are created, the first >state is at state 0. You mi

Re: rule cycle and reduce/reduce conflict

2013-11-18 Thread John Levine
>bool_expr : '!' bool_expr > | num_expr '=' num_expr > | 'b' > ; > >num_expr : bool_expr > | 'n' > ; Yes, this is ambiguous. If your input is "!b=n", it can't tell which of these you mean: ! ( b = n ) (!b) = n R's, John __

Re: Bison deterministic LALR parser for C++ (kind of complex langauge) without 'lexar hack' support

2012-08-18 Thread John Levine
>> You mean, Fortran is not parseable by Bison, is that what you mean? > >Not practical. I've written Fortran 77 parsers in yacc. It's quite easy. The lexical structure of Fortran is dreadful, but once you understand the hacks required, it's straightforward to pre-scan each statement to figure o

Re: Need Help on GLR Parser

2012-03-05 Thread John Levine
>I am new to Bison and trying to understand how GLR parser works. >As per the documentation, GLR parser creates separate parallel parsers in >case of conflicting actions found in action table. >Does it use fork() or clone() or Pthread to create those parallel process? No. It just creates internal

Re: nonterminal symbol types

2011-05-05 Thread John Levine
>formal_port_element >: .SIGNAL. {g_list_type = Parser::PORT;} > identifier_list > Colon {g_list_type = Parser::UNKNOWN;} > .mode. { design.portSpecs($4);} > type_mark > .constraint. > .BUS. > .VarAsgn__expression. >; >M

Re: Match at least one?

2011-04-05 Thread John Levine
>I'm guessing that I can't do it with the grammar itself and that I'll >have to do some post processing once msg is matched. You can in principle do it by factoring out the list into different rules that track which of the mandatory items you've seen so far. Here it is with two mandatory items A a

Re: bison I/O error

2010-07-01 Thread John Levine
>I'm getting the following error using bison 2.3 : > >Building Unsupported.tab.c because it does not exist. >bison -d -pUnsupported Unsupported.y >bison: I/O error >gmake: *** [Unsupported.tab.c] Error 1 >or38 linus>bison -V >bison (GNU Bison) 2.3 > >Any clue about what might be the root cause of

Re: How to learn bison efficiently if I want to generate parse in C++?

2010-01-01 Thread John Levine
>I want to learn to generate parser in C++. However, the book by Levine >only mentioned C++ in the last chapter, Chapter 9. All the examples in >Chapter 1-8 are in C. Instead of reading the book in order, could >somebody let me know if there is a faster way to learn bison to >generate parser in C++

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

2009-12-29 Thread John Levine
>I just start reading the book "flex & bison Text Processing Tools" by >John Levine. Please excuse me if I ask some question that are >available somewhere in the book. When the grammar become huge, it >would be inconvenient put all BNFs in a single file. I'm w

Re: How to resolve a shift/reduce conflict in simple grammar

2009-11-27 Thread John Levine
>The following grammar gives 2 shift/reduce conflicts. I have simplified >it as good as possible. The intention of the grammar is to "collect" >blocks of consecutive '0' and '1' characters from input until a >semicolon occurs. > >start : sequences ';' ; >sequences : sequences sequence |

Re: Determining LR(k)-ness

2009-11-18 Thread John Levine
>> For an arbitrary .y file, I'd like to know if it's possible to get >> some report detail that would tell me (when using the %glr-parser >> option) what was the maximum 'k' lookahead used for that grammar. > >Unless it has been changed lately, it just uses LALR(1) and splits the >parse when

Re: Undeclared value type for nonterminals when using multiple value types

2009-10-12 Thread John Levine
>What is the default data type for nonterminals when using multiple data types > (%union)? In other words can I have nonterminals with undefined data >types (no %type<..>) when using %union? There's no default. So long as you don't attempt to use the values, you'll be OK. If you do try to use o