Re: [jflex-users] Syntax error for a regex rule
The fast lexer generator for Java
Brought to you by:
lsf37,
steve_rowe
From: Denis W. <ddw...@gm...> - 2009-11-29 18:50:45
|
And another simple question. Does JFlex support for the following kind of variable character length unicodes? CHAR = \u9 | \uA | \uD | [\u20-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] Cherrs, Dhananjaya 2009/11/29 Peter L. Bird <pb...@co...> > You need to escape your quote characters. Try this: > > VALUE = '\"' ([^<&\"] | [0-9])* '\"' | "\'" ([^<&\'] | [0-9])* "\'" > > personally, i find the following more readable: > > VALUE = ([\"] ([^<&\"] | [0-9])* [\"]) | ([\'] ([^<&\'] | [0-9])* [\']) > > > Unless i'm mistaken, your inner patterns are redundant. That is, the > numeric characters*[0-9]*are part of the set specified in*[^<&\"] *( or [^<&\']). > The rewrite would look like: > > VALUE = ('\"' [^<&\"]* '\"') | ("\'" [^<&\']* "\'") > > cheers, > > peter bird > > > At 09:21 AM 11/29/2009, Denis Weerasiri wrote: > > Hi folks, > I'm new to JFlex and regex. > I get a syntax error when generate using .flex file. My .flex is sm thing > like as follows. > > %% > VALUE = '"' ([^<&"] | [0-9])* '"' | "'" ([^<&'] | [0-9])* "'" > %% > {VALUE} { return symbol(sym.VALUE); } > > > I get an error message as follows. > > Reading > "/home/hdd2/Acedemic/L4-S1/CS4410-CompTheory/project/Tokenizer.flex" > > Error in file > "/home/hdd2/Acedemic/L4-S1/CS4410-CompTheory/project/Tokenizer.flex" (line > 54): > Syntax error. > > VALUE = '"' ([^<&"] | [0-9])* '"' | "'" ([^<&'] | [0-9])* "'" > ^ > > Error in file > "/home/hdd2/Acedemic/L4-S1/CS4410-CompTheory/project/Tokenizer.flex" (line > 54): > Unterminated string at end of line. > > VALUE = '"' ([^<&"] | [0-9])* '"' | "'" ([^<&'] | [0-9])* "'" > ^ > 2 errors, 0 warnings. > > Generation aborted. > > Can anyone give me a clue to solve this? > > Best, > Dhananjaya. > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > -- > jflex-users mailing list > https://lists.sourceforge.net/lists/listinfo/jflex-users > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.426 / Virus Database: 270.14.87/2534 - Release Date: 11/29/09 > 07:49:00 > > |