Crate trinitry

source ·
Expand description

This crate is a parser for the ‘Trinitry’ (not ‘Trinity’) language, used to map all sort of Functions to a memorable command.

This parser is more of a validator, as Trinitry does not support any language features besides the aforementioned commands and arguments. That includes some simple constructs like: ‘||’ (OR) or ‘&&’ (AND). If you need these features, simple write them in the language, you’ve written your Function in.

§General specification

§Command

Basically every command can be a series of alphanumeric ASCII values.

Correctly spoken, the Language, containing all valid command names, is just the Kleene closure over an Alphabet $\Sigma$, which contains all alphanumeric characters: \[ \Sigma_{cmd} = \{x | 0 \leqslant x \leqslant 9\} \cup \{x | “\text{a}” \leqslant x \leqslant “\text{z}”\} \cup \{x | “\text{A}” \leqslant x \leqslant “\text{Z}”\} \cup \{“\text{\_}”, “\text{-}”, “.”\} \]

§Argument

Arguments constructed from the same alphabet as the commands, but can contain additional chars listed in the trinitry.pest file. \[ \Sigma_{args} = \Sigma_{cmd} \cup{} \{\dots{}\} \]

Besides the extra chars outlined above the arguments can also contain spaces and quotes, if they are quoted. Quoted args are either double quoted, and can thus contain single quotes, or single quoted, and can contain double quotes. \[ \Sigma_{args-double-quoted} = \Sigma_{args} \cup \{“\texttt{ꞌ}”, “\ “\} \\ \Sigma_{args-single-quoted} = \Sigma_{args} \cup \{”\texttt{“}”, “\ “\} \]

§Examples

§Command

A valid command would be something like that:

quit

something like that would not be valid however, as Trinitry does not support these ‘complex’ language features:

write && quit

§Arguments

A valid argumented command would be:

lua "function() print('Hi!') end"

Whilst this would not be valid (it is actually valid, but results in something, you likely did not expect):

lua "function() print("Hi!") end"

as the double quotes in the print statement actually unquote the argument, leaving you with three arguments:

  1. function() print(
  2. Hi!
  3. ) end

Structs§