Welcome GuestLogin

Parser configuration

RSS
Modified on Wednesday, 23 December 2009 08:46 by Administrator Categorized as Uncategorized
The parser configuration is stored in a single XML file. This file defines all tokens and the corresponding token handlers. It defines all regular expressions in use by the parser and their corresponding match handlers. It also defines the expression modes and the order of regular expression matching within each parse mode. Finally, it defines the format strings in use for generating syntax synopsis fragments.


Token configuration

The token configuration section declares each supported token, and their corresponding token handler.

Token element

Each token element defines a single token.


<token name="@return" handler="SetReturns" match="{?(?'type'[\w\.\$]+)}?(?:\s+(?'description'[\s\S]*))?"/>

name attribute

Specifies the name of the token.

name="@return"

handler attribute

Specifies the name of the delegate method that handles this token.

handler="SetReturns"

match attribute

Specifies the regular expression for matching the data of the token; the token content. Token handlers will receive the parsed token contents as a name/value collection of sub-expression matches where names are the names as defined in the regular expression ('type' and 'description' in the example below) and values are the actual values of these sub-expression matches.

match="{?(?'type'[\w\.\$]+)}?(?:\s+(?'description'[\s\S]*))?



Expression configuration

All regular expressions in use by ECMADoc are defined in this configuration file. Each expression defines its name, the name of the delegate method that handles it, a simple description of what it does and the regular expression associated with it.

expression element

Required. This is the root node that contains all other content.


<expression name="Function" handler="FunctionHandler" description="matches any type of function expression">
    <rxp><![CDATA[
       (?:\[comment(?'Comment'\d+)\]\s*)?(?:(?'VarDecl'var)\s*)?#
       (?:(?'FunctDeclLeft'[\w\$\.]+)\s*=\s*)?(?'NewKeyword'new\s+)?\(*\s*function\s*?(?'FunctDeclRight'[\w.$]+)?#
       \s*\((?'FunctArgs'[\w.$\s,]*?)\)\[function(?'FunctIndex'\d+)\]\s*\)*
    ]]></rxp>
</expression>

name attribute

Specifies the name of the expression. This name must be unique.

name="Function"

handler attribute

Specifies the name of the delegate method that handles the expression.

handler="FunctionHandler"

description attribute

Specifies the description of the expression.

description="Matches any type of function expression"

rxp element

Specifies the regular expression associated with the expression. The regular expression will be compiled with IgnorePatternWhitespace option on, so newlines and spaces can be used to improve readability. Each sub-match expression is assigned a name, and the match handlers refer to these sub-match expression by their name.


<![CDATA[
   (?:\[comment(?'Comment'\d+)\]\s*)?(?:(?'VarDecl'var)\s*)?#
   (?:(?'FunctDeclLeft'[\w\$\.]+)\s*=\s*)?(?'NewKeyword'new\s+)?\(*\s*function\s*?(?'FunctDeclRight'[\w.$]+)?#
   \s*\((?'FunctArgs'[\w.$\s,]*?)\)\[function(?'FunctIndex'\d+)\]\s*\)*
]]>





Parse mode configuration

This section defines the order of expression matching for each of the parse modes. There are four parse modes:

  • Global - the parser is matching expressions globally, outside of any function. This is the initial parse mode.
  • Function - the parser is matching expression within a function's body.
  • Constructor - the parser is matching expression within a body of a function that is considered a constructor. This will cause the parser to evaluate additional expressions applicable to constructors.
  • Literal - the parser is matching expressions within a code block defined using JavaScript object-literal notation (JSON).

mode element

Defined the expression evaluation order within a single parse mode.


<mode name="Global" order="Namespace,Function,InheritanceStatement,DocNewStatement,DocGeneric,Literal"/>

name attribute

Specifies the name of the mode. This must be one of Global|Function|Constructor|Literal.

name="Global"

order attribute

Specifies the order of expression evaluation. This is a comma-separated list of expression names. Each name must be defined in the expression configuration section.

order="Namespace,Function,InheritanceStatement,DocNewStatement,DocGeneric,Literal"

Format configuration

This section defines the format string in use for generating syntax synopsis fragments.

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.