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

Getting whitespace between terminals?

Mar 21, 2014 at 1:21 AM
I'm making a simple SQL parser which outputs a subset of the parsed SQL. When reading the value of each terminal in the parse tree, how do it get a string of the whitespace surrounding this particular terminal? As in if I have follow SQL statement:
How do I for the "SELECT" terminal get the single space following it?

Mar 21, 2014 at 6:11 AM
just compare location of tokens and their lengths, so you'll know the number of whitespace chars between. Each token has Location and Length property ( or Token.Text.Length)
Mar 21, 2014 at 10:16 AM

That's indeed a possibility. But I'd like the original whitespace string - with the subtraction method, I will not know if the whitespace consists of spaces, tabs, newlines or a good ol' mix.

Doesn't Irony keep this information?

Mar 22, 2014 at 8:41 PM
You have the original text and you have all tokens.. you can simply get substring between SELECT end and next token