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

Parsing Number Literal Hex

Aug 15, 2010 at 7:28 PM

Hi, first thanks for this LI Kit.

I'm making my first steps writing the grammar for my little special language. I've two digits hex parameter  and was not able to parse them if the parm had a leading character.

I added the following to 'NumberLIteral.cs' to the function  'public override IList<string> GetFirsts()' to solve problem

if (IsSet(NumberOptions.Hex))
          result.AddRange(new string[] { "A", "B", "C", "D", "E", "F" });

I'm not a real programmer, so please correct me if I'm wrong.

Aug 16, 2010 at 5:55 PM
If you have hex-only number, then just set a flag NumberOptions.Hex: var num = new NumberLiteral("num", NumberOptions.Hex); I think that should work
Aug 18, 2010 at 12:55 PM

Thanks for the fast response. That's what I did and it works, but only for 1 digit hex numbers or 2 digits with a leading number (like 1A). If the number is like AA it fails until I use the code change described above.