Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
e2a72da9
Commit
e2a72da9
authored
Aug 20, 2015
by
Laszlo Domoszlai
Browse files
some print cases
parent
87e99838
Changes
2
Hide whitespace changes
Inline
Side-by-side
interpreter/main.c
View file @
e2a72da9
...
...
@@ -57,7 +57,7 @@ int main()
// char* funstream = "160 F13 example.Start0 0 AF11 example.map2 VF11 example.incAF17 _predefined._Cons2 LI1 AF17 _predefined._Cons2 LI2 AF17 _predefined._Cons2 LI3 VF16 _predefined._Nil36 F11 example.inc1 1 AF3 add2 VA0 LI1 148 F11 example.map2 1 SVA0 2 C16 _predefined._NilVF16 _predefined._NilC17 _predefined._ConsAF17 _predefined._Cons2 AA1 1 VL0 AF11 example.map2 VA1 VL1 50 A2 17 _predefined._Cons2 0 16 _predefined._Nil0 0 ";
// [_predefined._Cons [2] [_predefined._Cons [3] [_predefined._Cons [4] [_predefined._Nil]]]]
char
*
funstream
=
"4
4
F13 example.Start0 0 AF11 example.fib1 LI3
5
119 F11 example.fib1 1 IAF2 lt2 VA0 LI2 LI1 AF3 add2 AF11 example.fib1 AF3 sub2 VA0 LI1 AF11 example.fib1 AF3 sub2 VA0 LI2 "
;
char
*
funstream
=
"4
3
F13 example.Start0 0 AF11 example.fib1 LI3 119 F11 example.fib1 1 IAF2 lt2 VA0 LI2 LI1 AF3 add2 AF11 example.fib1 AF3 sub2 VA0 LI1 AF11 example.fib1 AF3 sub2 VA0 LI2 "
;
int
nrfuns
=
parse
(
&
funstream
,
strlen
(
funstream
));
printf
(
"Number of functions parsed: %d
\n
"
,
nrfuns
);
...
...
interpreter/thunk.c
View file @
e2a72da9
...
...
@@ -18,6 +18,9 @@ int printDesc(Desc* f)
case
FT_SLICE
:
printDesc
(((
SliceEntry
*
)
f
)
->
forward_ptr
);
return
f
->
arity
;
case
FT_PRIM
:
printf
(
"%s"
,
((
PrimEntry
*
)
f
)
->
name
);
return
f
->
arity
;
case
FT_FUN
:
printf
(
"%s"
,
((
FunEntry
*
)
f
)
->
name
);
return
f
->
arity
;
...
...
@@ -150,8 +153,8 @@ void eval(Thunk* thunk)
thunk
=
thunk
->
_forward_ptr
;
}
//
print(thunk, false);
//
printf("\n");
print
(
thunk
,
false
);
printf
(
"
\n
"
);
switch
(
thunk
->
desc
->
type
)
{
...
...
@@ -207,9 +210,20 @@ void print(Thunk* thunk, bool force)
{
printf
(
"%d"
,
thunk
->
_int
);
}
else
if
((
FunEntry
*
)
thunk
->
desc
==
__BOOL__
)
{
if
(
thunk
->
_bool
)
{
printf
(
"True"
);
}
else
{
printf
(
"False"
);
}
}
else
{
printf
(
"print
Desc
: unhandled BOXED LIT
\n
"
);
printf
(
"print: unhandled BOXED LIT
\n
"
);
exit
(
-
1
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment