cup

JFLEX AND CUP, cannot make it work correctly

大兔子大兔子 提交于 2021-01-29 01:42:48
问题 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 break the entire tree lexicoh.jlex package compiladorhtml; import java_cup.runtime.*; %% %class Lexer %line %column %cup %{ private Symbol symbol(int type) { return new Symbol(type, yyline, yycolumn); } private Symbol symbol(int type, Object value) {

JFLEX AND CUP, cannot make it work correctly

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 01:42:07
问题 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 break the entire tree lexicoh.jlex package compiladorhtml; import java_cup.runtime.*; %% %class Lexer %line %column %cup %{ private Symbol symbol(int type) { return new Symbol(type, yyline, yycolumn); } private Symbol symbol(int type, Object value) {

Concatenation shift-reduce conflict

别等时光非礼了梦想. 提交于 2020-01-04 06:22:09
问题 I have a simple grammar for JavaCUP's LR(1) parser that recognises concatenation expressions of identifiers and strings. I also want to add some empty function calls as a possible concatenation argument. However, when I try that, it leads to a shift/reduce conflict. Grammar: precedence left PLUS; e ::= e exp | exp; exp ::= concat | literal; concatenation ::= exp PLUS exp | LPAREN exp RPAREN; literal ::= IDENTIFIER | STRING | IDENTIFIER LPAREN RPAREN; // THIS PRODUCES THE ERROR Input: x + x +

Shift/Reduce conflict in CUP

我是研究僧i 提交于 2019-12-24 20:11:17
问题 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 able to extrapolate these to my grammar. My understanding so far is that these problems are because the parser cannot decide which way it should take because it can't distinguish. My grammar is the following one: start with INPUT; INPUT::= PROGRAM;

How to match the empty case in CUP parser grammar

你说的曾经没有我的故事 提交于 2019-12-24 06:30:00
问题 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 ::= class_block:cb | class_block:cb stmts:sb | stmts:sb | // desired empty case ; Including the desired empty case gives me the following error: parser.java:516: error: incompatible types: Object cannot be converted to Symbol CUP$parser$result = parser

Parse tree generation with Java CUP

大憨熊 提交于 2019-12-22 08:07:03
问题 I am using CUP with JFlex to validate expression syntax. I have the basic functionality working: I can tell if an expression is valid or not. Next step is to implement simple arithmetic operations, such as "add 1". For example, if my expression is "1 + a", the result should be "2 + a". I need access to parse tree to do that, because simply identifying a numeric term won't do it: the result of adding 1 to "(1 + a) * b" should be "(1 + a) * b + 1", not "(2 + a) * b". Does anyone have a CUP

Parse EOF token in CUP

≡放荡痞女 提交于 2019-12-13 04:29:19
问题 I'm having trouble making my CUP parser parse the EOF token. I read in the documentation that using the %cup flag in my Jflex code implies that there is something present like this: %eofval{ return new java_cup.runtime.Symbol(<CUPSYM>.EOF); %eofval} %eofclose This is all good and well, but when I try the following first rule in my grammar (CUP file): program ::= program declaration EOF | /* Empty */ ; I get the error message that EOF is not declared by CUP. Error : java_cup.runtime.Symbol

shift/reduce Error with Cup

做~自己de王妃 提交于 2019-12-01 11:51:58
问题 Hi i am writing a Parser for a Programming language my university uses, with jflex and Cup I started with just the first basic structures such as Processes an Variable Declarations. I get the following Errors Warning : *** Shift/Reduce conflict found in state #4 between vardecls ::= (*) and vardecl ::= (*) IDENT COLON vartyp SEMI and vardecl ::= (*) IDENT COLON vartyp EQEQ INT SEMI under symbol IDENT Resolved in favor of shifting. Warning : *** Shift/Reduce conflict found in state #2 between

Shift/reduce conflict in java cup - dangling else issue

耗尽温柔 提交于 2019-12-01 07:15:26
I am getting the following error: Warning : *** Shift/Reduce conflict found in state #116 between Statement ::= Matched (*) and Unmatched ::= IF LPAREN Condition RPAREN Matched (*) ELSE Unmatched and Matched ::= IF LPAREN Condition RPAREN Matched (*) ELSE Matched under symbol ELSE Resolved in favor of shifting. Now, i am aware of the dangling else problem, and i have tried making the grammar unambiguous: Statement ::= Matched | Unmatched ; Matched ::= IF LPAREN Condition RPAREN Matched ELSE Matched | Others ; Unmatched ::= IF LPAREN Condition RPAREN Statement | IF LPAREN Condition RPAREN

Shift/reduce conflict in java cup - dangling else issue

假如想象 提交于 2019-12-01 04:30:00
问题 I am getting the following error: Warning : *** Shift/Reduce conflict found in state #116 between Statement ::= Matched (*) and Unmatched ::= IF LPAREN Condition RPAREN Matched (*) ELSE Unmatched and Matched ::= IF LPAREN Condition RPAREN Matched (*) ELSE Matched under symbol ELSE Resolved in favor of shifting. Now, i am aware of the dangling else problem, and i have tried making the grammar unambiguous: Statement ::= Matched | Unmatched ; Matched ::= IF LPAREN Condition RPAREN Matched ELSE