User Grammar Literals
The user grammar literal is always of type
Grammar
.
UserGrammar:
UserGrammarDeclarator [ComplexLiteralInputCharsopt]
UserGrammarDeclarator [Expression]
UserGrammarDeclarator [Expression, ArgumentList]
UserGrammarDeclarator: one of
g G
-
If the sequence of characters can be parsed as an Expression of type String, then the resulting grammar is a user grammar where the expression specifies the name of the grammar to retrieve the grammar from the repository.
-
If the sequence of characters can be parsed as an Expression and an ArgumentList where the first one must have type String, then the resulting grammar is a user grammar where the first argument specifies the name of the grammar to retrieve from the repository and the argument list must correspond to the expected parameterized arguments of a complex expression block defined in a grammar template file.
The arguments are ignored if the referenced grammar is not a grammar template. If it is one, then each specified argument is evaluated and assigned as the value of a defined argument to the expression block. If the types does not match, then a runtime exception is thrown back. No errors are generated if more arguments are supplied then expected; they are ignored. No errors are generated if fewer arguments are supplied then expected unless the given argument is accessed by the complex expression block and it is not defined with a default value.
-
If the sequence of characters cannot be parsed properly as described above, then it is considered to be the name of the user grammar to retrieve from the repository.
Example User Grammar Literals:
G[myGrammar.gsl] G[global] G["myGrammar.tgl", "dtmf-2", tagValue]
Note | The special case of G[] represents an empty grammar. |