Questions tagged [cup]

CUP is a parser generator for Java.

CUP generates Look-Ahead Left Recursive parser in Java.

It is related to two other projects:

  • is a scanner generator which can rely on CUP
  • Classgen is a tool to generate class frameworks and visitor patterns
76 questions
1
vote
0 answers

Shift Reduce Conflict (CUP)

I am trying define my grammar in my cup file and I'm getting the following errors. Warning : *** Shift/Reduce conflict found in state #4 between fielddecls ::= (*) and type ::= (*) INT under symbol INT Resolved in favor of…
1
vote
0 answers

Ply VS Jflex+Cup

I'm trying to build a compiler for a Pascal like language, and trying to decide between Ply(python) or a combination of Jflex+Cup(Java). I can't find any proper materials in order to evaluate which one is better. I want to know about performance,…
ElMassas
  • 367
  • 3
  • 18
1
vote
0 answers

Java CUP - Token value is null

I wanna print out the value of the tokens called in parser (returned by the scanner) however it shows null for each. For example when the input file is tmp := X*X; This grammar should print "tmp assigned" instead of "null assigned": assignment …
1
vote
1 answer

Need help in creating AST from cup in Java

I need to create AST in my code. I created classes Node and AST like helper class. public class Node { private String value; private String type; private Boolean visited; private Node leftChild, rightChild; public Node(){ …
Dragana
  • 11
  • 1
  • 3
1
vote
2 answers

How to match the empty case in CUP parser grammar

I am using CUP to generate a parser, and I want an empty file to be an acceptable program. I have tried add the empty case to my start symbol, based off the response to a similar question here. start with prog; /* The grammar rules */ prog ::=…
adhdj
  • 352
  • 4
  • 17
1
vote
1 answer

jflex / cup - error: cannot find symbol { return symbol(sym.EQEQ);

I'm trying to run the example on: http://jflex.de/manual.html#Example I've copied the example and only changed the file/class name. Running jflex seems to work fine. $ jflex -v -d output/ grammer/scanner.flex Reading…
0pen5pace
  • 11
  • 4
1
vote
1 answer

Is there a way to display the current parsing action using CUP and Jflex?

For my compilers class, we had to create a Lexical Analyzer and a Syntax Analyzer using JFlex and CUP. Part of the assignment also requires us to print out the tokens and corresponding parsing actions for a given input file. Additionally, the reduce…
84danie
  • 95
  • 1
  • 8
1
vote
1 answer

cup_v10k AST does not recognize Boolean

I am writing a compiler for a simple educational Java-like language. I am using cup_v10k.jar to generate the parser. I am using the AST CUP extension, to generate the abstract syntax tree. Along with other terminal symbols, in my parser.cup file i…
Nikola Bebić
  • 73
  • 1
  • 6
1
vote
0 answers

How to resolve Shift/Reduce conflict in simple grammar

The grammar is as follows: terminal TERM1,TERM2; non terminal entry, sector, unit_a, unit_b; entry ::= sector unit_b; sector ::= unit_a sector | unit_a; unit_a ::= TERM1 TERM1; unit_b ::= TERM1 TERM2; When i try to generate the parser…
DerZa
  • 11
  • 1
1
vote
1 answer

How to use Jlex and Cup tools

i'm trying to learn something about JFlex and Cup tools on Ubuntu, because i have to use them for a school project. So i downloaded and installed JFlex and Cup. There are some examples in "jflex-1.6.1/examples", so i tried to run one of them. In…
Furabio JZ4
  • 145
  • 1
  • 7
1
vote
1 answer

Shift/Reduce conflict in CUP

I'm trying to write a parser for a javascript-ish language with JFlex and Cup, but I'm having some issues with those deadly shift/reduce problems and reduce/reduce problems. I have searched thoroughly and have found tons of examples, but I'm not…
1
vote
0 answers

How get Expressions using Java Cup for Java Interpreter

I am creating a Interpreter using jflex and cup, but i dont know how to implements a nested statements, if else loops etc. I want to know if i can get a expression inside a statement to analyze it si ::= SI LPAREN ID:id COMMA ENTERO:value…
1
vote
1 answer

Shift/Reduce conflict in Java Cup

I'm getting the following error: Warning : *** Shift/Reduce conflict found in state #2 between ExitLoopStatement ::= EXITLOOP (*) and VarAccess ::= (*) DOLLAR IDENTIFIER under symbol DOLLAR This is the grammar I use. Currently I have…
berendeanicolae
  • 100
  • 1
  • 8
1
vote
1 answer

I cant generate CUP parser and JFlex scanner in cmd

i'm new in compiler . i've read that i can generate xxx.flex file in cmd by this code : java JFlex.Main xxx.flex but i got this error : Error: Could not find or load main class JFlex.Main and for generating yyy.cup , i typed : java…
Eng.sabbath
  • 111
  • 1
  • 1
  • 8
1
vote
1 answer

How to create a lambda symbol at jflex?

I'm doing a syntactic Analixer with jflex + javacup. At the .cup gramatic I have this part: SUBPPARAMLIST ::= lambda | "(" EXPLIST ")" Where lambda mean nothing (SUBPPARAMLIST can be empty) Well, I managed to create all my tokens correctly in my…