Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pga
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
pga
Commits
f8778da5
Commit
f8778da5
authored
10 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
9340893b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pga.ml
+18
-13
18 additions, 13 deletions
pga.ml
stringify.ml
+3
-1
3 additions, 1 deletion
stringify.ml
with
21 additions
and
14 deletions
pga.ml
+
18
−
13
View file @
f8778da5
open
Printf
open
Types
open
Stringify
open
Parse
let
main
()
=
let
argc
=
Array
.
length
Sys
.
argv
in
let
usage
status
=
printf
"usage: %s command [args]
\n
"
Sys
.
argv
.
(
0
);
printf
"command:
\n
"
;
printf
" help
\n
"
;
printf
" echo PROGRAM
\n
"
;
status
prerr_endline
(
"usage: "
^
Sys
.
argv
.
(
0
)
^
" command [args]"
);
prerr_endline
"command:"
;
prerr_endline
" help show this help page"
;
prerr_endline
" echo PROGRAM pretty-print a program"
;
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
if
argc
=
1
then
begin
usage
1
end
else
let
argc
=
Array
.
length
Sys
.
argv
in
if
argc
=
1
then
usage
1
;
begin
match
Sys
.
argv
.
(
1
)
with
|
"help"
->
usage
0
|
"echo"
when
argc
>
2
->
printf
"%s
\n
"
(
string_of_program
(
parse_string
Sys
.
argv
.
(
2
)));
0
print_endline
(
string_of_program
(
parse_string
Sys
.
argv
.
(
2
)))
|
_
->
usage
1
end
;
exit
0
let
()
=
exit
(
main
()
)
let
()
=
main
()
This diff is collapsed.
Click to expand it.
stringify.ml
+
3
−
1
View file @
f8778da5
open
Types
let
omega
=
"
\207\137
"
let
string_of_basic
ins
=
ins
let
string_of_primitive
=
function
...
...
@@ -12,5 +14,5 @@ let string_of_primitive = function
let
rec
string_of_program
=
function
|
Primitive
p
->
string_of_primitive
p
|
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
->
""
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