codemirror-grammar icon indicating copy to clipboard operation
codemirror-grammar copied to clipboard

Sequence query

Open Fandangi opened this issue 7 years ago • 3 comments

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 avatar Oct 03 '18 15:10 Fandangi

I'm not sure I understand what the problem is. But in any case you can define the tokens like the following (simpler):

"var": "RE::/var\\b/i",
"eq": "=",
"sub": "RE::/[A-Za-z$][A-Za-z0-9$]*/"

Then either leave the "subs1" or "var" in the "js" sequence BUT NOT BOTH and make sure that "var" or "subs1" are BEFORE "subs" (and also put "keyword" BEFORE "subs" and AFTER "var" or "subs1").

If I miss something, please clarify and add a screenshot of the result if possible so I get an idea

foo123 avatar Oct 05 '18 14:10 foo123

里面的搜索功能可以做到不区分大小写吗?

wangliabc avatar Mar 09 '22 10:03 wangliabc

@wangliabc , Please write in english, I am not a speaker of Chinese (although I would like to learn) According to google translation you ask something about case sensitivity of search function. Please clarify your question and add some example.

foo123 avatar Mar 09 '22 10:03 foo123