Is there a better way to define a decimal in an MGrammar?

112 views Asked by At

I'm working on a DSL in Microsoft's new M Grammar, and it needs to allow decimal values. I've defined decimal as

token digits = "0".."9";
token spot = ".";
token decimal = digits+ | digits+ spot digits+ | spot digits+;

That seems to work, but is there a better way? It just feels like I'm missing something.

1

There are 1 answers

0
Mike Two On BEST ANSWER

After much digging I found that you can use the build in Language.Grammar.Decimal. As in

syntax Cost = Language.Grammar.Decimal

The Language.Base "namespace" also has some useful bits. Both Language.Base and Language.Grammar are built in to intellipad.