Commit Graph

393 Commits

Author SHA1 Message Date
Natalie Weizenbaum
dd85c34ae2 Use fuzzy comparisons for number operations.
Also implement ==, which apparently didn't exist for numbers yet.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
dbd55e16d8 Add red(), green(), and blue(). 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
048d7cff33 Add mix(). 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
227329f9c3 Add rgba().
This also adds built-in function overloading. This adds some extra
layers to the default function-call logic which could be avoided by
handling overloading purely in the callbacks of functions that require
it, but it's not clear how to share logic gracefully between the perform
visitor and function helpers.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
5cc5bf1914 Add rgb(). 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
dd8a0efd66 Add an ArgumentList class. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
e4e445b8d4 Fix argument parsing. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
8bbaf46fe6 Use the tuple package. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
c9af638f54 Support for units 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
bacc1c4529 Unify strings and identifiers.
The separation makes sense conceptually, but it would make string
functions a lot harder to write.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
9ac48fbc05 Add support for binary operations. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
7fb7804a52 Refactor list parsing.
Moving all list parsing into a single method with a giant switch will
make it possible to parse binary operations there in the future.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
33f56f31ff _spaceListOrValue -> _spaceListOrExpression 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
bcaaa1103f UnaryOperatorExpression -> UnaryOperationExpression 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
5d71ac78b9 Indented syntax parser. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
bca0907897 ignoreComments() -> whitespace() 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
aab7c741c7 Refactor comment statement parsing. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
3a2b7ca9df Split the parser up.
There are now separate parsers for selectors and at-root queries, since
those are parsed independently of the main stylesheet. The Parser class
contains utilities that are useful across different parsers.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
3329ba80b8 Re-add CssValue.toString(). 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
af61587807 Better known identifier parsing. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
913e81faaa Remove fixed TODOs. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
bde9c353f5 Further improve list serialization. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
ee7c3e5c3c Support expression &. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
db0cea9870 Fix some bugs with combinators. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
5e23c99b22 Get rid of more redundant toString() definitions. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
53635def75 Fix map serialization. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
232ee90b4d Fix parenthesis parsing. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
efd336dd20 Support null. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
1832879845 Support @each 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
e873242ac4 Support @while 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
80f0afb484 Support @for. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
202fcad40f Name all at-rules *Rule. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
f85b21a3c3 Support @error 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
69aabed63d Support @warn 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
da1cef3f6f Move advanced list paren logic to serializer. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
7a5029b5ae Support @debug. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
e8fdcc586a Add runtime exceptions and stack traces. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
60b8aae55f No more throwing strings. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
da7a58645e Add a proper exception class. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
987eee5c0a Support @extend !optional. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
507ae1790a ExtendRule -> Extend 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
3fb3ae1f3b Throw if an extend doesn't match. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
92f657db46 Don't emit placeholders. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
673db13d51 Move emptiness-checking to the serializer.
We can't actually know if a rule will be empty until we've evaluated the
entire stylesheet, since it might contain a placeholder that may or may
not be extended.
2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
cc56ea0f13 Implement CssNode.toString() using toCss(). 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
e607e7914f Support @at-root. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
17c5814a15 Fix a formatting nit. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
0f82f72fa4 Fix media query parsing. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
d3d4427028 Fix quoted strings in interpolation. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
0fe62a04a6 @supports support. 2016-09-30 12:41:41 -07:00
Natalie Weizenbaum
07a79e4557 Fix color serialization. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
7b5f8c7284 Fix an @extend bug. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
def4ffea0f Fix a selector-parsing bug. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
9b183ed32c Clean up output of childless rules. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
83c8c1a9b7 Add args support.
It doesn't really do anything yet.
2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
80e111eb56 Properly parse whitespace-only files. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
e2eb590ce6 Set precision to 10. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
cdc3065dfb Make visitor interfaces wholly abstract. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
ffb85921cb Buggy implementation of CSS @import. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
47929dfde3 Support @import.
CSS @import is still unsupported.
2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
f1ce6ea599 Format all code. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
faa86b697c Make (most) spans mandatory.
Arguments are still optional since they may be constructed for
user-defined arguments.
2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
82aca21682 Add @if. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
c4cda30bc0 Validate dynamic children. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
0f20b58044 Clean up at-rule parsing. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
0573fa7709 @content support. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
3b3e3046fd Fix variable parsing. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
ceacb840b3 Fix function/mixin scoping. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
631f0870ac Make Environment.scope scope mixins and functions. 2016-08-30 15:51:23 -07:00
Natalie Weizenbaum
bbaf8a5a2f Run arguments in the right environment. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
fcaa696f02 Re-organize AST files. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
6951774d70 Add a CallableInvocation interface. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
32db51f005 Add built-in functions. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
709f564f21 Refactor _runCallable. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
cba5881eb4 Remove redundant parameters. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
4e0a511570 Add mixins. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
7692d61ef4 Fix Environment.setFunction(). 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
64c2453a35 Fix printing of childless at-rules. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
0498e8a95c InterpolationExpression -> Interpolation 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
860f761c27 "Separator independent" -> "normalized" 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
50912350af Add support for functions.
Argument list objects are still not implemented.
2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
cbe3709914 Default values for boolean parameters. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
43027bf84a Fix list parsing. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
7bac6790af Merge both perform visitors together. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
77dd5c1e84 Make underscores and dashes equal. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
113b4787ed Stylistic consistency. 2016-08-30 15:51:22 -07:00
Natalie Weizenbaum
977bb9c3d2 Use unvendor() in Pseudo.
Also, fix unvendor().
2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
02a9780b43 Fix selector pseudo parsing. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
55e81951b2 Stringify the parent selector normally. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
64e4954656 Fix some pseudo bugs. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
0a0f7837b0 Parent selector support. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
e58af84cc6 Fix an analysis error. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
cf086471c6 Nested properties. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
dbf2c18ae6 Move selector serialization to the visitor. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
ce979fba35 Remove a TODO that's already been done. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
6c0a2547b0 Re-organize visitors. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
a206fdcddb Fix analysis. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
3108dc46e9 Add a default Value.toString(). 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
0b7ea7d8c9 Add nested list parenthsization. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
9f2f32c7e4 Fix comment formatting. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
6c6bd715ee Add maps. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
e38d290191 Fix analysis. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
4f4188fd12 Add StringExpression.asInterpolation. 2016-08-30 15:51:21 -07:00
Natalie Weizenbaum
8fa603feda Parse psuedo selector arguments. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
98682b67a8 Add support for custom properties. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
dda3a3d45c _declarationValue -> _declarationExpression
"Declaration value" already means something different.
2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
a2d645ee73 Add bracketed lists. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
2fb2e4a9a6 Fix Pseudo.*Specificity. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
e0333b303c Get simple extension working. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
69221190e7 Enable @extend.
Still tons of runtime errors.
2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
69a431c7bf Fix all analysis. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
8d396cc465 Add _mustUnify. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
b9c6a1dc4e _isParentSuperselector => complexIsParentSuperselector 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
a5a81382ac Add _paths. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
51c8213a6d Add _selectorPseudoIsSuperselector. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
b5b4cd5a8b Add PseudoSelector.normalizedName. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
2b120f005d Fix some hints. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
25f625af13 Fix most strong-mode errors. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
1ea3619d93 some analysis fixes 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
d5b029de9b Some extend infra juggling. 2016-08-30 15:51:20 -07:00
Natalie Weizenbaum
16ace03246 Add Extender.addExtension 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
3c0e8cbd86 Source tracking.
This is actually way simpler than the Ruby Sass version, but I think it
should obey the First Law just as well.
2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
a88670da4e Add selector specificity. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
efaf64020f Add an LCS implementation. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
ab2d8ae3f3 unify complex 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
9caecbe0d0 Simplify names. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
ec5eb46747 Compound/Simple unification. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
946c6c814c More extend stuff 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
5e93ee8667 Extend WIP 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
4b2cba2775 Structural equality for selectors. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
0629fab635 _addChild -> _parent.addChild 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
da91d13d4f Make bubbling Sass-compliant. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
c5eb7f187b Only store selectors/media queries. 2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
e8756eb02d Make CssNodes directly mutable.
This shaves off a significant amount of time, since now we don't have to
do what is essentially a full copy of the CSS tree. We may want to use
interfaces to provide an immutable view of the CSS tree for use outside
of the perform visitor.
2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
a4a7ec1bd9 Refactor bubbling.
This still isn't quite right, though...
2016-08-30 15:51:19 -07:00
Natalie Weizenbaum
9575005571 Fix analysis issues. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
42ead803e9 Partial implementation of media rule merging.
The outer query is still hanging around.
2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
6022128372 Clean up style rule tracking. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
d69839080e Add a mutable node class for the performer. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
ed9f54b076 Add a Parent interface. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
e1e139959f Bubbling! 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
2ece8c19c9 Complete the loop on media queries.
Still need bubbling support.
2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
d063b41e64 Add Sass media query classes. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
e94e55f642 Support static strings. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
5891dacf53 Partial media query parsing.
Still needs classes, plain-CSS parsing, and to be hooked up to visitors.
2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
8d46af6b56 Add support for unrecognized at-rules. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
162ea29c14 Use built-in string scanner methods. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
4b0f18def7 Fix selector parsing. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
951ab45274 Parse selectors for rule nodes. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
04ba7cf782 Get rid of spans on selectors.
Selectors aren't parsed from source files, so it doesn't makes sense to
track these.
2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
e413dfb427 SourceSpan -> FileSpan 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
849ee6022b Add selector parsing.
Not yet hooked up to perform.
2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
a23aa018b0 Support hex colors. 2016-08-30 15:51:18 -07:00
Natalie Weizenbaum
f09d2c01b2 Fix analysis. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
13e3bd7707 Prefix all values. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
2189dbf113 Parse strings. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
dadcebf2c9 Add a dedicated serializer. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
a2d3008f9b Move sass visitors under a sass dir. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
01e31fe4ad Add CSS and Value visitors. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
3e61f962ac Fix a parser bug. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
d2a42d61ef visit -> accept 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
e5cf8d5738 Numbers. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
97e53ce1ff Boolean literals. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
b32a3b7005 Fix bugs. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
8f44bd8daa Booleans and unary not. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
110bdf9efc Single-char unary operators. 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
27a819243b Parens 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
8a395d7f7b Hooray for exports! 2016-08-30 15:51:17 -07:00
Natalie Weizenbaum
b88d0158ec Fix variables. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
86fa4cf068 Add variable support. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
73e450ca1c Fix a parser bug. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
34b365c8c6 Simple perform. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
5543201398 Change CssValue. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
4023f33d4c Make the CSS AST a sibling of the Sass AST. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
fbae2fe016 Re-organize the Sass AST. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
b24e806943 Add a plain-CSS AST. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
22b87bed6e Add a value type. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
e205a64eda Small fixes 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
2fce20d66a Remove outdated convention. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
f8cfb305a9 Add an explicit distinction between statements and expressions. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
7cc74b7c17 Add a visitor class. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
6efd5232b1 style fix 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
5308fcfb05 trySingleExpression() -> singleExpression() 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
fcb0b7d29e declarationValue() 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
0b6e7669ec Declarations and nested rulesets. 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
6eeb6a96f4 styleRule() 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
c030eb5581 almostAnyValue() 2016-08-30 15:51:16 -07:00
Natalie Weizenbaum
cee3c26963 Refactor comment parsing. 2016-08-30 15:51:15 -07:00
Natalie Weizenbaum
f8ef789b0d InterpolationBuffer 2016-08-30 15:51:15 -07:00
Natalie Weizenbaum
306d5998ef Refactor parse(). 2016-08-30 15:51:15 -07:00
Natalie Weizenbaum
2f332b4bbc Add an executable and fix some bugs. 2016-08-30 15:51:15 -07:00
Natalie Weizenbaum
53c5fb8e13 Checked-mode clean. 2016-08-30 15:51:15 -07:00
Natalie Weizenbaum
60e2e66b72 Some parser junk. 2016-08-30 15:51:11 -07:00