Skip to content

Commit

Permalink
v.4.2.1
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Nikos M committed Dec 11, 2016
1 parent f450f10 commit 812f175
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 308 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ var xml_grammar = {
"Extra" : {

"fold" : "xml"
//"match" : "xml"
//"electricChars" : "<"

},
Expand Down Expand Up @@ -113,33 +112,34 @@ var xml_grammar = {
,"doctype:block" : ["RE::/<!doctype\\b/i", ">"]
,"meta:block" : ["RE::/<\\?[_a-zA-Z][\\w\\._\\-]*/", "?>"]
,"cdata:block" : ["<![CDATA[", "]]>"]
,"open_tag" : "RE::/<([_a-zA-Z][_a-zA-Z0-9\\-]*)/"
,"close_tag" : "RE::/<\\/([_a-zA-Z][_a-zA-Z0-9\\-]*)>/"
,"open_tag" : "RE::/<((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)\\b/"
,"close_tag" : "RE::/<\\/((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)>/"
,"attribute" : "RE::/[_a-zA-Z][_a-zA-Z0-9\\-]*/"
,"string:line-block" : [["\""], ["'"]]
,"number" : ["RE::/[0-9]\\d*/", "RE::/#[0-9a-fA-F]+/"]
,"atom" : ["RE::/&#x[a-fA-F\\d]+;/", "RE::/&#[\\d]+;/", "RE::/&[a-zA-Z][a-zA-Z0-9]*;/"]
,"text" : "RE::/[^<&]+/"

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

},

// Syntax model (optional)
"Syntax" : {

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

},

Expand Down Expand Up @@ -210,6 +210,7 @@ Result:

![xml-grammar-1](/test/grammar-xml.png)
![xml-grammar-2](/test/grammar-xml-2.png)
![xml-grammar-2](/test/grammar-xml-3.png)



Expand Down
2 changes: 1 addition & 1 deletion beeld.config
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks =[{}]
replace =[{}]

"@@ROOT@@" = "this"
"@@VERSION@@" = "4.2.0"
"@@VERSION@@" = "4.2.1"
"@@MODULE@@" = "CodeMirrorGrammar"

@
Expand Down
Loading

0 comments on commit 812f175

Please sign in to comment.