Grammar Validator outputs a set of error and warning messages relevant to the contents of an input grammar. The tool generates errors for conditions that prevent the grammar from being loaded and used by the Microsoft Speech Platform Runtime 11. Grammar Validator generates warnings for conditions that might cause undesired runtime behavior when the grammar is used. Warnings do not prevent the grammar from being used, but indicate conditions that the grammar author might want to evaluate.
Error messages for errors detected within input files contain the following information:
File name (if applicable)
Line number within the file of the error (if applicable)
Message type: Error, Warning, or Info
Error code (if applicable)
Error description
The following examples demonstrate the types of error and warning messages produced by Grammar Validator. See the next section, Error Types, for further discussion of each error type.
C:\grammars\mygrammar.grxml(57): Error: A rule name was duplicated.
C:\grammars\mygrammar.grxml(83): Warning: Ambiguous Normalization
C:\grammars\mygrammar.grxml: Error: Problem opening file
C:\grammars\mygrammar.grxml(113): Error: Can't have 'continue' out of loop
Execution continues until all available errors and warnings are identified. If errors are encountered the tool returns EXIT_FAILURE (1). Upon successful completion, with no errors, the tool returns EXIT_SUCCESS (0).
Error Types
Grammar Validator reports the following types of errors.
Tool-specific errors
Speech API (SAPI) errors
JScript syntax errors
Tool-Specific Errors
Grammar Validator will throw an error if it encounters any of the following conditions:
The grammar file specified by the /In option cannot be found, or cannot be opened.
The grammar file specified by the /In option is not properly formed and cannot be compiled.
The grammar file specified by the /In option includes the name of a rule, for example: /In MyGrammar.grxml#MyRule.
The file specified by the /RecoConfig option cannot be found, or cannot be opened.
There is no file specified by the /RecoConfig option and there is no file named "RecoConfig.xml" in the current directory or in the directory that contains GrammarValidator.exe.
Remarks
Grammar Validator will attempt to load external grammars or rules specified by the uri attribute of a ruleref element to validate their contents. If an externally referenced grammar or rule cannot be loaded (for example, it is behind a firewall or the URI cannot be found), then the tool will emit a warning. If an internally referenced grammar or rule cannot be loaded, then the tool will emit an error.
If a referenced grammar defines a root rule and does not have any publicly scoped rules, then a warning will be emitted. Note that the scope for rule elements is private by default in a grammar. Rules must be declared public explicitly, using the optional attribute setting scope="public".
Additional warnings include:
A rule that cannot be reached.
Recursion with no outlet (for example, Rule 1 references Rule 2 which references Rule 1).
A GRXML-format grammar file in which the encoding element is NOT specified. This is important if characters (for example, "á") are found in the grammar that are not UTF-8 format.
You must either specify a recognition engine configuration file using the /RecoConfig option, or create a default configuration file named "RecoConfig.xml" in the current directory (the directory for the command line), or in the directory that contains GrammarValidator.exe. The tool will generate an error if you do not supply it with a configuration file.
SAPI Errors
Grammar Validator produces a subset of SAPI errors that describe incorrect logic or syntax found in a grammar document. The following table lists and describes the SAPI errors produced by Grammar Validator.
Error Name | Hexadecimal | Description | ||
---|---|---|---|---|
SPERR_UNDEFINED_FORWARD_RULE_REF | 0x8004501c | A rule reference in a grammar was made to a named rule that was never defined. | ||
SPERR_EMPTY_RULE | 0x8004501d | A non-dynamic grammar rule that has no body. | ||
SPERR_GRAMMAR_COMPILER_INTERNAL_ERROR | 0x8004501e | The grammar compiler failed due to an internal state error. | ||
SPERR_RULE_NOT_DYNAMIC | 0x8004501f | An attempt was made to modify a non-dynamic rule. | ||
SPERR_DUPLICATE_RULE_NAME | 0x80045020 | A rule name was duplicated. | ||
SPERR_DUPLICATE_RESOURCE_NAME | 0x80045021 | A resource name was duplicated for a given rule. | ||
SPERR_TOO_MANY_GRAMMARS | 0x80045022 | Too many grammars have been loaded. | ||
SPERR_CIRCULAR_REFERENCE | 0x80045023 | Circular reference in import rules of grammars. | ||
SPERR_INVALID_IMPORT | 0x80045024 | A rule reference to an imported grammar that could not be resolved. | ||
SPERR_ALL_WORDS_OPTIONAL | 0x80045027 | A grammar rule was defined with a null path through the rule. That is, it is possible to satisfy the rule conditions with no words.
| ||
SPERR_RULE_NAME_ID_CONFLICT | 0x80045029 | A rule exists with matching IDs (names) but different names (IDs). | ||
SPERR_NO_RULES | 0x8004502a | A grammar contains no top-level, dynamic, or exported rules. There is no possible way to activate or otherwise use any rule in this grammar. | ||
SPERR_CIRCULAR_RULE_REF | 0x8004502b | Rule 'A' refers to a second rule 'B' which, in turn, refers to rule 'A'. | ||
SP_NO_PARSE_FOUND | 0x0004502c | Parse path cannot be parsed given the currently active rules. | ||
SPERR_NO_PARSE_FOUND | 0x8004502d | Parse path cannot be parsed given the currently active rules. | ||
SPERR_INVALID_FORMAT_STRING | 0x80045033 | The XML format string for this RULEREF is invalid, e.g. not a GUID or REFCLSID. | ||
SPERR_NO_TERMINATING_RULE_PATH | 0x80045036 | No Terminating Rule Path. |
JScript Syntax Errors
Grammar Validator reports the errors produced as a result of incorrect EcmaScript in tag elements. These errors are shown in the following table.
Error number | Description |
---|---|
1002 | Syntax error |
1003 | Expected ':' |
1004 | Expected ';' |
1005 | Expected '(' |
1006 | Expected ')' |
1007 | Expected ']' |
1008 | Expected '{' |
1009 | Expected '}' |
1010 | Expected identifier |
1011 | Expected '=' |
1012 | Expected '/' |
1014 | Invalid character |
1015 | Unterminated string constant |
1016 | Unterminated comment |
1018 | 'return' statement outside of function |
1019 | Can't have 'break' outside of loop |
1020 | Can't have 'continue' outside of loop |
1023 | Expected hexadecimal digit |
1024 | Expected 'while' |
1025 | Label redefined |
1026 | Label not found |
1027 | 'default' can only appear once in a 'switch' statement |
1028 | Expected identifier, string or number |
1029 | Expected '@end' |
1030 | Conditional compilation is turned off |
1031 | Expected constant |
1032 | Expected '@' |
1033 | Expected 'catch' |
1035 | Throw must be followed by an expression on the same source line |