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
1 answer

java - cup parser allow me to do empty transitions in a grammar LALR?

hello guys i am new in cup parser, my problem is that in the define of trans in my grammar i have empty trans and my question is, is that correct? for example, in my grammar i have INIT -> A B -c- A -> A -a- | empty B -> B -b- | empty …
Edwin Aguilar
  • 45
  • 1
  • 7
1
vote
1 answer

How is it that the val() and rep() functions are called in this code(there's no definition for them)?

I'm using a parser generator called CUP. I was provided with the grammar (CUP specification) and this piece of supporting code (Expr.java) for the class definitions. In the CUP specification, the grammar productions have a semantic action…
1
vote
1 answer

Parser.cup using CUP in Java

Im trying to do a compiler in Java, and Im using CUP to generete the grammar for the syntax. I have this Parser.cup /* Terminals (tokens returned by the scanner). */ terminal PLUS, MINUS; terminal TIMES, DIV, DIVINT; terminal LPAREN,…
1
vote
1 answer

JFLEX AND CUP, cannot make it work correctly

I'm working with jflex and cup, trying to make a html parser, but can't make it work correctly, Netbeans, the compile process dont stop, always continues, Can't add more "tokens" correctly in the parse tree, Also can't add space in "TEXTO" , this…
Crashman
  • 146
  • 11
1
vote
1 answer

Compiler Construction for Formal Requirement Specification Language using JFlex and CUP

I am planning to build compiler for Requirement Specification Language. I have come up with idea using JFlex as lexical analyzer and CUP as parser. Can any one let me know it is possible to use JFlex and CUP for formal specification language? All…
man19688
  • 301
  • 1
  • 2
  • 6
0
votes
1 answer

How to set a package name for generated classes when using cup.gradle.cup-gradle-plugin?

The cup arg: -destdir does not work. With or without this option, the generated source files (parser and symbols) always in the top folder (build/generated-src/cup). For example as below, the expected destination folder is…
Zhen
  • 11
0
votes
0 answers

How to save a symbol value in CUP? java parser

I'm using CUP for a project but I'm not really sure how to save the value of the token TEXT into a String here´s my production: error_content ::= LEXEMA_START TEXT LEXEMA_END {: System.out.println("´text value" ); :} | LINE_START…
Ale
  • 3
  • 2
0
votes
1 answer

Conflict in ambiguous grammar due to ordered declaration of optional blocks

I need help defining some rules for a grammar in cups. The rules in question belong to the declaration block, which consists of the declaration of 0 or more constants, 0 or more type records, and 0 or more variables. An example of code to parser: x:…
0
votes
1 answer

Fixing Ambiguous Grammer in CUP

I am having problems with a grammer I am using to make a CUP Parser. The grammer is as follows: In CUP format. terminal PLUS, MINUS, TIMES, DIV, EQUALS, LESS, IF, THEN, ELSE, LET, EQ, IN, FUN , ARROW, LPAREN, RPAREN,…
0
votes
1 answer

Java CUP (Parser) produces a shift/reduce conflict when the type of a variable is user defined

My grammar needs to have custom types defined by the user, but the problem is that when I add tvariable ::= ENTERO | ID it generates the following: [cup] Warning : *** Shift/Reduce conflict found in state #21 [cup] between epsilon ::= (*) …
Aarón
  • 1
0
votes
1 answer

How to resolve a shift/reduce conflict for nested lists using the same separator in JFLEX/CUP?

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 containing lists of expressions). I boiled the problem…
greg.
  • 140
  • 10
0
votes
1 answer

Jflex and CUP not working on vscode and mac

I downloaded jflex by doing brew install jflex everything worked the way it should. But now when I'm trying to make it work with java_cup.runtime.*. And I keep getting the errors below Lexer.java:681: error: cannot find symbol { return new…
carlosdafield
  • 1,479
  • 5
  • 16
0
votes
1 answer

Error when run parsing using cup and jflex

I am new to JFlex and CUP. I am trying to do a simple example, but when I run the parser, it always gives the same error, it does not progress with the recognition of the statements. I think the problem must be in the productions or rules. I have…
Marco Osorio
  • 101
  • 8
0
votes
1 answer

Java cup, How to Inject a function after each reduce in the generated parser file?

I'm using .cup file to generate parser based on specific derivation rules. After every reduce, I want to call a function, Is it possible to define it anywhere in the .cup file, so that it will be injected into the generated code after each reduce?
BOB123
  • 176
  • 10
0
votes
1 answer

Shift/Reduce conflict found in state in Java Cup

I am trying to write parsing in java cup but I get conflict start with prog; prog ::= header; header ::= t1 t3 t2 | t3 t1 t2 | t2 t3 t1 | t1 t2 t3 | t2 t1 t3 | t3 t2 t1; t1 ::= TOK1; t2 ::= TOK2 | TOK2 TOK2 ; t3 ::= | t3 TOK3; I got this…
Neo
  • 119
  • 2
  • 11