|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Doublequotes and Backslashes...Hello again,
I am new to Javacc, so there might be a very obvious solution to this. I'm trying to parse a) "ABC\\" and b) "\\ABC" by somestuff() below. [<= both as they are, NOT escaped, 2 backslashes] In case of: a) the normalString() is used by javacc -> clearly not intended b) there is an exception: Lexical error at line 1, column 1. Encountered: "\\" (92), after : "" ------------------------------ options{ IGNORE_CASE=false ; JAVA_UNICODE_ESCAPE= true ; } PARSER_BEGIN(Test) package Mini; public class Test {} PARSER_END(Test) TOKEN : { < T_ASTERISK: "*"> | < T_QUOTED: ( (" ") ("\\\\") ("\\\"") ["a"-"z","A"-"Z","_","-","0"-"9",":"] )+ > | < T_PROPERTY: ( ["a"-"z","A"-"Z","_","-","0"-"9",":"] )+ > } void somestuff(): {} { escapedQuoteString() | normalString() | <T_ASTERISK> } void escapedQuoteString(): {System.out.println("YEA");} { <T_QUOTED> } void normalString(): {System.out.println("NO");} { <T_PROPERTY> } ------------------------------ Wasn't able to find anything usefull, on how to handle \\ and \" when expected as valid option in your input. Any help much appreciated !! Bertram |
|
|
Re: Doublequotes and Backslashes...As I read the definition of T_QUOTED, it reads:
A literal space followed by 2 backslashes followed by 1 backslash and one doublequote, followed by at least one of [a-zA-Z0-9:_-] If that is not what you intended, then you need to re-define that. On Wed, Mar 25, 2009 at 4:10 AM, Bertram <bertram@...> wrote: > > Hello again, > > I am new to Javacc, so there might be a very obvious solution to this. > > I'm trying to parse a) "ABC\\" and b) "\\ABC" by somestuff() below. [<= both > as they are, NOT escaped, 2 backslashes] > In case of: > a) the normalString() is used by javacc -> clearly not intended > b) there is an exception: Lexical error at line 1, column 1. Encountered: > "\\" (92), after : "" > > ------------------------------ > > options{ > IGNORE_CASE=false ; > JAVA_UNICODE_ESCAPE= true ; > } > PARSER_BEGIN(Test) > package Mini; > public class Test {} > PARSER_END(Test) > TOKEN : > { > < T_ASTERISK: "*"> > | < T_QUOTED: ( (" ") ("\\\\") ("\\\"") > ["a"-"z","A"-"Z","_","-","0"-"9",":"] )+ > > | < T_PROPERTY: ( ["a"-"z","A"-"Z","_","-","0"-"9",":"] )+ > > } > void somestuff(): > {} > { escapedQuoteString() > | normalString() > | <T_ASTERISK> > } > void escapedQuoteString(): > {System.out.println("YEA");} > { > <T_QUOTED> > } > void normalString(): > {System.out.println("NO");} > { > <T_PROPERTY> > } > > ------------------------------ > > Wasn't able to find anything usefull, on how to handle \\ and \" when > expected as valid option in your input. > > Any help much appreciated !! > > Bertram > > -- > View this message in context: http://www.nabble.com/Doublequotes-and-Backslashes...-tp22682545p22682545.html > Sent from the java.net - javacc users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- - J.Chris Findlay (c: --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Doublequotes and Backslashes...that explained a lot ;-)
works now, thanks. Solution for the next newbee: TOKEN : < DQUOTE: "\"" > | < ESCQUOTE: "\\" <DQUOTE> > | < ESCSLASH: "\\\\" > | < #SEARCH_CHAR: <ESCQUOTE> | <ESCSLASH> | <WCHAR> | ["\u0020"-"\u0021"] | ["\u0023"-"\u005B"] | ["\u005D"-"\uD7FF"] | ["\uE000"-"\uFFFD"] > | < SEARCH_STR: <DQUOTE> (<SEARCH_CHAR>)* <DQUOTE> > Bertram Grillitsch
|
| Free embeddable forum powered by Nabble | Forum Help |