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

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

Comments

Projects
None yet
1 participant
@lsf37
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 from Macro error on regexp negation (!) to [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 Feb 15, 2015

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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

Member

lsf37 commented Feb 15, 2015

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

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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
Member

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

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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

Member

lsf37 commented Feb 15, 2015

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

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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

  • status: pending --> open
Member

lsf37 commented Feb 15, 2015

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

  • status: pending --> open
@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

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

  • status: open --> closed
Member

lsf37 commented Feb 15, 2015

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

  • status: open --> closed

@lsf37 lsf37 added the bug 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