From 6389c8a2d3a523edd11a27f431ed270afed178e6 Mon Sep 17 00:00:00 2001 From: rofrischmann Date: Sun, 12 Feb 2017 12:08:04 +0100 Subject: [PATCH] updated node docs --- README.md | 1 + docs/ASTNodes.md | 12 ++++++++++++ modules/__tests__/parser-test.js | 2 +- modules/parser.js | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0e331c0..0017cec 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ ast === { * [Keyword](docs/ASTNodes.md#keyword) * [Operator](docs/ASTNodes.md#operator) * [HexColor](docs/ASTNodes.md#hexcolor) + * [Parenthesis](docs/ASTNodes.md#parenthesis) * [URL](docs/ASTNodes.md#url) * [String](docs/ASTNodes.md#string) * [Dimension](docs/ASTNodes.md#dimension) diff --git a/docs/ASTNodes.md b/docs/ASTNodes.md index bd38957..d83fc17 100644 --- a/docs/ASTNodes.md +++ b/docs/ASTNodes.md @@ -16,6 +16,7 @@ body: [ /* child nodes */ ] * [Keyword](#keyword) * [Operator](#operator) * [HexColor](#hexcolor) +* [Parenthesis](#parenthesis) * [URL](#url) * [String](#string) * [Dimension](#dimension) @@ -75,6 +76,17 @@ HexColor represents color values given in hexadecimal notation. } ``` +## Parenthesis +Parenthesis are used to wrap expressions. They may used to enforce e.g. additions to be executed before multiplications. Parenthesis surrounding [Functions](#function) will **not** be parsed into AST nodes. + +```javascript +// e.g. ( +{ + type: 'Parenthesis', + value: '(' +} +``` + ## URL URL is used for any URI-type string. *It is not validated by the parser!* diff --git a/modules/__tests__/parser-test.js b/modules/__tests__/parser-test.js index 9e8f3aa..05900ab 100644 --- a/modules/__tests__/parser-test.js +++ b/modules/__tests__/parser-test.js @@ -30,7 +30,7 @@ describe('Parsing CSS values', () => { expect(parser.parse('(')).toEqual({ body: [{ - type: 'Parenthese', + type: 'Parenthesis', value: '(' }], type: 'CSSValue' diff --git a/modules/parser.js b/modules/parser.js index 82c3a55..9348591 100644 --- a/modules/parser.js +++ b/modules/parser.js @@ -37,7 +37,7 @@ export default class Parser { tokens: Array; constructor(options?: Object = {}) { - this.tokenizer = createTokenizer(CSSValueRules, ['whitespace']) + this.tokenizer = createTokenizer(CSSValueRules) this.options = options } @@ -216,7 +216,7 @@ export default class Parser { --this.parenBalance } return { - type: 'Parenthese', + type: 'Parenthesis', value: this.currentToken.value } }