Skip to content

Commit

Permalink
feat: better insertions and use std::iswpunct
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Sep 11, 2021
1 parent bb30e76 commit dc8dbb7
Show file tree
Hide file tree
Showing 8 changed files with 8,355 additions and 8,151 deletions.
Binary file modified build/Release/obj.target/tree_sitter_norg_binding.node
Binary file not shown.
Binary file modified build/Release/obj.target/tree_sitter_norg_binding/src/parser.o
Binary file not shown.
Binary file modified build/Release/tree_sitter_norg_binding.node
Binary file not shown.
16 changes: 14 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,16 @@ module.exports = grammar({
),

word: $ =>
token.immediate(/[a-zA-Z0-9_\-\+]+/),
seq(
token(/[a-z0-9_\-\+]+/),
token(/[a-zA-Z0-9_\-\+]*/),
),

capitalized_word: $ =>
seq(
token(/[A-Z0-9_\-\+]+/),
token(/[a-zA-Z0-9_\-\+]*/),
),

insertion: $ =>
prec.right(0,
Expand All @@ -1395,7 +1404,10 @@ module.exports = grammar({

field(
"item",
$.word,
choice(
$.capitalized_word,
$.word
)
),

choice(
Expand Down
54 changes: 47 additions & 7 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2913,11 +2913,42 @@
}
},
"word": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z0-9_\\-\\+]+"
}
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-z0-9_\\-\\+]+"
}
},
{
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z0-9_\\-\\+]*"
}
}
]
},
"capitalized_word": {
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[A-Z0-9_\\-\\+]+"
}
},
{
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z0-9_\\-\\+]*"
}
}
]
},
"insertion": {
"type": "PREC_RIGHT",
Expand All @@ -2933,8 +2964,17 @@
"type": "FIELD",
"name": "item",
"content": {
"type": "SYMBOL",
"name": "word"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "capitalized_word"
},
{
"type": "SYMBOL",
"name": "word"
}
]
}
},
{
Expand Down
18 changes: 14 additions & 4 deletions src/node-types.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"type": "capitalized_word",
"named": true,
"fields": {}
},
{
"type": "carryover_tag",
"named": true,
Expand Down Expand Up @@ -785,6 +790,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "capitalized_word",
"named": true
},
{
"type": "word",
"named": true
Expand Down Expand Up @@ -2869,6 +2878,11 @@
]
}
},
{
"type": "word",
"named": true,
"fields": {}
},
{
"type": "\n",
"named": false
Expand Down Expand Up @@ -3116,9 +3130,5 @@
{
"type": "weak_paragraph_delimiter",
"named": true
},
{
"type": "word",
"named": true
}
]
Loading

0 comments on commit dc8dbb7

Please sign in to comment.