Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compilerLaLog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
JAUJAY Augustin
compilerLaLog
Commits
6e082ac0
Commit
6e082ac0
authored
3 years ago
by
Augustin Jaujay
Browse files
Options
Downloads
Patches
Plain Diff
Instruction Get fonctionnelle
parent
ba7dc02c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
expr/fun/eval.ml
+2
-0
2 additions, 0 deletions
expr/fun/eval.ml
expr/fun/toPfx.ml
+2
-0
2 additions, 0 deletions
expr/fun/toPfx.ml
pfx/basic/ast.ml
+2
-0
2 additions, 0 deletions
pfx/basic/ast.ml
pfx/basic/eval.ml
+3
-1
3 additions, 1 deletion
pfx/basic/eval.ml
with
9 additions
and
1 deletion
expr/fun/eval.ml
+
2
−
0
View file @
6e082ac0
...
...
@@ -12,3 +12,5 @@ let rec eval env = function
|
_
,
v
->
(
BinOp
.
eval
op
)
(
eval
env
e1
)
v
end
|
Uminus
e
->
-
(
eval
env
e
)
|
App
(
_
,
_
)
->
failwith
"Not yet supported"
(* TODO *)
|
Fun
(
_
,
_
)
->
failwith
"Not yet supported"
This diff is collapsed.
Click to expand it.
expr/fun/toPfx.ml
+
2
−
0
View file @
6e082ac0
...
...
@@ -10,5 +10,7 @@ let rec generate = function
|
Binop
(
Bmul
,
a
,
b
)
->
(
generate
b
)
@
(
generate
a
)
@
[
Mul
]
|
Binop
(
Bdiv
,
a
,
b
)
->
(
generate
b
)
@
(
generate
a
)
@
[
Div
]
|
Binop
(
Bmod
,
a
,
b
)
->
(
generate
b
)
@
(
generate
a
)
@
[
Rem
]
|
App
(
_
,
_
)
->
failwith
"Not yet supported"
(* TODO *)
|
Fun
(
_
,
_
)
->
failwith
"Not yet supported"
|
Uminus
x
->
(
generate
x
)
@
[
Push
0
]
@
[
Sub
]
|
Var
_
->
failwith
"Not yet supported"
This diff is collapsed.
Click to expand it.
pfx/basic/ast.ml
+
2
−
0
View file @
6e082ac0
...
...
@@ -14,6 +14,8 @@ let string_of_command = function
|
Mul
->
"Mul"
|
Div
->
"Div"
|
Rem
->
"Rem"
|
Exec
->
"Exec"
|
Get
->
"Get"
let
string_of_commands
cmds
=
String
.
concat
" "
(
List
.
map
string_of_command
cmds
)
...
...
This diff is collapsed.
Click to expand it.
pfx/basic/eval.ml
+
3
−
1
View file @
6e082ac0
...
...
@@ -30,7 +30,9 @@ let step state =
|
Rem
::_,
[]
->
Error
(
"Nothing to divide"
,
state
)
|
Rem
::_,
_
::
0
::_
->
Error
(
"Forbidden operation"
,
state
)
|
Get
::_,
i
::
stack
when
(
List
.
length
stack
)
<
i
->
Error
(
"Invalid get operation"
,
state
)
|
Get
::_,
i
::_
when
i
<
O
->
Error
(
"Cannot get negative index"
,
state
)
|
Get
::_,
i
::_
when
i
<
0
->
Error
(
"Cannot get negative index"
,
state
)
|
Get
::_,
[]
->
Error
(
"Nothing to get"
,
state
)
|
Exec
::_,
_
->
Error
(
"Not yet supported"
,
state
)
(* TODO *)
(* Valid configurations *)
|
(
Push
x
)
::
q
,
stack
->
Ok
(
q
,
x
::
stack
)
|
Pop
::
q
,
_
::
stack
->
Ok
(
q
,
stack
)
...
...
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