Parsing \\\---///

View: New views
3 Messages — Rating Filter:   Alert me  

Parsing \\\---///

by Piet Blauw :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I sketched up a grammer for a file containing a sequence of characters:

\\\---///

Now, I tried to define "\\" as a skip token, or "\\\---" etc but javacc keeps giving me an error:

ERROR: VensimCompiler.TokenMgrError: Lexical error at line 65, column 2.  Encountered: "\\" (92), after : "\\".

I've looked online, searched the documentation but I couldn't find anything. I've been trying this for a couple of hours but I couldn't find any solution. Could anybody give me a pointer on how to solve this?

RE: Parsing \\\---///

by Laughing Man :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
You'll probably have to make your token definitions a bit complex.

This will probably be close to what you want.
<SOME_BETTER_NAME_THAN_THIS: "\\" (~["/"])* "//">

However, the last / wouldn't be considered part of the token.

<SOME_BETTER_NAME_THAN_THIS: "\\" (~["/"])* "///">  would handle your example

<SOME_BETTER_NAME_THAN_THIS: "\\" (~["/"])* "/" ("/")*  > would let you end on any more than two /'s.

You also might want to consider using Lexical states.




> Date: Thu, 17 Jul 2008 11:53:05 -0700
> From: pietblauw@...
> To: users@...
> Subject: [JavaCC] Parsing \\\---///
>
>
> I sketched up a grammer for a file containing a sequence of characters:
>
> \\\---///
>
> Now, I tried to define "\\" as a skip token, or "\\\---" etc but javacc
> keeps giving me an error:
>
> ERROR: VensimCompiler.TokenMgrError: Lexical error at line 65, column 2.
> Encountered: "\\" (92), after : "\\".
>
> I've looked online, searched the documentation but I couldn't find anything.
> I've been trying this for a couple of hours but I couldn't find any
> solution. Could anybody give me a pointer on how to solve this?
> --
> View this message in context: http://www.nabble.com/Parsing-%5C%5C%5C-------tp18515390p18515390.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@...
>


Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

RE: Parsing \\\---///

by Piet Blauw :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your suggestion, I tried several similar things before in my parser but it didn't work. Because you too thought this would work I ripped out everything from my grammar to make a testfile, which did produce the right results. Did some more editing in my main parser and now it works.
LightInTheBox - Buy quality products at wholesale price