Hello,
The following simple "calculator expression" grammar (BNF) can be easily parsed with the a trivial recursive-descent parser, which is predictive LL(1):
<expr> := <term> + <term>
| <term> - <term>
| <term>
<term> := <factor> * <factor>
<factor> / <factor>
<fa...
How do hand-written recursive descent parsers (which are inevitably LL(k)) compare to generated LALR parsers in terms of performance?
I know that LALR parsers are able to handle far more grammars than LL(k); however it's my intention to write my parser by hand, and recursive descent seems the most appropriate choice. Is it possible to w...
I'm looking for a good explanation of the definitions of the FIRST, FOLLOW, and PREDICT sets of a RDP when given a grammar.
...
I'm trying to parse some data out of a file using Perl & Parse::RecDescent. I can't throw the full data file at the perl script because RecDescent will take days poring over it. So I split up the huge datafile into RD-sized chunks to reduce the runtime.
However, I need to extract sections within balanced brackets and the routine I hav...
I've recently being trying to teach myself how parsers (for languages/context-free grammars) work, and most of it seems to be making sense, except for one thing. I'm focusing my attention in particular on LL(k) grammars, for which the two main algorithms seem to be the LL parser (using stack/parse table) and the Recursive Descent parser ...
I've tried taking this code and converting it to something for a project I'm working on for programming language processing, but I'm running into an issue with a simplified version:
op = oneOf( '+ - / *')
lparen, rparen = Literal('('), Literal(')')
expr = Forward()
expr << ( Word(nums) | ( expr + op + expr ) | ( lparen + expr + rparen)...
Like the title says, I'm looking to write a recursive descent parser by hand and I'm looking for good resources on how to structure it, algorithms, etc.
...
The question is very straightforward: Is it possible to parse PHP using PEG?
I want to use a PEG parser-generator to parse PHP. Please kindly advise. Thank you!
...
hi there,
is there a way to replace following CSS with jQuery?
.quote-body .quote-body { background: #f5f5f5 }
.quote-body .quote-body .quote-body { background: #fff }
.quote-body .quote-body .quote-body .quote-body { background: #f5f5f5 }
.quote-body .quote-body .quote-body .quote-body .quote-body { background: #fff }
...
and so on
...
I have figured out how to use spirit -- i.e., I have written a moderately complex grammar. I always take the approach of growing a program -- one subsystem at a time. I've written the data structures for a complex model which has 4 types at the highest level.
I would like to use the grammar composed from rules approach to parse the top...
I have a section of a schema for a model that I need to parse. Lets say it looks like the following.
{
type = "Standard";
hostname="x.y.z";
port="123";
}
The properties are:
The elements may appear unordered.
All elements that are part of the schema must appear, and no other.
All of the elements' synthesised attributes go into...
I'm currently in the middle of playing with a BNF grammar that I hope to be able to wrangle into a LL(1) form. However, I've just finished making changes and calculating the new FIRST and FOLLOW sets for the grammar by hand for the third time today and I'm getting tired of it. There has to be a better way!
Can someone suggest a tool tha...
I am trying to parse some data to no success. Can anyone recommend a good introduction with a lot of examples to Recursive Descent Parsing? I haven't been able to find any.
...
Is it possible to generate a parse tree at the same time as I use recursive descent parser to check if the data matches grammar?
If so, what approach would I use to build a tree as I recursively descent?
Thanks, Boda Cydo.
Note: I am new to parsing. (Asked several questions on SO already, and I am getting better with it.)
...
I'm building a custom expression parser and evaluator for production environment to provide a limited DSL to the users. The parser itself as the DSL, need to be simple. The parser is going to be built in an exotic language that doesn't support dynamic expression parsing nor has any parser generator tools available.
My current decision ...
It's been a few years since my computer-language class and so I've forgotten the finer points of BNF's and EBNF's and I don't have a textbook next to me. Specifically, I've forgotten how to convert an EBNF into BNF.
From what little I remember, I know that one of the main points is to convert { term } into <term> | <many-terms>. But I d...
So, I'm writing an LL(1) parser (for kicks) and I ran into a problem with the member selection operator ("." as in "var.function()"). Here's a simplified grammar I'm trying to analyze with the parser:
postfix_expression
: postfix_expression '(' ')'
| postfix_expression '.' identifier
| identifier
;
The above grammar i...
I am trying to make a recursive-descent parser in Ruby for a grammar, which is defined by the following rules
Input consists of white-space separated Cards starting with a Stop-word,
where white-space is regex /[ \n\t]+/
Card may consist of Keywords or/and Values also separated by white-space,
which have card-specific order/pattern
Al...
I'm using ANTRL and this is my some grammar which give error to me.
statement
: (name)(
| BECOMES expression
| LPAREN (expression (COMMA expression)*)? RPAREN
| SHIFTLEFT name LPAREN (expression ( COMMA expression )*)? RPAREN
)
| OUTPUT LPAREN expression ( COMMA expression)* RPAREN
| IF expression THEN state...
For example,
EBNF
A ::= B c;
B ::= T1 | T2 | ε
T1 ::= a
T2 ::= b
parseA()
{
switch(currentToken.kind){
case Token.a :
parseT1();
case Token.b :
parseT2();
break;
case <epsilon> :
break;
default:
// report error
break;
}
}
How to write the parser parse the epsilon ( set of empty string ) in Java?
...