LMD SyntaxEdit Schemes Language Reference


Chain Block


Element: <ChainBlock>

 

Sometimes we don’t want to switch back into outer scheme, after exit from inner scheme given by <RegexBlock>. We may want to switch into another inner scheme, parse it, and then switch back into outer scheme. For example, look at Perl regexp-substitute  construct parsing:

 

my $v    =            s/([^\0]*)    /         '$1'/             ;

^^ Main scheme ^^    ^^ switch to   ^^    switch to    ^^^ switch back  ^^

                        regex-search      regex-subst      to Main scheme

                        inner scheme      inner scheme

 

Attribute: innerScheme, type: string, case-sensitive, scheme reference
Causes parser to switch inside specified scheme to parse matched text.
Same as <RegexBlock> innerScheme attribute. For more, look there.

Attribute: name, type: string, case-sensitive
Used to refer this block from <RegexBlock>.

Attribute: end, type: Regular expression
This attribute gives regular expression which ends parsing scheme referred by innerScheme attribute.  Same as end attribute of <RegexBlock>.

Attribute: end_moreWordSeparators, type: string.
This attribute extends default word separator chars, used by \b regexp operator, for this end regexp attribute only.
See topic in regexps section.
See <KeywordRegex> element for example.

Attribute: end_moreWordChars, type: string.
This attribute extends default word chars, used by \b regexp operator, for this end regexp attribute only. See links above.

Attribute: end_token0..N, type: string, case-sensitive, <Token> reference
This attribute splits text matched by end regexp by tokens. Splitting rules same as for  token0..N of <RegexBlock>  element (see more above).

Attribute: chainBlock, type: string, case-sensitive, <ChainBlock> reference
This attribute instructs parser after end of innerScheme don’t switch back to outer scheme. Instead, parser should switch to innerScheme of specified <ChainBlock>.
Same as chainBlock attribute of <RegexBlock> node.

 

Example

 

<!--This will highlight second part of subst-expression, 

    and switch back into outer (main) scheme -->

<ChainBlock name='RegexSubstEnd' 

            end_token0='regexEnd' 

            innerScheme='RegexSubst'  >

    <End> /[egimosx]* </End>        

</ChainBlock>

 

<!--This will highlight first part of subst-expression -->

<!--After end of first part,  parser will switch into 

    RegexSubst scheme, specified by chainBlock='RegexSubstEnd' -->

<RegexBlock innerScheme='RegexFind' 

            start_token0='regexStart' 

            end_token0='regexEnd' 

            chainBlock='RegexSubstEnd'>

 

    <Start> s/  </Start>        

    <End> / </End>        

</RegexBlock>