Skip to content

Commit

Permalink
Implement FBF parser
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-adam committed Jan 19, 2025
1 parent be92bcc commit b317d66
Show file tree
Hide file tree
Showing 47 changed files with 6,255 additions and 22 deletions.
203 changes: 203 additions & 0 deletions .output/actual/fbf/il/parseAssemblyApp/Bubblesort.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
[ Compiler
( LineBreaks 80 )
, Compiler
( Dim
[ "tot"
, "cur"
, "subcur"
, "temp"
, "lastchange"
, "templastchange"
, "temp2"
, "compres"
, "times"
, "temp3"
]
)
, Compiler
( Table 256 "mem" )
, Code Line
, Code
( Msg
[ "OK"
, "give"
, "me"
, "a"
, "sentence"
, "and"
, "then"
, "press"
, "enter."
, "I"
, "cannot"
, "hold"
, "more"
, "than"
, "256"
, "letters"
]
)
, Code Line
, Code
( Read "temp" )
, Code
( UnEq
( Literal 10 ) "temp" []
)
, Code
( Inc 1 "tot" )
, Code
( WTable
( Variable "temp" )
( Variable "tot" ) "mem"
)
, Code
( Read "temp" )
, Code End
, Code
( Msg
[ "Wait"
, "while"
, "I"
, "bubble-sort"
, "the"
, "characters..."
]
)
, Code Line
, Code
( Inc 1 "cur" )
, Code
( Copy "tot" "lastchange" )
, Code
( UnEq
( Literal 0 ) "lastchange" []
)
, Code
( Inc 1 "times" )
, Code Line
, Code
( Set 1 "subcur" )
, Code
( Inc 1 "tot" )
, Code
( UnEq
( Variable "tot" ) "subcur" []
)
, Code
( RTable
( Variable "subcur" ) "mem" "temp"
)
, Code
( Print [ "temp" ] )
, Code
( Inc 1 "subcur" )
, Code End
, Code
( Dec 1 "tot" )
, Code
( Set 1 "cur" )
, Code
( Copy "lastchange" "templastchange" )
, Code
( Set 0 "lastchange" )
, Code
( UnEq
( Variable "templastchange" ) "cur" []
)
, Code
( RTable
( Variable "cur" ) "mem" "temp"
)
, Code
( Inc 1 "cur" )
, Code
( RTable
( Variable "cur" ) "mem" "temp2"
)
, Code
( Comp
( Variable "temp" )
( Variable "temp2" ) "compres"
)
, Code
( IfEq
( Literal 0 ) "compres" []
)
, Code
( Copy "cur" "lastchange" )
, Code
( WTable
( Variable "temp" )
( Variable "cur" ) "mem"
)
, Code
( Dec 1 "cur" )
, Code
( WTable
( Variable "temp2" )
( Variable "cur" ) "mem"
)
, Code
( Inc 1 "cur" )
, Code End
, Code End
, Code End
, Code
( Set 1 "cur" )
, Code
( Inc 1 "tot" )
, Code Line
, Code
( Msg
[ "Finished!"
, "It"
, "took"
, "me"
]
)
, Code Space
, Code
( Byte2Ascii
( Variable "times" ) "temp" "temp2" "temp3"
)
, Code
( Print
[ "temp"
, "temp2"
, "temp3"
]
)
, Code Space
, Code
( Msg
[ "itterations."
, "While"
, "the"
, "sentence"
, "was"
]
)
, Code Space
, Code
( Dec 1 "tot" )
, Code
( Byte2Ascii
( Variable "tot" ) "temp" "temp2" "temp3"
)
, Code
( Print
[ "temp"
, "temp2"
, "temp3"
]
)
, Code Space
, Code
( Msg
[ "characters"
, "long."
]
)
, Code Line
]
173 changes: 173 additions & 0 deletions .output/actual/fbf/il/parseAssemblyApp/FindTheNumber.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
[ Compiler
( LineBreaks 80 )
, Compiler
( Dim
[ "low"
, "high"
, "guess"
, "temp"
, "temp2"
, "temp3"
]
)
, Code
( Msg
[ "Think"
, "of"
, "a"
, "number"
, "between"
, "1"
, "and"
, "100."
, "And"
, "press"
, "any"
, "key"
, "when"
, "ready."
]
)
, Code
( Set 1 "low" )
, Code
( Set 100 "high" )
, Code
( Read "temp" )
, Code
( UnEq
( Variable "high" ) "low" []
)
, Code
( Sub
( Variable "high" )
( Variable "low" ) "guess"
)
, Code
( Div
( Variable "guess" )
( Literal 2 ) "guess"
)
, Code
( Add
( Variable "low" )
( Variable "guess" ) "guess"
)
, Code
( Byte2Ascii
( Variable "guess" ) "temp" "temp2" "temp3"
)
, Code
( Msg
[ "My"
, "guess"
, "is"
]
)
, Code Space
, Code
( Print
[ "temp"
, "temp2"
, "temp3"
]
)
, Code
( Msg [ "." ] )
, Code Line
, Code
( Msg
[ "1."
, "Correct!"
]
)
, Code Line
, Code
( Msg
[ "2."
, "Smaller"
, "than"
, "the"
, "hidden"
, "number."
]
)
, Code Line
, Code
( Msg
[ "3."
, "Bigger"
, "than"
, "the"
, "hidden"
, "number."
]
)
, Code Line
, Code
( Read "temp" )
, Code
( Read "temp2" )
, Code
( IfEq
( Literal 49 ) "temp" []
)
, Code
( Copy "guess" "low" )
, Code
( Copy "low" "high" )
, Code End
, Code
( IfEq
( Literal 50 ) "temp" []
)
, Code
( Copy "guess" "high" )
, Code
( Dec 1 "high" )
, Code End
, Code
( IfEq
( Literal 51 ) "temp" []
)
, Code
( Copy "guess" "low" )
, Code
( Inc 1 "low" )
, Code End
, Code
( Comp
( Variable "low" )
( Variable "high" ) "temp"
)
, Code
( IfEq
( Literal 1 ) "temp" []
)
, Code
( Msg
[ "I"
, "found"
, "it!"
, "It's"
]
)
, Code Space
, Code
( Byte2Ascii
( Variable "low" ) "temp" "temp2" "temp3"
)
, Code
( Print
[ "temp"
, "temp2"
, "temp3"
]
)
, Code
( Msg [ "." ] )
, Code Line
, Code End
, Code Line
, Code End
]
Loading

0 comments on commit b317d66

Please sign in to comment.