foo123 / editor-grammar

invariant codebase of editor-grammar (codemirror-grammar, ace-grammar,prism-grammar,syntaxhighlighter-grammar, highlightjs-grammar,..)
https://foo123.github.io/
19 stars 7 forks source link

Correct use of sequence #7

Closed Fandangi closed 6 years ago

Fandangi commented 6 years ago

In the following line, I am trying to catch 'var', '=' and 'somevar' separately and assign styles.

var=somevar

I have defined in the lex section 'var', eq and 'subs', and these work well.

    ,"var"                          : "RE::/(var)(?:(?=\\s)|(?=\\t)|(?==)|$)/gim"
    ,"eq"                           : "RE::/\\s*=\\s*/gim"
    ,"subs"                         : "RE::/[A-Za-z$][A-Za-z0-9$]*/"

I am having trouble with the 'somevar' part as I believe I can only identify it accurately as a subs type following after types var and eq.

My sequence is currently

"Syntax"                            : {
    "subs1"                  : {"sequence":["var", "eq", "subs"]}
    ,"js"                           : " comment | eq | operator | var | subs1 | subs | keyword  "
},

Am I being too hopeful, or is there a correct approach to the above requirement.

Fandangi commented 6 years ago

Sorry - I meant this to be i the codemirror-grammar area, I will add if there. Please close this case.