This project has moved and is read-only. For the latest updates, please go here.

Having Two tokens without whitespace.

Dec 29, 2008 at 2:50 PM
Getting back to my test with the Pilot language, the basic syntax is "(command letter)(optional conditional)(colon)(other stuff)".  On the most extended version of the language, the conditional could be an expression, although in the basic  syntax, it's just "Y" or "N", so that we'd have:

T:  Hello World!       (always print "Hello World)
T(#X>#Y):Hello World!       (print "Hello World if variable X is greater than Y)
TY: Hello World!       (print "Hello World if the global match condition is true)

The first line works OK, I haven't tried implementing the second yet, but I think it should parse well enough.  The third line fails, as it doesn't see the "T' and "Y" as two separate tokens.  If I were to write it as

T Y: Hello World!   

That works, but that's not the language syntax.  Is there anyway to get it to recognized two one-letter keywords without intervening whitespace?

I could handle this by making "T:", "TY:" and "TN:" separate tokens, but since virtually any command can have a conditional, this would essentially be tripling the grammar.

Dec 29, 2008 at 11:26 PM
I don't think you can do anything here directly using Irony's facilities, it it too different from what Irony's scanner is made for. But try changing the WhitespaceChars property in Grammar class, and introduce space as a separate token.. although it's a lot of trouble. I'm afraid you can't do much without custom terminals. 
I was thinking for a long time about creating FixedLengthTerminal, for reading files with fixed-length field, will probably do it some day. Although not sure this will help in this case. Let me think about this.