Skip to content

Commit

Permalink
feat: add negated classes
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Apr 26, 2023
1 parent bfb38d2 commit 393915d
Show file tree
Hide file tree
Showing 4 changed files with 990 additions and 1,284 deletions.
21 changes: 1 addition & 20 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ module.exports = grammar({
optional($.quantifier),
),

all_letters_char: _ => token.immediate('a'),
control_char: _ => token.immediate('c'),
digit_char: _ => token.immediate('d'),
printable_char: _ => token.immediate('g'),
lowercase_char: _ => token.immediate('l'),
punctuation_char: _ => token.immediate('p'),
space_char: _ => token.immediate('s'),
uppercase_char: _ => token.immediate('u'),
alphanumeric_char: _ => token.immediate('w'),
hexadecimal_char: _ => token.immediate('x'),
escape_char: _ => token.immediate(/\W/),
capture_index: _ => token.immediate(/[1-9]/),
balanced_match: $ => seq(
Expand Down Expand Up @@ -91,16 +81,7 @@ module.exports = grammar({
class: $ => seq(
token.immediate('%'),
choice(
$.all_letters_char,
$.control_char,
$.digit_char,
$.printable_char,
$.lowercase_char,
$.punctuation_char,
$.space_char,
$.uppercase_char,
$.alphanumeric_char,
$.hexadecimal_char,
/[acdglpsuwxACDGLPSUWX]/,
$.capture_index,
$.balanced_match,
$.escape_char,
Expand Down
110 changes: 2 additions & 108 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,76 +125,6 @@
}
]
},
"all_letters_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "a"
}
},
"control_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "c"
}
},
"digit_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "d"
}
},
"printable_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "g"
}
},
"lowercase_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "l"
}
},
"punctuation_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "p"
}
},
"space_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "s"
}
},
"uppercase_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "u"
}
},
"alphanumeric_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "w"
}
},
"hexadecimal_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "x"
}
},
"escape_char": {
"type": "IMMEDIATE_TOKEN",
"content": {
Expand Down Expand Up @@ -341,44 +271,8 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "all_letters_char"
},
{
"type": "SYMBOL",
"name": "control_char"
},
{
"type": "SYMBOL",
"name": "digit_char"
},
{
"type": "SYMBOL",
"name": "printable_char"
},
{
"type": "SYMBOL",
"name": "lowercase_char"
},
{
"type": "SYMBOL",
"name": "punctuation_char"
},
{
"type": "SYMBOL",
"name": "space_char"
},
{
"type": "SYMBOL",
"name": "uppercase_char"
},
{
"type": "SYMBOL",
"name": "alphanumeric_char"
},
{
"type": "SYMBOL",
"name": "hexadecimal_char"
"type": "PATTERN",
"value": "[acdglpsuwxACDGLPSUWX]"
},
{
"type": "SYMBOL",
Expand Down
82 changes: 1 addition & 81 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,8 @@
"fields": {},
"children": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "all_letters_char",
"named": true
},
{
"type": "alphanumeric_char",
"named": true
},
{
"type": "balanced_match",
"named": true
Expand All @@ -133,41 +125,9 @@
"type": "capture_index",
"named": true
},
{
"type": "control_char",
"named": true
},
{
"type": "digit_char",
"named": true
},
{
"type": "escape_char",
"named": true
},
{
"type": "hexadecimal_char",
"named": true
},
{
"type": "lowercase_char",
"named": true
},
{
"type": "printable_char",
"named": true
},
{
"type": "punctuation_char",
"named": true
},
{
"type": "space_char",
"named": true
},
{
"type": "uppercase_char",
"named": true
}
]
}
Expand Down Expand Up @@ -414,14 +374,6 @@
"type": "^",
"named": false
},
{
"type": "all_letters_char",
"named": true
},
{
"type": "alphanumeric_char",
"named": true
},
{
"type": "b",
"named": false
Expand All @@ -430,46 +382,14 @@
"type": "capture_index",
"named": true
},
{
"type": "control_char",
"named": true
},
{
"type": "digit_char",
"named": true
},
{
"type": "escape_char",
"named": true
},
{
"type": "hexadecimal_char",
"named": true
},
{
"type": "lowercase_char",
"named": true
},
{
"type": "one_or_more",
"named": true
},
{
"type": "printable_char",
"named": true
},
{
"type": "punctuation_char",
"named": true
},
{
"type": "space_char",
"named": true
},
{
"type": "uppercase_char",
"named": true
},
{
"type": "zero_or_more",
"named": true
Expand Down
Loading

0 comments on commit 393915d

Please sign in to comment.