jflex

Is inheritance possible in JFlex?

I'm fairly new to JFlex and JSyntaxPane although I have managed to hack together a lexer for XPath. The problem I find myself in is that I'm working on a project that supports a subset of XPath with a few proprietary features. Nasty I know. If this were a regular Java problem I'd turn to inheritance but it doesn't seem possible to ach...

Keeping track of state in JFlex

I'm writing a custom flex file to generate a lexer for use with JSyntaxpane. The custom language I need to lex has different states that can be embedded into each other in a kind of stack. I.E you could be writing an expression that has a single quoted string in it and then embed another expression within the string using a special tok...

Matching Lua's "Long bracket" string syntax

I'm writing a jFlex lexer for Lua, and I'm having problems designing a regular expression to match one particular part of the language specification: Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs fo...

Is there a jflex specification of java string literals somewhere ?

And by string literals I mean those containing \123-like characters too. I've written something but I don't know if it's perfect: <STRING> { \" { yybegin(YYINITIAL); return new Token(TokenType.STRING,string.toString()); } \\[0-3][0-7][0-7] { string.append( ...

distinguishing a string with flex

Hi, I need to tokenize some strings which will be splitted of according to operators like = and !=. I was successful using regex until the string has != operator. In my case, string was seperated into two parts, which is expected but ! mark is in the left side even it is part of given operator. Therefore, I believe that regex is not sui...

using JFlex instead of Regex

Hello, I am new to JFlex. I have gathered that JFlex is a parser generator. However, I am still not clear about the following and need clarification around the same. How different this is from using regex for pattern identification and data segregation and what are the additional benefits of using JFlex. Any specific use case where JF...

What is an example of a lexical error and is it possible that a language has no lexical errors?

for our compiler theory class, we are tasked with creating a simple interpreter for our own designed programming language. I am using jflex and cup as my generators but i'm a bit stuck with what a lexical error is. Also, is it recommended that i use the state feature of jflex? it feels wrong as it seems like the parser is better suited t...

How do I use regular expression capturing groups with JFlex?

Although this question is about JFlex, it probably applies to other scanner generators such as lex, gnu-flex as well. If I have some rule, how can I create a capturing group in part of that rule and use the result of that captured group as an argument to the code that gets called upon the rule matching? For example, let's say I had a s...