fxe
fxe

Reputation: 575

JavaCC beginning of line

Does JavaCC supports begging of line regex like '^' ?

I have a Token like this

TOKEN: { < ENTRYTK : "DATA"(" ")* > }

Would like it to match only the following regex

^"DATA"[ ]*

I have tried the following which neither works

TOKEN: { < ENTRYTK : "^DATA"(" ")* > }
TOKEN: { < ENTRYTK : ^"DATA"(" ")* > }

Upvotes: 4

Views: 679

Answers (1)

Theodore Norvell
Theodore Norvell

Reputation: 16221

No it doesn't. Use lexical states to ensure that the production is only in play at the start of a newline. Since every file starts with a newline, the default state will be the one for the start of a newline.

Upvotes: 2

Related Questions