This question is about Tree theory and the handling of such tree concept used by Vim syntax/highlighting in a typical syntax/mylanguage.vim.
Is it true, for Vim, that exactly one path is ONLY supported between any two vertex of a (syntax) graph tree? That between any two vertexes, Vim syntax requires, at most, one pathway?
And that acyclic (more than 1 syntax path between vertexes) cannot be reliably processed?
I ask this because after a very long lengthy mathematic operations (and highlighting thereof), the syntax developer (me) is struggling at joining back all of the related syntaxes together and nextgroup into a specific type of syntax (ie., variable type).
Trying again but in Vim-speak, the EBNF is simplified as:
Grammar ::= Clause*
Clause ::= ClauseA | ClauseB
ClauseA ::= 'KeywordA' Expression IntegerVarName
ClauseB ::= 'KeywordB' Expression StringVarName
Expression ::= ComplexExpression | SimpleExpression
IntegerVarName ::= ( '0x' )[0-9]
StringVarName ::= [a-zA-Z0-9]+
SimpleExpression ::= '=' | '\='
ComplexExpression ::= ( ( ModExpr | XorExpr | OrExpr | AndExpr ) ShiftExpr ( ModExpr | XorExpr | OrExpr | AndExpr )* )+
ModExpr ::= '^'
XorExpr ::= '%'
OrExpr ::= '|'
AndExpr ::= '&'
syntax match my_IntegerVarName "\v(0x)?[0-9]+" skipwhite contained
syntax match my_StringVarName "\v[a-zA-Z0-9]+" skipwhite contained
syntax match my_SimpleExpression "=" skipwhite contained
\ nextgroup=my_IntegerVarName
syntax match my_ComplexExpression_AndExpr "\&" skipwhite contained
syntax cluster my_ComplexExpression
\ contains=my_ComplexExpression_AndExpr
syntax cluster my_grammar
\ contains=
\ my_SimplexExpression,
\ my_ComplexExpression
The expression fails to arrive at StringVarName due breaks on ComplexExpression due to SimplexExpression takeover.
Never see the StringVarName groupname.
What should have happened after going thru the "shared" Expression is
- ClauseA's
KeywordAshould have led toIntegerVarNameand - ClauseB's
KeywordBshould have led toStringVarName.






:help syntaxdon't seem to match traditional notions of parse trees, so it may be hard to map Vim's notion of syntax highlighting onto your description. (Reading the relevant code or running it in a debugger might be the best way to find out.)Expression) into duplication of Vim syntaxes (using unique groupnames, cloned fromExpression) are required to meet the functional characteristics of an end-vertex (final groupnames,IntegerVarName&StringVarName) having multiple inbound paths (from various points inside theComplexExpression. Tree theory end.