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
e9ae0066
Commit
e9ae0066
authored
11 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Moved some helper functions to utils
parent
0829ab94
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-2
1 addition, 2 deletions
Makefile
parser.mly
+1
-8
1 addition, 8 deletions
parser.mly
stringify.ml
+1
-19
1 addition, 19 deletions
stringify.ml
util.ml
+15
-7
15 additions, 7 deletions
util.ml
with
18 additions
and
36 deletions
Makefile
+
1
−
2
View file @
e9ae0066
RESULT
:=
mincss
RESULT
:=
mincss
BASENAMES
:=
types stringify parser lexer
util
parse main
BASENAMES
:=
types
util
stringify parser lexer parse main
OFILES
:=
$(
addsuffix .cmx,
$(
BASENAMES
))
OFILES
:=
$(
addsuffix .cmx,
$(
BASENAMES
))
OCAMLCFLAGS
:=
-g
OCAMLCFLAGS
:=
-g
...
@@ -34,7 +34,6 @@ lexer.cmi: lexer.ml
...
@@ -34,7 +34,6 @@ lexer.cmi: lexer.ml
parser.cmx
:
parser.cmi lexer.cmi
parser.cmx
:
parser.cmi lexer.cmi
parser.mli
:
parser.ml
parser.mli
:
parser.ml
parse.cmx
:
lexer.cmi parser.cmx
parse.cmx
:
lexer.cmi parser.cmx
util.cmx
:
stringify.cmx
main.cmx
:
parse.cmx util.cmx
main.cmx
:
parse.cmx util.cmx
stringify.cmx parser.cmi parser.cmx lexer.cmx util.cmx parse.cmx main.cmx
:
\
stringify.cmx parser.cmi parser.cmx lexer.cmx util.cmx parse.cmx main.cmx
:
\
types.cmi
types.cmi
...
...
This diff is collapsed.
Click to expand it.
parser.mly
+
1
−
8
View file @
e9ae0066
...
@@ -9,14 +9,7 @@
...
@@ -9,14 +9,7 @@
*)
*)
open
Lexing
open
Lexing
open
Types
open
Types
open
Util
(* 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
type
term_t
=
Term
of
expr
|
Operator
of
string
type
term_t
=
Term
of
expr
|
Operator
of
string
...
...
This diff is collapsed.
Click to expand it.
stringify.ml
+
1
−
19
View file @
e9ae0066
open
Types
open
Types
open
Util
let
tab
=
" "
let
tab
=
" "
...
@@ -16,19 +17,6 @@ let string_of_num n =
...
@@ -16,19 +17,6 @@ let string_of_num n =
then
string_of_int
(
int_of_float
n
)
then
string_of_int
(
int_of_float
n
)
else
string_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
* Pretty-printing
*)
*)
...
@@ -167,12 +155,6 @@ let minify_media_query query =
...
@@ -167,12 +155,6 @@ let minify_media_query query =
pre
^
" "
^
mtype
^
" and "
^
features_str
features
pre
^
" "
^
mtype
^
" and "
^
features_str
features
|
_
->
string_of_media_query
query
|
_
->
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
let
rec
minify_statement
=
function
|
Ruleset
(
selectors
,
decls
)
->
|
Ruleset
(
selectors
,
decls
)
->
cat
","
minify_selector
selectors
^
cat
","
minify_selector
selectors
^
...
...
This diff is collapsed.
Click to expand it.
util.ml
+
15
−
7
View file @
e9ae0066
open
Printf
open
Printf
open
Str
open
Types
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
input_all
ic
=
let
n
=
in_channel_length
ic
in
let
n
=
in_channel_length
ic
in
let
buf
=
String
.
create
n
in
let
buf
=
String
.
create
n
in
...
@@ -22,11 +34,7 @@ let input_buffered ic chunksize =
...
@@ -22,11 +34,7 @@ let input_buffered ic chunksize =
in
in
read_all
(
String
.
create
chunksize
)
chunksize
0
read_all
(
String
.
create
chunksize
)
chunksize
0
let
output_css
oc
decls
=
(** Error printing *)
output_string
oc
(
Stringify
.
string_of_stylesheet
decls
);
output_char
oc
'\n'
let
print_css
=
output_css
stdout
let
noloc
=
(
""
,
0
,
0
,
0
,
0
)
let
noloc
=
(
""
,
0
,
0
,
0
,
0
)
...
@@ -41,7 +49,7 @@ let count_tabs str upto =
...
@@ -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
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
let
indent
n
=
repeat
(
repeat
" "
(
tabwidth
-
1
))
n
...
...
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