flex-lexer

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) {

How can flex return multiple terminals at one time

故事扮演 提交于 2021-01-27 18:51:22
问题 In order to make my question easy to understand I want to use the following example: The following code is called nonblock do-loop in fortran language DO 20 I=1, N ! line 1 DO 20 J=1, N ! line 2 ! more codes 20 CONTINUE ! line 4 Pay attention that the label 20 at line 4 means the end of both the inner do-loop and the outer do-loop. I want my flex program to parse the feature correctly: when flex reads the label 20 , it will return ENDDO terminal twice. Firstly, because I also use bison, so

yylex errors for simple parser generator

橙三吉。 提交于 2021-01-07 01:29:21
问题 I'm just doing a homework assignment where i have to make a simple polynomial parser generator. So it has to accept assignment like: a= 2x2+2 and also evaluation like a[2] will print 10. If a is entered alone it should print 2x2+2. It should work for any polynomial. There is a typedef struct defined in another file which I'm supposed to use: typedef struct Polyn { int sign; int coeff; int exp; struct Polyn *next; } Polyn; lex file: %option noyywrap %{ #include <stdio.h> #include <string.h>

Only part of matched string in flex in yytext

浪尽此生 提交于 2020-07-09 03:07:36
问题 I'm a newbie but I would like to know if I can, with flex, parse something with regex in a way yytext would only be part of the matched sequence. For example: @abcd{efgh, . I would like to match abcd once and use it then efgh, but I need to use the @ and the { to match them. Is this possible or do I have to process it entirely later in C? 回答1: You can use following context with the '/' operator. For eaxmple, abcd/efgh will match the string "abcd" only if its followed by "efgh", with the