Skip to content

Syntax

The syntax system parses the syntax attribute of @InkCommand into a typed spec used to validate and read tag arguments.

Syntax grammar

FormatKindDescription
<name:type>Required positionalMust be provided, in order
(name:type)Optional positionalCan be omitted
[name:type=default]Named optionalPassed as name=value
[--flagname]Boolean flagPresent = true, absent = false

Available types (ArgType): STRING, INT, FLOAT, BOOLEAN

Example:

"shake <amplitude:float> [duration:float=1.0] [--loop]"

SyntaxParser

java
CommandSpec spec = SyntaxParser.parse(keyword, syntaxDeclaration);

CommandSpec

Compiled representation of a syntax declaration. Parse a list of tokens against it:

java
ParsedCommand command = spec.parse(tokens);

ParsedCommand

Typed snapshot of a parsed command. Passed to doValidate - store it as a field to use it in doExecute. See Reading arguments.

Argument definition records

RecordFieldsRepresents
ArgDefname, ArgTypeRequired positional
NamedArgDefname, ArgType, defaultValueNamed optional
FlagDefnameBoolean flag