I'm working on a simple scripting language for a work project and I need to create a definition statement of the form type name = value
. I've been following the SuperpowerSimpleSql example and have created the tokenizer, which is correctly tokenizing the input.
The problem is coming from creating the TokenListParser for the assignment statement. Currently the parser is defined as this:
public static TokenListParser<AumToken, ShmemWord> ShmemWord =
from keyword in Token.EqualToValueIgnoreCase(AumToken.Keyword, "ShmemWord")
from name in Token.EqualTo(AumToken.Keyword)
from equal in Token.EqualTo(AumToken.Assignment)
from value in Token>EqualTo(AumToken.Number).Apply(Numerics.HexDigitsUInt64)
select new ShmemWord(name, value);
and ShmemWord
is a simple class with the constructor signature ShmemWord(string name, ulong value)
.
Am I defining this correctly so far, and how can I convert name to a string?
Token<TKind>
provides ToStringValue()
for this:
select new ShmemWord(name.ToStringValue(), value);