Skip to content

Commit

Permalink
add an implementation of .format, which uses the .format of EO
Browse files Browse the repository at this point in the history
  • Loading branch information
dours committed Sep 26, 2022
1 parent 04582fb commit 0c1c860
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions transpiler/src/main/eo/preface/pystring.eo
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,50 @@
index.write (index.plus 1)
a

[] > format
[args...] > ap
[stackUp] > @
memory "" > acc
memory "" > subst
memory 0 > i
memory 0 > args-index
seq > @
while.
(i.lt (value.length))
[unused]
seq > @
if.
((value.slice i 1).eq "{")
seq
subst.write ""
i.write (i.plus 1)
while.
(((value.slice i 1).eq "}").not)
[unused]
seq > @
subst.write
sprintf
"%s%s"
subst
if.
(value.slice i 1).eq ":"
"%"
value.slice i 1
i.write (i.plus 1)
0
i.write (i.plus 1)
write.
acc
sprintf
"%s%s"
acc
sprintf subst (args.get args-index)
args-index.write (args-index.plus 1)
0
acc.write (sprintf "%s%s" acc (value.slice i 1))
stackUp.forward (return (pystring acc))
0

[] > x__iter__
[self] > ap
[stackUp] > @
Expand Down

0 comments on commit 0c1c860

Please sign in to comment.