Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Macro error on regexp negation (!) [sf#55] #57

Closed
lsf37 opened this issue Feb 15, 2015 · 6 comments
Closed

[Bug] Macro error on regexp negation (!) [sf#55] #57

lsf37 opened this issue Feb 15, 2015 · 6 comments
Labels
bug Not working as intended

Comments

@lsf37
Copy link
Member

lsf37 commented Feb 15, 2015

Reported by deadsea on 2002-09-18 14:33 UTC
I tried to create a lexer for SQL which is an
interesting beast.
SQL has a rule that says operators can be any
combination of certain characters except for
combinations that would start a comment.

I tried to implement this using the regexp negation
feature of JFlex but I get a macro error. I'm trying
to do the the expression that matches everything of a
not matched by b as specified in the user manual: !(!a|b)
I create a very loose definition of an operator (a) and
then a definition for things that look they they are an
operator, but aren't (b).

I am attaching a test case that demonstrates this.

If you modify it to compile, you can run:
jflex Test.jflex
javac Test.java
java Test

(I'm using JFlex 1.3.5)

@lsf37 lsf37 changed the title Macro error on regexp negation (!) [Bug] Macro error on regexp negation (!) [sf#55] Feb 15, 2015
@lsf37 lsf37 added this to the jflex bug milestone Feb 15, 2015
@lsf37 lsf37 closed this as completed Feb 15, 2015
@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Commented by deadsea on 2002-09-18 14:33 UTC
Compile error on regexp negation.

@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Commented by lsf37 on 2002-09-25 13:18 UTC
Logged In: YES
user_id=93534

I can't completely reproduce the error. If I run JFlex (1.3.5) on
your example, I don't really get a macro error, but (wrong)
warnings. I've found a bug in the macro expansion which I
think is what you're experiencing (it doesn't descend into
negated expressions, this should affect the warnings only,
though).

If I run the example, I get:

kleing@kosh:> jflex Test.flex
Reading "Test.flex"

Warning : Macro "operatorChar" has been declared but never
used.

Warning : Macro "illegalOperator" has been declared but
never used.
Constructing NFA : 87 states in NFA
Converting NFA to DFA :
.............
15 states before minimization, 11 states in minimized DFA
Writing code to "Test.java"
kleing@kosh:> javac Test.java
kleing@kosh:> java Test
Operator: #
Operator: #
Operator: /
Operator: #
Comment: /* comment */
Operator: #
Comment: -- comment

The result seems to be ok according to the spec (although I
confess, I've not analyzed it thouroughly). If I remove the
comments in the spec, I get another warning:

Rule can never be matched:
<YYINITIAL> ({operator}) {

This warning is correct, though, because the rule above it (
{operatorChar}+) is a superset of {operator}.

As a quick fix for the warnings, I've attached a replacement for
JFlex.jar that does the warnings properly (it should report
1.4_pre3 as version number).

Is this the error you meant, or is it something completely
different?

@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2002-09-25 13:18 UTC

  • milestone: --> jflex bug
  • assigned_to: nobody --> lsf37
  • priority: 5 --> 7
  • labels: --> frontend/syntax
  • status: open --> pending

@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Commented by lsf37 on 2002-09-25 13:20 UTC

@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2002-09-25 13:20 UTC

  • status: pending --> open

@lsf37
Copy link
Member Author

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2004-04-12 12:26 UTC

  • status: open --> closed

@lsf37 lsf37 added the bug Not working as intended label Feb 17, 2015
@lsf37 lsf37 modified the milestone: jflex bug Feb 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Projects
None yet
Development

No branches or pull requests

1 participant