Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
96 views

I'm writing an LALR(1) parser generator, and am getting a bit confused about the use of the GOTO function in creating the parsing table. I've been following the dragon book. The grammar I have been ...
sudgy's user avatar
  • 583
0 votes
0 answers
32 views

My grammar file looks like this: https://github.com/EmptyDreams/php-parser/blob/master/src/main/resources/php.cup When I build it using java-cup, I encounter a Reduce/Reduce conflict: Warning : *** ...
kmar's user avatar
  • 13
1 vote
0 answers
53 views

I am writing a microJava compiler and I am currently implementing class logic. So far I have implemented field logic but I am struggling with method access. The code bellow is working properly (for ...
Nikola Nikolić's user avatar
1 vote
1 answer
245 views

S → 0S0 S → 1S1 S → 10 found 2 possible paths on canonical item i3 for 0 input. in my solution: I0 was S'-> .S S → .0S0 S → .1S1 S → .10 I1 was(S input from I0) S'-> S.(accept) I2 ...
Vansh Guleria's user avatar
1 vote
1 answer
535 views

I have to construct LR(0) table to know if there are any sort of conflicts? Is there a way to look at the grammar and tell if there's a conflict without constructing the table? So yeah, the question ...
Pavel Averin's user avatar
0 votes
1 answer
36 views

I am getting shift/reduce conflict The following is my .cup specification: terminal PROG, SEMI, RANGE, VOID; terminal PP, MM, READ, LPAREN, RPAREN, DCOL; terminal MUL, DIV, MOD, ...
dm98's user avatar
  • 63
0 votes
1 answer
96 views

I'm trying to implement an LR1 Parser, using the help in this wikipedia article. I have made a closure function for the LR0 Items, and when trying to make a closure for the LR1 items (the part about ...
Chris Geo's user avatar
2 votes
0 answers
129 views

According to the dragon book, the algorithm for LR(1) state machine is: initialize C to Closure([S` -> .S, $]) repeat for each state in C for each grammar symbol X if Goto(...
user's user avatar
  • 21
-1 votes
2 answers
658 views

I have the following grammar: S -> aSb S -> c It can be used for LR(1) parsers are there is no conflict. However, when I combine states with same LR(0) items and different lookaheads, I get a ...
Lobster3221's user avatar
1 vote
0 answers
54 views

Can the following ABNF rules be written as a bison LALR grammar without any conflicts (shift/reduce or reduce/reduce)? Among them, lowercase letters are non-terminal symbols, and uppercase letters are ...
neorobin's user avatar
  • 139
0 votes
1 answer
83 views

The algorithm for computing the lookaheads](https://i.sstatic.net/T3Yzb.jpg)](https://i.sstatic.net/T3Yzb.jpg) The algorithm says to compute $CLOSURE( { [A \rightarrow \alpha . \beta , # ]}) $ In the ...
Metric's user avatar
  • 111
0 votes
2 answers
105 views

I would like to use Lark to generate a standalone parser for a small rational language of mine. This needs to be a LALR(1) parser. It should accept the following input: (lorem) consectetur adipiscing ...
Aristide's user avatar
  • 4,124
0 votes
1 answer
148 views

I am having trouble understanding what the rules are for adding a lookahead to a core production during the construction of the DFA. To illustrate my confusion, I will be using an online parser ...
Stephen Rodriguez's user avatar
0 votes
1 answer
112 views

Is there a general algorithm that turns a given grammar into LR(0) grammar? I tried turning the grammar into CNF but even when I succeeded it didnt work out to be LR0
Abdullah Garra's user avatar
0 votes
1 answer
388 views

I'm following Appel's book Modern Compiler Implementation in ML and am trying to write a grammar for Tiger. Here's my first attempt: %% %term EOF | ID of string | INT of int | STRING of ...
Bridge's user avatar
  • 105
0 votes
1 answer
72 views

everybody! When I learn dragon book, I encountered some trouble. I can't understand the first step in Eaxmple-4.64, which appears in subsection 4.7.5 and page 273. Problem At first, Eaxmple-4.61 gives ...
dtwang's user avatar
  • 1
1 vote
1 answer
164 views

Since LR (1) grammars are broader than LALR or SLR grammars, I have doubts regarding the proof of LR grammars. If a grammar is SLR or LALR, then does that mean that the grammar is also LR (1)? In fact,...
xXMarcoXx's user avatar
0 votes
1 answer
132 views

I'm trying to implement a parser in JFLEX/CUP (JFlex 1.8.2, Cup 0.11b) for a language in which lists containing different kinds of elements can be nested (e.g. lists of statements and statements ...
user11718766's user avatar
0 votes
0 answers
135 views

I'm trying to write a simple LALR parser for a custom DSL. My grammar looks like this : main : stmts stmts : expr stmts | expr : arithmetics | function_call | VARNAME | INT ...
ibi0tux's user avatar
  • 2,649
1 vote
1 answer
145 views

Let's say I have got a set of LR(1) states and I want to try to convert it to LALR(1). I did the first step of finding states that have got the same LR(0) core and now I'm doing the merge process. ...
Felix.leg's user avatar
  • 843
0 votes
0 answers
111 views

I was writing an LALR(1) parser for a simple arithmetic grammar E -> E ('+' | '-') T E -> T T -> T ('*' | '/') F T -> F F -> '( E ')' F -> int How would I handle operator precedence ...
ishaangupte's user avatar
0 votes
0 answers
166 views

I'm trying to parse using Python Lark the output of a plan from a database. Here's my grammar: start: op op: command "(" op ")" "[" text "]" | command &...
Antonis Karvelas's user avatar
0 votes
1 answer
153 views

I wrote a pretty simple left-recursive grammar in yacc, based on data types for a simple C-like language. The generated yacc parser reduces before the left recursion suffix, and I have no clue why. ...
Daniel F.'s user avatar
-1 votes
1 answer
92 views

I have to admit I'm an absolute newbie in this and might not even understand what I am doing. I am trying to make a grammar that at least contains grammar from BABA IS YOU, and if possible expands on ...
Ludwig Von Chesterfield's user avatar
0 votes
0 answers
103 views

I am writing a grammar where I'd like certain functions to be only at the top-level of the expression while arithmetic operations can be anywhere. E.g. 4 + (5 * 9) is correct, FUNC(2 + 4) * 8 - FUNC(4)...
Milos Ljumovic's user avatar
1 vote
1 answer
426 views

Can someone please explain to me why an LR(1) grammar that is not LALR(1) must have only reduce/reduce conflicts
django's user avatar
  • 53
1 vote
1 answer
371 views

I have strings with words like this: "ABC Some other stuff" (normaly there is a short letter combination at the beginning) "Some other stuff" (sometimes there is nothing ...
HrkBrkkl's user avatar
  • 723
1 vote
1 answer
877 views

I'm porting a code from pyparsing to SLY, it's a lambda calc grammar. I have this rule from sly import Lexer, Parser class Lex(Lexer): tokens = {ID, LAMB, DOT, LPAR, RPAR} ID = r"[a-z]&...
geckos's user avatar
  • 6,449
0 votes
0 answers
100 views

I have this grammar S-> Stat Stat -> Exprs WRITE Stat -> Vars READ Vars -> ID COMMA Vars Vars -> ID Exprs -> Expr COMMA Exprs Exprs -> Expr Expr -> ID Expr -> ... ... (You ...
Alexander's user avatar
0 votes
1 answer
224 views

I am feeding a (generated) grammar to Beaver parser generator. Multiple shift-reduce conflicts are caused by it seems like the dangling else problem in this rules: Condition = IF LPAR Expression....
Hawk's user avatar
  • 2,132
0 votes
1 answer
427 views

By all accounts, LR(1) should be more powerful in every way compared to LALR(1) since LR(1) builds a canonical collection of LR(1) items, and LALR(1) is just a better SLR(1) parser. Then why does this ...
Raiyyan Siddiqui's user avatar
0 votes
2 answers
1k views

I know that LALR(1) grammars are a subset of LR(1) grammars and most of the time LALR(1) parsing table is much smaller than LR(1) parsing table for the same grammar. But I couldn't find the answer on ...
qalis's user avatar
  • 1,599
1 vote
1 answer
939 views

Given are the following lark grammar and Python source code: start: (TEXT _NEWLINE)+ TEXT: /[^\n]+/ COMMENT: /\/\/[^\n]*/ _NEWLINE %ignore COMMENT _NEWLINE: (" "* "\n")+ from lark import Lark ...
Scriptim's user avatar
  • 1,842
1 vote
1 answer
381 views

I had lots of conflicts, most of them were due to operators and relational operators which had different precedences. But I still face some conflicts that I don't really know how to tackle them. some ...
mgh's user avatar
  • 407
0 votes
1 answer
2k views

Ply is reporting that the it has encountered numerous shift/reduce conflicts while using the grammar I've entered to build a LALR parser. Right now I'm trying to resolve these conflicts but whatever ...
mgh's user avatar
  • 407
2 votes
0 answers
514 views

I've been trying to set up a rather simple math parser, and it's been working fine. Only I can't figure out how to put in implied multiplication. I've been using lark as an lalr(1) parser. Here's ...
weakit's user avatar
  • 236
2 votes
2 answers
259 views

OK, my adventures with my parser generator continued. This time I got my hands on a classic grammar, which is said to be a LALR grammar: start -> a a a -> "A" a a -> "B" When I put it into ...
Felix.leg's user avatar
  • 843
0 votes
2 answers
156 views

I started a project with a grammar that used % (and the word mod) for modulus operators, and now I would like to add % as a trailing unary operator to divide by 100. A few notes, I don't work with a ...
Marius's user avatar
  • 3,517
0 votes
0 answers
393 views

Recently I wrote a (highly optimized) LALR(1) parser (that could handle ambiguous grammars) and supplied it a very ambiguous grammar. After that, I wrote a recursive descent parser for the same ...
xilpex's user avatar
  • 3,305
1 vote
1 answer
103 views

While searching for Bison grammars, i found this example of C grammar: https://www.lysator.liu.se/c/ANSI-C-grammar-y.html logical_and_expression : inclusive_or_expression | ...
Growlnx's user avatar
  • 13
0 votes
1 answer
254 views

I have read that yacc generates bottom up parser for LALR(1) grammars. I have a grammar for Java 1 that can be used for generating three address code and is strictly LALR(1), but the translation ...
Shashank Kumar's user avatar
0 votes
1 answer
146 views

I have had a shift-reduce conflict and reduced it to a couple of lines: start : instruction_A; instruction_A : instruction_A instruction | ...
Afonso Matos's user avatar
  • 2,496
1 vote
1 answer
182 views

In a yacc-based project I've encountered a complex expression which I don't understand what it does. The expression is repeated multiple times, so it looks like copy-and-paste. In fact the same exact ...
thoni56's user avatar
  • 3,413
1 vote
1 answer
167 views

I have put together a grammar in Lemon (which is similar to YACC) but it is producing an S/R conflict. I am not used to LALR parsing and don't understand what the problem is, nor how to resolve it. ...
Evgeniy Yakovich's user avatar
2 votes
1 answer
369 views

Here is a QML grammar (extracted from https://github.com/kropp/intellij-qml/blob/master/grammars/qml.bnf): /* identifier, value, integer and float are terminals */ qml ::= object /* Simplified */ ...
Swordow's user avatar
  • 35
0 votes
1 answer
403 views

I'm confused on how to parse this grammar using LR(1): S -> A A -> A(A) | empty I'm aware there is left recursion but I was told it isn't necessary to remove it for LR(1). My item sets look ...
Ryan Foster's user avatar
0 votes
1 answer
182 views

I'm having trouble parsing the following grammar using the LALR method. s -> y y -> dX | ydX X -> e | Zd z -> F | epsilon I'm ok at the beginning, here is item state 0: (the , seperates ...
Ryan Foster's user avatar
1 vote
1 answer
801 views

I am studying for a final in Language Theory and one question asks the following: If you have a parsing table T in LR(1) and a parsing table T' in LALR(1) for the same grammar. Is it possible that T' ...
acasla's user avatar
  • 141
0 votes
1 answer
71 views

I have a yacc parser in which commands like "abc=123" (VAR=VAR), abc=[1 2 3] (VAR=value_series/string) and abc=[[123]] can be parsed. I need to parse abc=[xyz=[1 2 3] jkl=[3 4 5]].This grammar is ...
goldcommode's user avatar
7 votes
2 answers
1k views

I try to learn about language parser recently and always seen the review about difference in Yacc and Antlr (about LALR and LL). It was always some concluded wording like "LALR is more powerful". But ...
Thaina Yu's user avatar
  • 1,552