diff --git a/src/numeric-values.js b/src/css-typed-om/numeric-values.js similarity index 99% rename from src/numeric-values.js rename to src/css-typed-om/numeric-values.js index 9c212d4..a74b472 100644 --- a/src/numeric-values.js +++ b/src/css-typed-om/numeric-values.js @@ -1,19 +1,24 @@ +import {simplifyCalculation} from '../simplify-calculation'; +import { + tokenizeString +} from './tokenizer'; import { CommaToken, DelimToken, DimensionToken, - FunctionToken, IdentToken, + FunctionToken, + IdentToken, LeftCurlyBracketToken, LeftParenthesisToken, LeftSquareBracketToken, NumberToken, - PercentageToken, RightCurlyBracketToken, - RightParenthesisToken, RightSquareBracketToken, + PercentageToken, + RightCurlyBracketToken, + RightParenthesisToken, + RightSquareBracketToken, Token, - tokenizeString, WhitespaceToken -} from './tokenizer'; -import {simplifyCalculation} from './simplify-calculation'; +} from './tokens'; /** * @typedef {{[string]: integer}} UnitMap diff --git a/src/proxy-cssom.js b/src/css-typed-om/proxy-cssom.js similarity index 99% rename from src/proxy-cssom.js rename to src/css-typed-om/proxy-cssom.js index 33f9268..01cefd2 100644 --- a/src/proxy-cssom.js +++ b/src/css-typed-om/proxy-cssom.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import {createAType, invertType, multiplyTypes, parseCSSNumericValue, to, toSum} from './numeric-values'; -import {simplifyCalculation} from './simplify-calculation'; +import {simplifyCalculation} from '../simplify-calculation'; import './tokenizer' export function installCSSOM() { diff --git a/src/tokenizer.js b/src/css-typed-om/tokenizer.js similarity index 91% rename from src/tokenizer.js rename to src/css-typed-om/tokenizer.js index 273a21b..f9ed780 100644 --- a/src/tokenizer.js +++ b/src/css-typed-om/tokenizer.js @@ -1,125 +1,29 @@ - -export class Token {} - -// The output of tokenization step is a stream of zero or more of the following tokens: , , -// , , , , , , , -// , , , , , , , -// , , <[-token>, <]-token>, <(-token>, <)-token>, <{-token>, and <}-token>. -export class IdentToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class FunctionToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class AtKeywordToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class HashToken extends Token { - type; - value; - constructor(value, type = 'unrestricted') { - super(); - this.value = value; - this.type = type; - } -} - -export class StringToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class BadStringToken extends Token {} - -export class UrlToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class BadUrlToken extends Token {} - -export class DelimToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class NumberToken extends Token { - value; - type; - constructor(value, type = "integer") { - super(); - this.value = value; - this.type = type; - } -} - -export class PercentageToken extends Token { - value; - constructor(value) { - super(); - this.value = value; - } -} - -export class DimensionToken extends Token { - value; - type; - unit; - constructor(value, type, unit) { - super(); - this.value = value; - this.type = type; - this.unit = unit; - } -} - -export class WhitespaceToken extends Token {} - -export class CDOToken extends Token {} - -export class CDCToken extends Token {} - -export class ColonToken extends Token {} - -export class SemicolonToken extends Token {} - -export class CommaToken extends Token {} - -export class LeftSquareBracketToken extends Token {} - -export class RightSquareBracketToken extends Token {} - -export class LeftParenthesisToken extends Token {} - -export class RightParenthesisToken extends Token {} - -export class LeftCurlyBracketToken extends Token {} - -export class RightCurlyBracketToken extends Token {} +import { + AtKeywordToken, + BadStringToken, + BadUrlToken, + CDCToken, + CDOToken, + ColonToken, + CommaToken, + DelimToken, + DimensionToken, + FunctionToken, + HashToken, + IdentToken, + LeftCurlyBracketToken, + LeftParenthesisToken, + LeftSquareBracketToken, + NumberToken, + PercentageToken, + RightCurlyBracketToken, + RightParenthesisToken, + RightSquareBracketToken, + SemicolonToken, + StringToken, + UrlToken, + WhitespaceToken +} from './tokens'; class InputStream { input diff --git a/src/css-typed-om/tokens.js b/src/css-typed-om/tokens.js new file mode 100644 index 0000000..53d61f7 --- /dev/null +++ b/src/css-typed-om/tokens.js @@ -0,0 +1,122 @@ + +export class Token {} + +// The output of tokenization step is a stream of zero or more of the following tokens: , , +// , , , , , , , +// , , , , , , , +// , , <[-token>, <]-token>, <(-token>, <)-token>, <{-token>, and <}-token>. +export class IdentToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class FunctionToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class AtKeywordToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class HashToken extends Token { + type; + value; + constructor(value, type = 'unrestricted') { + super(); + this.value = value; + this.type = type; + } +} + +export class StringToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class BadStringToken extends Token {} + +export class UrlToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class BadUrlToken extends Token {} + +export class DelimToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class NumberToken extends Token { + value; + type; + constructor(value, type = "integer") { + super(); + this.value = value; + this.type = type; + } +} + +export class PercentageToken extends Token { + value; + constructor(value) { + super(); + this.value = value; + } +} + +export class DimensionToken extends Token { + value; + type; + unit; + constructor(value, type, unit) { + super(); + this.value = value; + this.type = type; + this.unit = unit; + } +} + +export class WhitespaceToken extends Token {} + +export class CDOToken extends Token {} + +export class CDCToken extends Token {} + +export class ColonToken extends Token {} + +export class SemicolonToken extends Token {} + +export class CommaToken extends Token {} + +export class LeftSquareBracketToken extends Token {} + +export class RightSquareBracketToken extends Token {} + +export class LeftParenthesisToken extends Token {} + +export class RightParenthesisToken extends Token {} + +export class LeftCurlyBracketToken extends Token {} + +export class RightCurlyBracketToken extends Token {} diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index 195d1b8..f83ca3d 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {installCSSOM} from "./proxy-cssom.js"; +import {installCSSOM} from "./css-typed-om/proxy-cssom.js"; import {simplifyCalculation} from "./simplify-calculation"; import {normalizeAxis, splitIntoComponentValues} from './utils.js';