Skip to content

Commit 812f175

Browse files
author
Nikos M
committed
v.4.2.1
* dynamic autocompletion in-context or context-free * define,defined, .. actions can use a sequential list (mode-list) or a static hash (mode-hash) * define,defined .. actions used raw group_replace in contrast to other actions (needed additional group number), fixed * group_replace token ids in actions for block and non-block type of tokens (block=raw, non-block=non-raw), fixed * fix a couple of typos in main grammars + some optimisations
1 parent f450f10 commit 812f175

10 files changed

+317
-308
lines changed

README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ var xml_grammar = {
8383
"Extra" : {
8484

8585
"fold" : "xml"
86-
//"match" : "xml"
8786
//"electricChars" : "<"
8887

8988
},
@@ -113,33 +112,34 @@ var xml_grammar = {
113112
,"doctype:block" : ["RE::/<!doctype\\b/i", ">"]
114113
,"meta:block" : ["RE::/<\\?[_a-zA-Z][\\w\\._\\-]*/", "?>"]
115114
,"cdata:block" : ["<![CDATA[", "]]>"]
116-
,"open_tag" : "RE::/<([_a-zA-Z][_a-zA-Z0-9\\-]*)/"
117-
,"close_tag" : "RE::/<\\/([_a-zA-Z][_a-zA-Z0-9\\-]*)>/"
115+
,"open_tag" : "RE::/<((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)\\b/"
116+
,"close_tag" : "RE::/<\\/((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)>/"
118117
,"attribute" : "RE::/[_a-zA-Z][_a-zA-Z0-9\\-]*/"
119118
,"string:line-block" : [["\""], ["'"]]
120119
,"number" : ["RE::/[0-9]\\d*/", "RE::/#[0-9a-fA-F]+/"]
121120
,"atom" : ["RE::/&#x[a-fA-F\\d]+;/", "RE::/&#[\\d]+;/", "RE::/&[a-zA-Z][a-zA-Z0-9]*;/"]
122121
,"text" : "RE::/[^<&]+/"
123122

124123
// actions
125-
,"tag_ctx:action" : {"context":true}
126-
,"\\tag_ctx:action" : {"context":false}
127-
,"unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\""}
128-
,"unique_att:action" : {"unique":["tag", "$0"],"msg":"Duplicate attribute \"$0\"","in-context":true}
129-
,"tag_opened:action" : {"push":"<$1>","ci":true}
130-
,"tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"}
131-
,"tag_autoclosed:action" : {"pop":null}
132-
,"out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document"
124+
,"@tag:action" : {"context":true}
125+
,"tag@:action" : {"context":false}
126+
,"@unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\"","mode":"hash"}
127+
,"@unique_att:action" : {"unique":["att", "$0"],"msg":"Duplicate attribute \"$0\"","mode":"hash","in-context":true}
128+
,"@tag_opened:action" : {"push":"<$1>","ci":true}
129+
,"@tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"}
130+
,"@tag_autoclosed:action" : {"pop":null}
131+
,"@autocomplete:action" : {"define":["autocomplete","$1"],"msg":false,"autocomplete":true,"mode":"hash"}
132+
,"@out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document"
133133

134134
},
135135

136136
// Syntax model (optional)
137137
"Syntax" : {
138138

139-
"tag_att" : "'id'.attribute unique_att '=' string unique_id | attribute unique_att '=' (string | number)"
140-
,"start_tag" : "open_tag.tag tag_ctx tag_opened tag_att* ('>'.tag | '/>'.tag tag_autoclosed) \\tag_ctx"
141-
,"end_tag" : "close_tag.tag tag_closed"
142-
,"xml" : "(^^1 declaration? doctype?) (declaration.error out_of_place | doctype.error out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*"
139+
"tag_att" : "'id'.attribute @unique_att '=' string @unique_id | attribute @unique_att '=' (string | number)"
140+
,"start_tag" : "open_tag.tag @tag @autocomplete @tag_opened tag_att* ('>'.tag | '/>'.tag @tag_autoclosed) tag@"
141+
,"end_tag" : "close_tag.tag @autocomplete @tag_closed"
142+
,"xml" : "(^^1 declaration? doctype?) (declaration.error @out_of_place | doctype.error @out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*"
143143

144144
},
145145

@@ -210,6 +210,7 @@ Result:
210210

211211
![xml-grammar-1](/test/grammar-xml.png)
212212
![xml-grammar-2](/test/grammar-xml-2.png)
213+
![xml-grammar-2](/test/grammar-xml-3.png)
213214

214215

215216

beeld.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ tasks =[{}]
4949
replace =[{}]
5050

5151
"@@ROOT@@" = "this"
52-
"@@VERSION@@" = "4.2.0"
52+
"@@VERSION@@" = "4.2.1"
5353
"@@MODULE@@" = "CodeMirrorGrammar"
5454

5555
@

0 commit comments

Comments
 (0)