Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
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
uva
Commits
cf3cb8a8
Commit
cf3cb8a8
authored
Nov 27, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
funclang series4: Added basic version of assignment 10.
parent
19a4225d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
funclang-taddeus/series4/ass10.ml
funclang-taddeus/series4/ass10.ml
+83
-0
No files found.
funclang-taddeus/series4/ass10.ml
0 → 100644
View file @
cf3cb8a8
type
arithOp
=
Plus
of
int
*
int
|
Minus
of
int
*
int
|
Times
of
int
*
int
|
Divide
of
int
*
int
|
Modulo
of
int
*
int
type
relOp
=
EQ
of
int
*
int
|
NEQ
of
int
*
int
|
LT
of
int
*
int
|
LTE
of
int
*
int
|
GT
of
int
*
int
|
GTE
of
int
*
int
type
logicOp
=
AND
of
bool
*
bool
|
OR
of
bool
*
bool
type
binOp
=
ArithOp
of
arithOp
|
RelOp
of
relOp
|
LogicOp
of
logicOp
type
monOp
=
UnaryMinus
of
int
|
Negation
of
bool
type
const
=
BoolConst
of
bool
|
IntConst
of
int
type
expr
=
Enclosure
of
expr
|
BinOp
of
expr
*
binOp
*
expr
|
MonOp
of
monOp
*
expr
|
Id
of
string
|
Const
of
const
let
rec
eval_expr
=
let
eval_binOp
=
let
eval_arithOp
=
function
Plus
(
a
,
b
)
->
"("
^
(
string_of_int
a
)
^
" + "
^
(
string_of_int
b
)
|
Minus
(
a
,
b
)
->
"("
^
(
string_of_int
a
)
^
" - "
^
(
string_of_int
b
)
^
")"
|
Times
(
a
,
b
)
->
"("
^
(
string_of_int
a
)
^
" * "
^
(
string_of_int
b
)
^
")"
|
Divide
(
a
,
b
)
->
"("
^
(
string_of_int
a
)
^
" / "
^
(
string_of_int
b
)
^
")"
|
Modulo
(
a
,
b
)
->
"("
^
(
string_of_int
a
)
^
" mod "
^
(
string_of_int
b
)
^
")"
in
let
eval_relOp
=
function
EQ
(
a
,
b
)
->
(
string_of_int
a
)
^
" = "
^
(
string_of_int
b
)
|
NEQ
(
a
,
b
)
->
(
string_of_int
a
)
^
" != "
^
(
string_of_int
b
)
|
LT
(
a
,
b
)
->
(
string_of_int
a
)
^
" < "
^
(
string_of_int
b
)
|
LTE
(
a
,
b
)
->
(
string_of_int
a
)
^
" <= "
^
(
string_of_int
b
)
|
GT
(
a
,
b
)
->
(
string_of_int
a
)
^
" > "
^
(
string_of_int
b
)
|
GTE
(
a
,
b
)
->
(
string_of_int
a
)
^
" >= "
^
(
string_of_int
b
)
in
let
eval_logicOp
=
function
AND
(
a
,
b
)
->
(
string_of_bool
a
)
^
" && "
^
(
string_of_bool
b
)
|
OR
(
a
,
b
)
->
(
string_of_bool
a
)
^
" || "
^
(
string_of_bool
b
)
in
function
ArithOp
op
->
eval_arithOp
(
op
)
|
RelOp
op
->
eval_relOp
(
op
)
|
LogicOp
op
->
eval_logicOp
(
op
)
in
let
eval_monOp
=
function
UnaryMinus
i
->
"-"
^
string_of_int
i
|
Negation
b
->
"!"
^
string_of_bool
b
in
let
eval_const
=
function
IntConst
i
->
string_of_int
i
|
BoolConst
b
->
string_of_bool
b
in
function
Enclosure
e
->
"("
^
eval_expr
(
e
)
^
")"
|
BinOp
(
e1
,
op
,
e2
)
->
eval_expr
(
e1
)
^
eval_binOp
(
op
)
^
eval_expr
(
e2
)
|
MonOp
(
op
,
e
)
->
eval_monOp
(
op
)
^
eval_expr
(
e
)
|
Id
id
->
id
|
Const
c
->
eval_const
(
c
)
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