What is the actual difference between LR, SLR, and LALR parsers? I know that SLR and LALR are types of LR parsers, but what is the actual difference as far as their parsing tables are concerned?
And how to show whether a grammar is LR, SLR, or LALR? For an LL grammar we just have to show that any cell of the parsing table should not con...
Considering the following grammar
S -> iEtES'|a
S'-> eS
S'->
E-> b
What will the value of FOLLOW(S'). I know that if there is a production fo the form `A->aB' then everything in FOLLOW(A) is in FOLLOW(B) but corresponsind to the above grammar FOLLOW(S') is same as FOLLOW(S) then what is FOLLOW(S)?
Whether this rule will be applied fo...
How to specify a fixed digit number in antlr grammar?
I want to parse a line which contains fields of fixed number of characters. Each field is a number.
0034|9056|4567|0987|-2340| +345|1000
The above line is a sample line. | indicates field boundaries (which will not be in the actual file. shown here just to indicate the boundary).
...
Lets say the same grammar is not LR(1), can we safely say that the grammar is not LALR too?
if not, what are the conditions for a grammar to be LALR? (or what are the conditions that make a grammar not LALR)
Thanks for the help!
...
I'm having a bit of trouble understanding how to obtain the lookahead token for LR(1).
I'm hoping that someone can post a small example, and explain it to me.
Thanks for the help!
...
P-> Q | ε
Q-> m | m Q
S0:
S' ->.P, $
P -> .Q, $
P -> ., $
Q -> .m, $
Q -> .mQ, $
< Arrow from S0 to S2 moving with m>
S2:
Q-> m., $
Q-> m.Q, $
Q-> .m, $
Q-> .mQ, $
< Arrow from S2 to S3 moving with Q>
S3:
Q-> mQ., $/m
Can someone explain how why the lookahead token "m" is in S3?
Thanks a lot for the help!
...
I'm developing a new object oriented scripting language and the project itself is quite ready for audience now, so i'm starting to think about a serious (not as "drafty" as it is right now) way of document its grammar, functions from standard library and standard library classes.
I've looked a bit around and almost every language hash it...
I am experimenting with lex and yacc and have run into a strange issue, but I think it would be best to show you my code before detailing the issue. This is my lexer:
%{
#include <stdlib.h>
#include <string.h>
#include "y.tab.h"
void yyerror(char *);
%}
%%
[a-zA-Z]+ {
yylval.strV = yytext;
return ID;
}
[0-9]+ {
yylval.intV...
Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L?
A) (0*10*1)*
B) 0*(10*10*)*
C) 0*(10*1)* 0*
D) 0*1(10*1)* 10*
According to me option D is never correct because it does not represent the bit string with zero 1s. But ...
Hello all,
I'm doing some small projects which involve having different syntaxes for something, however sometimes these syntaxes are so easy that using a parser generator might be overkill.
Now, when should I use a hand-made parser, and when should I use a parser generator?
Thanks,
William van Doorn
...
Hi there i have a flex rule inside my lexer definition :
operators "[]"|"[]="|"[]<"|".."|"."|".="|"+"|"+="|"-"|"-="|"/"|"/="|"*"|"*="|"%"|"%="|"++"|"--"|"^"|"^="|"~"|"&"|"&="|"|"|"|="|"<<"|"<<="|">>"|"!"|"<"|">"|">="|"<="|"=="|"!="|"&&"|"||"|"~="
Is there any way to split this ruole on more lines to keep it clearer?
I tried with \ ju...
Hi
Is there any existing tool to strip all the action code from bison grammar files, leaving only the {} around it?
...
I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form.
...
Hello all,
I'm writing a simple scripting language on top of Java/JVM, where you can also embed Java code using the {} brackets. The problem is, how do I parse this in the grammar? I have two options:
Allow everything to be in it, such as: [a-z|a-Z|0-9|_|$], and go on
Get an extra java grammar and use that grammar to parse that small ...
I'd like to generate completely random piece of html source, possibly from a grammar. I want to do this in python but I'm not sure how to proceed -- is there a library that takes a grammar and just randomly follows its rules, printing the path?
Ideas?
...
hello
i have the following sentence
a language L1={a^n * b^n : n>=0} and L2={b^n * a^n : n>=0} are context free languages so they are close a=under the L1L2 so L={a^n * b^2n A^n : n>=0} must be context free too because it is generated by a close property
I have to prove if this sentence is true or not
so i check the L language and i do...
In the Java Generic Book, while contrasting the difference between C++ Templates and Java Generic says:
In C++, a problem arises because >>
without the space denotes the
right-shift operator. Java fixes the
problem by a trick in the grammar.)
What is this trick?
...
I'm OCaml newbie and I'm trying to write a simple OCaml-like grammar, and I can't figure this out. My grammar allows something like this:
let sub = fun x -> fun y -> x - y;;
However, if I want to use the function so defined, I can write: (sub 7) 3 but I can't write sub 7 3, which really bugs me. For some reason, it gets interpreted as...
Does the standard specify the official C++ grammar?
I searched, but did not find it anywhere.
Also, I wish to read a bit about C++ grammar in detail, like which category of grammars it falls in, etc. Any links pointing me in the right direction would be helpful.
By category, I mean
taken from here.
...
I'm trying to get the basic of Treetop parsing. Here's a very simple bit of grammar so that I can say ArithmeticParser.parse('2+2').value == 4.
grammar Arithmetic
rule additive
first:number '+' second:number {
def value
first.value + second.value
end
}
end
rule number
[1-9] [0-9]* {
def value...