update regexes to match django
This commit is contained in:
1 parent
d86f6533a8
commit
451e38cad4
4 files changed
+1138
-1097
No files matched your search
+5
-2
@@ -73,9 +73,12 @@ const django = grammar({
|
|||||||
seq($.filter, repeat(seq(token.immediate("|"), $.filter))),
|
seq($.filter, repeat(seq(token.immediate("|"), $.filter))),
|
||||||
value: ($) => choice($.literal, $.variable_attribute),
|
value: ($) => choice($.literal, $.variable_attribute),
|
||||||
literal: ($) => seq(choice($.number, $.string), $._after_literal),
|
literal: ($) => seq(choice($.number, $.string), $._after_literal),
|
||||||
number: ($) => /[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][0-9]+)?/,
|
// digits, with single underscores allowed between them, as Python's
|
||||||
|
// int() and float() accept ("1_000") and Django's Variable relies on
|
||||||
|
number: ($) =>
|
||||||
|
/[-+]?(?:[0-9](?:_?[0-9])*(?:\.(?:[0-9](?:_?[0-9])*)?)?|\.[0-9](?:_?[0-9])*)(?:[eE][0-9](?:_?[0-9])*)?/,
|
||||||
string: ($) => /"(?:[^"\\]|\\[^\n])*"|'(?:[^'\\]|\\[^\n])*'/,
|
string: ($) => /"(?:[^"\\]|\\[^\n])*"|'(?:[^'\\]|\\[^\n])*'/,
|
||||||
attribute: ($) => /[a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+)*/,
|
attribute: ($) => /[a-zA-Z0-9][a-zA-Z0-9_]*(?:\.[a-zA-Z0-9][a-zA-Z0-9_]*)*/,
|
||||||
variable_attribute: ($) =>
|
variable_attribute: ($) =>
|
||||||
seq($.identifier, optional(seq(token.immediate("."), $.attribute))),
|
seq($.identifier, optional(seq(token.immediate("."), $.attribute))),
|
||||||
identifier: ($) => /[a-zA-Z][a-zA-Z0-9_]*/,
|
identifier: ($) => /[a-zA-Z][a-zA-Z0-9_]*/,
|
||||||
|
|||||||
+2
-2
@@ -138,7 +138,7 @@
|
|||||||
},
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[-+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][0-9]+)?"
|
"value": "[-+]?(?:[0-9](?:_?[0-9])*(?:\\.(?:[0-9](?:_?[0-9])*)?)?|\\.[0-9](?:_?[0-9])*)(?:[eE][0-9](?:_?[0-9])*)?"
|
||||||
},
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
},
|
},
|
||||||
"attribute": {
|
"attribute": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[a-zA-Z0-9_]+(?:\\.[a-zA-Z0-9_]+)*"
|
"value": "[a-zA-Z0-9][a-zA-Z0-9_]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_]*)*"
|
||||||
},
|
},
|
||||||
"variable_attribute": {
|
"variable_attribute": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
|||||||
+1103
-1093
File diff suppressed because it is too large.
Load diff
@@ -246,3 +246,31 @@ Template Variable Signed Number
|
|||||||
(number)))))
|
(number)))))
|
||||||
(content))
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Template Variable Underscore Separated Number
|
||||||
|
==================
|
||||||
|
|
||||||
|
{{ 1_000 }}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(template_variable
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Template Variable Attribute Beginning With Underscore
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{{ user._private }}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(ERROR)
|
||||||
|
|
||||||
Reference in new issue
Block a user