Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mincss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
mincss
Commits
e9ae0066
Commit
e9ae0066
authored
Jul 21, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some helper functions to utils
parent
0829ab94
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
36 deletions
+18
-36
Makefile
Makefile
+1
-2
parser.mly
parser.mly
+1
-8
stringify.ml
stringify.ml
+1
-19
util.ml
util.ml
+15
-7
No files found.
Makefile
View file @
e9ae0066
RESULT
:=
mincss
BASENAMES
:=
types
stringify parser lexer util
parse main
BASENAMES
:=
types
util stringify parser lexer
parse main
OFILES
:=
$(
addsuffix
.cmx,
$(BASENAMES)
)
OCAMLCFLAGS
:=
-g
...
...
@@ -34,7 +34,6 @@ lexer.cmi: lexer.ml
parser.cmx
:
parser.cmi lexer.cmi
parser.mli
:
parser.ml
parse.cmx
:
lexer.cmi parser.cmx
util.cmx
:
stringify.cmx
main.cmx
:
parse.cmx util.cmx
stringify.cmx parser.cmi parser.cmx lexer.cmx util.cmx parse.cmx main.cmx
:
\
types.cmi
...
...
parser.mly
View file @
e9ae0066
...
...
@@ -9,14 +9,7 @@
*)
open
Lexing
open
Types
(* TODO: move this to utils *)
let
(
|>
)
a
b
=
b
a
let
rec
filter_none
=
function
|
[]
->
[]
|
None
::
tl
->
filter_none
tl
|
Some
hd
::
tl
->
hd
::
filter_none
tl
open
Util
type
term_t
=
Term
of
expr
|
Operator
of
string
...
...
stringify.ml
View file @
e9ae0066
open
Types
open
Util
let
tab
=
" "
...
...
@@ -16,19 +17,6 @@ let string_of_num n =
then
string_of_int
(
int_of_float
n
)
else
string_of_float
n
(* TODO: move this to utils *)
let
(
@@
)
f
g
x
=
f
(
g
x
)
let
rec
filter_none
=
function
|
[]
->
[]
|
None
::
tl
->
filter_none
tl
|
Some
hd
::
tl
->
hd
::
filter_none
tl
let
add_parens
s
=
let
l
=
String
.
length
s
in
if
l
>
0
&
s
.
[
0
]
=
'
(
'
&
s
.
[
l
-
1
]
=
'
)
'
then
s
else
"("
^
s
^
")"
(*
* Pretty-printing
*)
...
...
@@ -167,12 +155,6 @@ let minify_media_query query =
pre
^
" "
^
mtype
^
" and "
^
features_str
features
|
_
->
string_of_media_query
query
let
rec
minify_condition
=
function
|
Not
c
->
"not "
^
add_parens
(
minify_condition
c
)
|
And
c
->
cat
" and "
(
add_parens
@@
minify_condition
)
c
|
Or
c
->
cat
" or "
(
add_parens
@@
minify_condition
)
c
|
Decl
(
name
,
value
)
->
"("
^
name
^
":"
^
minify_expr
value
^
")"
let
rec
minify_statement
=
function
|
Ruleset
(
selectors
,
decls
)
->
cat
","
minify_selector
selectors
^
...
...
util.ml
View file @
e9ae0066
open
Printf
open
Str
open
Types
(** Operators *)
let
(
|>
)
a
b
=
b
a
(** List utilities *)
let
rec
filter_none
=
function
|
[]
->
[]
|
None
::
tl
->
filter_none
tl
|
Some
hd
::
tl
->
hd
::
filter_none
tl
(** Reading input from file/stdin *)
let
input_all
ic
=
let
n
=
in_channel_length
ic
in
let
buf
=
String
.
create
n
in
...
...
@@ -22,11 +34,7 @@ let input_buffered ic chunksize =
in
read_all
(
String
.
create
chunksize
)
chunksize
0
let
output_css
oc
decls
=
output_string
oc
(
Stringify
.
string_of_stylesheet
decls
);
output_char
oc
'\n'
let
print_css
=
output_css
stdout
(** Error printing *)
let
noloc
=
(
""
,
0
,
0
,
0
,
0
)
...
...
@@ -41,7 +49,7 @@ let count_tabs str upto =
let
rec
repeat
s
n
=
if
n
<
1
then
""
else
s
^
(
repeat
s
(
n
-
1
))
let
retab
str
=
global_replace
(
regexp
"
\t
"
)
(
repeat
" "
tabwidth
)
str
let
retab
str
=
Str
.
global_replace
(
Str
.
regexp
"
\t
"
)
(
repeat
" "
tabwidth
)
str
let
indent
n
=
repeat
(
repeat
" "
(
tabwidth
-
1
))
n
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment