commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18284] New: - use SKIP instead of SPECIAL_TOKEN in parser?
Date Mon, 24 Mar 2003 17:54:01 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18284>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18284

use SKIP instead of SPECIAL_TOKEN in parser?

           Summary: use SKIP instead of SPECIAL_TOKEN in parser?
           Product: Commons
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: Eric.D.Friedman@wellsfargo.com


There may be a good reason why this wasn't already done, but since I couldn't
see one right off and since you can always reject this e.r., I'm logging it anyway.

The XPath.jj file from with JXPath's parser is generated includes this in its
lexical spec:

/*----------------------------*/
/* Skip Whitespace everywhere */
/*----------------------------*/


/* [39]    ExprWhitespace    ::=    S  */
SPECIAL_TOKEN :
{
    <S: ( [" ", "\t", "\n", "\r"] )+>
}

Given that the <S> token is never used, why not use SKIP instead?

SKIP :
{
  [" ", "\t", "\n" , "\r", "\f"] // note addition of "\f"
}

This has a couple of advantages: (1) it eliminates the need for the lexer to
create an instance of Token that gets attached as a "special" to real tokens you
care about (since you don't seem to be using the <S> token, why create it?); (2)
using a simple character class is slightly faster than a character class with a
kleene + around it.

I didn't look very closely, so perhaps there's a place where the <S> token is
used after all.  If so, you can disregard this suggestion.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message