Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mincss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
mincss
Commits
bc51af63
Commit
bc51af63
authored
11 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added support for exotic browser-specific syntax such as @-ms-viewport and filter(opacity=60)
parent
ef3a6884
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lexer.mll
+2
-0
2 additions, 0 deletions
lexer.mll
parser.mly
+26
-4
26 additions, 4 deletions
parser.mly
stringify.ml
+6
-0
6 additions, 0 deletions
stringify.ml
types.ml
+3
-0
3 additions, 0 deletions
types.ml
with
37 additions
and
4 deletions
lexer.mll
+
2
−
0
View file @
bc51af63
...
...
@@ -106,6 +106,8 @@ rule token = parse
| '@' S U P P O R T S { SUPPORTS_SYM }
| '@' (('-' ident '-')? as prefix) K E Y F R A M E S
{ KEYFRAMES_SYM (String.lowercase prefix) }
| '@' (('-' ident '-')? as prefix) V I E W P O R T
{ VIEWPORT_SYM (String.lowercase prefix) }
| (s | comment)* s comment* A N D comment* s (s | comment)*
{ advance_pos lexbuf; WS_AND }
...
...
This diff is collapsed.
Click to expand it.
parser.mly
+
26
−
4
View file @
bc51af63
...
...
@@ -58,7 +58,8 @@
%
token
NAMESPACE_SYM
SUPPORTS_SYM
IMPORTANT_SYM
%
token
<
float
>
PERCENTAGE
NUMBER
%
token
<
float
*
string
>
UNIT_VALUE
%
token
<
string
>
KEYFRAMES_SYM
COMBINATOR
RELATION
STRING
IDENT
HASH
URI
FUNCTION
%
token
<
string
>
KEYFRAMES_SYM
VIEWPORT_SYM
COMBINATOR
RELATION
STRING
IDENT
HASH
%
token
<
string
>
URI
FUNCTION
%
token
LPAREN
RPAREN
LBRACE
RBRACE
LBRACK
RBRACK
SEMICOL
COLON
DOUBLE_COLON
%
token
COMMA
DOT
PLUS
MINUS
SLASH
STAR
ONLY
AND
(*OR*)
NOT
FROM
TO
EOF
%
token
WS_AND
WS_OR
...
...
@@ -90,7 +91,7 @@ stylesheet:
nested_statement
:
|
s
=
ruleset
|
s
=
media
|
s
=
page
|
s
=
font_face_rule
|
s
=
keyframes_rule
|
s
=
supports_rule
|
s
=
supports_rule
|
s
=
viewport_rule
{
s
}
group_rule_body
:
...
...
@@ -209,6 +210,10 @@ S*;
unused : block | ATKEYWORD S* | ';' S* | CDO S* | CDC S*;
*)
viewport_rule
:
|
pre
=
VIEWPORT_SYM
S
*
decls
=
decls_block
{
Viewport
(
pre
,
decls
)
}
%
inline
decls_block
:
|
LBRACE
S
*
hd
=
declaration
?
tl
=
wspreceded
(
SEMICOL
,
declaration
?
)
*
RBRACE
S
*
{
filter_none
(
hd
::
tl
)
}
...
...
@@ -285,13 +290,30 @@ term:
|
v
=
numval
S
*
{
v
}
|
str
=
STRING
S
*
{
Strlit
str
}
|
id
=
IDENT
S
*
{
Ident
(
String
.
lowercase
id
)
}
|
ONLY
S
*
{
Ident
"only"
}
|
NOT
S
*
{
Ident
"not"
}
|
AND
S
*
{
Ident
"and"
}
|
FROM
S
*
{
Ident
"from"
}
|
TO
S
*
{
Ident
"to"
}
|
uri
=
URI
S
*
{
Uri
uri
}
|
fn
=
FUNCTION
arg
=
expr
RPAREN
S
*
{
Function
(
String
.
lowercase
fn
,
arg
)
}
|
key
=
IDENT
S
*
COLON
S
*
value
=
term
{
Key_value
(
key
,
":"
,
value
)
}
|
key
=
IDENT
S
*
DOT
S
*
value
=
term
{
Key_value
(
key
,
"."
,
value
)
}
|
key
=
IDENT
S
*
rel
=
RELATION
S
*
value
=
term
{
if
rel
=
"="
then
Key_value
(
key
,
"="
,
value
)
else
raise
(
Syntax_error
(
"unexpected '"
^
rel
^
"'"
))
}
|
hex
=
HASH
S
*
{
let
h
=
"[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"
in
{
let
h
=
"[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"
in
if
Str
.
string_match
(
Str
.
regexp
(
"^"
^
h
^
"
\\
("
^
h
^
"
\\
)?$"
))
hex
0
then
Hexcolor
(
String
.
lowercase
hex
)
else
raise
(
Syntax_error
(
"invalid color #"
^
hex
))
}
else
raise
(
Syntax_error
(
"invalid color #"
^
hex
))
}
unary_operator
:
|
MINUS
{
"-"
}
|
PLUS
{
"+"
}
...
...
This diff is collapsed.
Click to expand it.
stringify.ml
+
6
−
0
View file @
bc51af63
...
...
@@ -34,6 +34,7 @@ let rec string_of_expr = function
|
Unary
(
op
,
opnd
)
->
op
^
string_of_expr
opnd
|
Nary
(
","
,
opnds
)
->
cat
", "
string_of_expr
opnds
|
Nary
(
op
,
opnds
)
->
cat
op
string_of_expr
opnds
|
Key_value
(
key
,
op
,
value
)
->
key
^
op
^
string_of_expr
value
let
string_of_declaration
(
name
,
value
,
important
)
=
let
imp
=
if
important
then
" !important"
else
""
in
...
...
@@ -141,6 +142,8 @@ let rec string_of_statement = function
|
Supports
(
condition
,
statements
)
->
"@supports "
^
string_of_condition
condition
^
block
(
cat
"
\n\n
"
string_of_statement
statements
)
|
Viewport
(
prefix
,
decls
)
->
"@"
^
prefix
^
"viewport"
^
block
(
cat
"
\n
"
string_of_declaration
decls
)
let
string_of_stylesheet
=
cat
"
\n\n
"
string_of_statement
...
...
@@ -168,6 +171,7 @@ let rec minify_expr = function
|
Nary
(
op
,
opnds
)
->
cat
op
minify_expr
opnds
|
Number
(
n
,
None
)
->
minify_num
n
|
Number
(
n
,
Some
u
)
->
minify_num
n
^
u
|
Key_value
(
key
,
op
,
value
)
->
key
^
op
^
minify_expr
value
|
expr
->
string_of_expr
expr
let
minify_declaration
(
name
,
value
,
important
)
=
...
...
@@ -219,6 +223,8 @@ let rec minify_statement = function
|
Supports
(
condition
,
statements
)
->
"@supports "
^
stringify_condition
""
condition
^
"{"
^
cat
""
minify_statement
statements
^
"}"
|
Viewport
(
prefix
,
decls
)
->
"@"
^
prefix
^
"viewport{"
^
cat
";"
minify_declaration
decls
^
"}"
|
statement
->
string_of_statement
statement
let
minify_stylesheet
=
cat
""
minify_statement
...
...
This diff is collapsed.
Click to expand it.
types.ml
+
3
−
0
View file @
bc51af63
...
...
@@ -8,6 +8,7 @@ type expr =
|
Hexcolor
of
string
|
Unary
of
string
*
expr
|
Nary
of
string
*
expr
list
|
Key_value
of
string
*
string
*
expr
type
declaration
=
string
*
expr
*
bool
...
...
@@ -63,6 +64,8 @@ type statement =
(* @[-<prefix>-]keyframes <id> { <rulesets> } *)
|
Supports
of
condition
*
statement
list
(* @supports <condition> { <rulesets> } *)
|
Viewport
of
string
*
declaration
list
(* @[-<prefix>-]viewport { <declarations> } *)
type
stylesheet
=
statement
list
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment