Primitives
Krikata currently comes with 4 built-in primitives: number, int, string and bool.
The first two are parsed using parseFloat and then checked by Number.isFinite and Number.isInteger respectively.
A string matches one token generated by the Parser. If Parser.fromArgv() is used, this means a string is one argument as parsed by the shell.
A bool matches exactly true or false. It is trivial to create a bool with different names, for example T and F like so:
const mybool = new Type<boolean>("mybool", [
Constant("T", () => true),
Constant("F", () => false),
]);
Example:
> number 5.37
5.37
> number 6.06e5
606000
> int 6
6
> string hello
hello
> bool true
true
> mybool F
false
Example grammar:
l.calc:
| <t.value> EOI
t.value:
| "number" <p.number>
| "int" <p.int>
| "string" <p.string>
| "bool" <p.bool>
| "mybool" <t.mybool>
t.mybool:
| "T"
| "F"