Add namespace statements

This commit is contained in:
Max Brunsfeld 2018-10-26 11:46:10 -07:00
parent d9f5080cca
commit 2659e00a88
4 changed files with 3213 additions and 2826 deletions

View File

@ -17,6 +17,32 @@ Import statements
(import_statement (call_expression (function_name) (arguments (string_value))))
(import_statement (string_value) (keyword_query)))
==============================
Namespace statements
==============================
/* Default namespace */
@namespace url(XML-namespace-URL);
@namespace "XML-namespace-URL";
@namespace url(http://www.w3.org/1999/xhtml);
@namespace svg url(http://www.w3.org/2000/svg);
/* Prefixed namespace */
@namespace prefix url(XML-namespace-URL);
@namespace prefix "XML-namespace-URL";
---
(stylesheet
(comment)
(namespace_statement (call_expression (function_name) (arguments (plain_value))))
(namespace_statement (string_value))
(namespace_statement (call_expression (function_name) (arguments (plain_value))))
(namespace_statement (namespace_name) (call_expression (function_name) (arguments (plain_value))))
(comment)
(namespace_statement (namespace_name) (call_expression (function_name) (arguments (plain_value))))
(namespace_statement (namespace_name) (string_value)))
==============================
Media statements
==============================

View File

@ -23,6 +23,7 @@ module.exports = grammar({
$.import_statement,
$.media_statement,
$.charset_statement,
$.namespace_statement,
$.at_rule
),
@ -47,6 +48,13 @@ module.exports = grammar({
';'
),
namespace_statement: $ => seq(
'@namespace',
optional(alias($.identifier, $.namespace_name)),
choice($.string_value, $.call_expression),
';'
),
at_rule: $ => seq(
$.at_keyword,
commaSep($._query),

47
src/grammar.json vendored
View File

@ -27,6 +27,10 @@
"type": "SYMBOL",
"name": "charset_statement"
},
{
"type": "SYMBOL",
"name": "namespace_statement"
},
{
"type": "SYMBOL",
"name": "at_rule"
@ -138,6 +142,49 @@
}
]
},
"namespace_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@namespace"
},
{
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "namespace_name"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string_value"
},
{
"type": "SYMBOL",
"name": "call_expression"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
},
"at_rule": {
"type": "SEQ",
"members": [

5958
src/parser.c vendored

File diff suppressed because it is too large Load Diff