Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pga
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
pga
Commits
f8778da5
Commit
f8778da5
authored
Jul 02, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
9340893b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
pga.ml
pga.ml
+18
-13
stringify.ml
stringify.ml
+3
-1
No files found.
pga.ml
View file @
f8778da5
open
Printf
open
Types
open
Types
open
Stringify
open
Stringify
open
Parse
open
Parse
let
main
()
=
let
main
()
=
let
argc
=
Array
.
length
Sys
.
argv
in
let
usage
status
=
let
usage
status
=
printf
"usage: %s command [args]
\n
"
Sys
.
argv
.
(
0
);
prerr_endline
(
"usage: "
^
Sys
.
argv
.
(
0
)
^
" command [args]"
);
printf
"command:
\n
"
;
prerr_endline
"command:"
;
printf
" help
\n
"
;
prerr_endline
" help show this help page"
;
printf
" echo PROGRAM
\n
"
;
prerr_endline
" echo PROGRAM pretty-print a program"
;
status
prerr_endline
"input program syntax:"
;
prerr_endline
" - omit omega sign after closing parenthesis"
;
prerr_endline
" - write dollar sign ($) instead of pound sign"
;
exit
status
in
in
if
argc
=
1
then
begin
usage
1
let
argc
=
Array
.
length
Sys
.
argv
in
end
else
if
argc
=
1
then
usage
1
;
begin
match
Sys
.
argv
.
(
1
)
with
match
Sys
.
argv
.
(
1
)
with
|
"help"
->
|
"help"
->
usage
0
usage
0
|
"echo"
when
argc
>
2
->
|
"echo"
when
argc
>
2
->
printf
"%s
\n
"
(
string_of_program
(
parse_string
Sys
.
argv
.
(
2
)));
print_endline
(
string_of_program
(
parse_string
Sys
.
argv
.
(
2
)))
0
|
_
->
|
_
->
usage
1
usage
1
end
;
exit
0
let
()
=
exit
(
main
()
)
let
()
=
main
(
)
stringify.ml
View file @
f8778da5
open
Types
open
Types
let
omega
=
"
\207\137
"
let
string_of_basic
ins
=
ins
let
string_of_basic
ins
=
ins
let
string_of_primitive
=
function
let
string_of_primitive
=
function
...
@@ -12,5 +14,5 @@ let string_of_primitive = function
...
@@ -12,5 +14,5 @@ let string_of_primitive = function
let
rec
string_of_program
=
function
let
rec
string_of_program
=
function
|
Primitive
p
->
string_of_primitive
p
|
Primitive
p
->
string_of_primitive
p
|
Concat
l
->
String
.
concat
";"
(
List
.
map
string_of_program
l
)
|
Concat
l
->
String
.
concat
";"
(
List
.
map
string_of_program
l
)
|
Repeat
p
->
"("
^
string_of_program
p
^
")
\207\137
"
|
Repeat
p
->
"("
^
string_of_program
p
^
")
"
^
omega
|
Empty
->
""
|
Empty
->
""
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