Skip to content

Commit

Permalink
Merge pull request #33 from coco33920/emojis
Browse files Browse the repository at this point in the history
Emojis
  • Loading branch information
vanilla-extracts authored Apr 12, 2023
2 parents 5ddbcd6 + 4e05c5c commit 71f166e
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/conditions.baguette
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ CROISSANT CHOUQUETTE FLAN CHOUQUETTE CUPCAKE POPCAKE CLAFOUTIS CLAFOUTIS BAGUETT
CROISSANT CHOUQUETTE PAINDEPICE CHOUQUETTE CUPCAKE CUPCAKE CLAFOUTIS CLAFOUTIS BAGUETTE
//FALSE
CROISSANT CHOUQUETTE CREPE CHOUQUETTE CUPCAKE CUPCAKE CLAFOUTIS CLAFOUTIS BAGUETTE
//FALSE
//TRUE
CROISSANT CHOUQUETTE CREPE CHOUQUETTE CUPCAKE POPCAKE CLAFOUTIS CLAFOUTIS BAGUETTE
18 changes: 18 additions & 0 deletions examples/emoji_condition.baguette
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//FALSE
🥐 🧅 🥮🍵🍫 🧅 5 4 🧄 🧄 🥖
//TRUE
🥐 🧅 🥚 🧅 8 8 🧄 🧄 🥖
//FALSE
🥐 🧅 🎂🍋 🧅 8 8 🧄 🧄 🥖
//TRUE
🥐 🧅 🍞🥐 🧅 10 5 🧄 🧄 🥖
//FALSE
🥐 🧅 🥧 🧅 10 10 🧄 🧄 🥖
//FALSE
🥐 🧅 🎂🥚 🧅 🧁 🎂 🧄 🧄 🥖
//TRUE
🥐 🧅 🍞🌶️ 🧅 🧁 🧁 🧄 🧄 🥖
//FALSE
🥐 🧅 🍞🥚 🧅 🧁 🧁 🧄 🧄 🥖
//TRUE
🥐 🧅 🍞🥚 🧅 🧁 🎂 🧄 🧄 🥖
1 change: 1 addition & 0 deletions examples/emoji_hello_world.baguette
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
🥐 🧅 🍉 Hello, World ! 🍉 🧄 🥖
16 changes: 16 additions & 0 deletions examples/emoji_math.baguette
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Addition a+b
🥐 🧅 🧁🍷 🧅 2 , 3 , 12 , 20 🧄 🧄 🥖
// Subtraction a-b
🥐 🧅 🍞🍇 🧅 2 , 2 🧄 🧄 🥖
// Division a/b
🥐 🧅 🥐🍫 🧅 2 , 2 🧄 🧄 🥖
// Random [[a,b]]
🥐 🧅 🥨 🧅 2 , 10 🧄 🧄 🥖
// Power a^b
🥐 🧅 🎂🧈 🧅 2 , 3 🧄 🧄 🥖
// Logarithm a base b
🥐 🧅 🥮🖼️ 🧅 1000 , 10 🧄 🧄 🥖
// n-ième nombre de fibonnacci
🥐 🧅 🧁💰 🧅 10 🧄 🧄 🥖
// Racine carré
🥐 🧅 🧁🍫 🧅 16 🧄 🧄 🥖
1 change: 1 addition & 0 deletions examples/emoji_read.baguette
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
🥐 🧅 🥐🍫 🧅 🧄 🧄 🥖
89 changes: 89 additions & 0 deletions examples/emoji_turing.baguette
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//Program reading subroutine, the input line must like STATE-TAPESTATE-TOWRITE-DIRECTION-NEWSTATE (0-1-0-r-0 :
//when the machine is in state 0 and reads 1 in the tape it writes 0, move the head to the write and stay in the state 0
🍨 🍉 program_read 🍉
🥮
🌰 🧅 🍉 line 🍉 , ⛈️🍫 🧅 0 🧄 🧄
🌰 🧅 🍉 rline 🍉 , 🧇 🧅 🧈 🧅 🍉 line 🍉 🧄 🍉 - 🍉 🧄 🧄
🌰 🧅 🍉 temp_state 🍉 🎂🥕 🧅 🥧🍓 🧅 0 , 🧈 🧅 🍉 rline 🍉 🧄 🧄 🧄 🧄
🌰 🧅 🍉 tapestate 🍉 🎂🥕 🧅 🥧🍓 🧅 1 , 🧈 🧅 🍉 rline 🍉 🧄 🧄 🧄 🧄
🌰 🧅 🍉 towrite 🍉 🎂🥕 🧅 🥧🍓 🧅 2 , 🧈 🧅 🍉 rline 🍉 🧄 🧄 🧄 🧄
🌰 🧅 🍉 direction 🍉 🥧🍓 🧅 3 , 🧈 🧅 🍉 rline 🍉 🧄 🧄 🧄
🌰 🧅 🍉 newstate 🍉 🥧🍓 🧅 4 , 🧈 🧅 🍉 rline 🍉 🧄 🧄 🧄

🥧🫐 🧅 🧈 🧅 🍉 tapestate 🍉 🧄 , 🥧🍓 🧅 🧈 🧅 🍉 temp_state 🍉 🧄 🧈 🧅 🍉 delta0 🍉 🧄 🧄 🧈 🧅 🍉 towrite 🍉 🧄 🧄
🥧🫐 🧅 🧈 🧅 🍉 tapestate 🍉 🧄 , 🥧🍓 🧅 🧈 🧅 🍉 temp_state 🍉 🧄 🧈 🧅 🍉 delta1 🍉 🧄 🧄 🧈 🧅 🍉 direction 🍉 🧄 🧄
🥧🫐 🧅 🧈 🧅 🍉 tapestate 🍉 🧄 , 🥧🍓 🧅 🧈 🧅 🍉 temp_state 🍉 🧄 🧈 🧅 🍉 delta2 🍉 🧄 🧄 🧈 🧅 🍉 newstate 🍉 🧄 🧄

🌰 🧅 🍉 i 🍉 , 🧁🍷 🧅 1 , 🧈 🧅 🍉 i 🍉 🧄 🧄 🧄

🥠 🎂🍋 🧅 🧈 🧅 🍉 i 🍉 🧄 , 🧈 🧅 🍉 n 🍉 🧄 🧄
🍰 🥮
🍞 🍉 program_read 🍉
🍪 🥖
🍪 🥖

//Step subroutine, updates the tape, head position and state of the machine
🍨 🍉 step 🍉
🥮
🥠 🍞🍎 🧅 🥮🍵🍫 🧅 🧈 🧅 🍉 state 🍉 🧄 , 🍉 H 🍉 🧄 🧄
🍰 🥮
🌰 🧅 🍉 current_tapestate 🍉 , 🎂🥕 🧅 🧇🇧🇪 🧅 🧈 🧅 🍉 head 🍉 🧄 , 🧈 🧅 🍉 tape 🍉 🧄 🧄 🧄 🧄
🌰 🧅 🍉 current0 🍉 , 🥧🍓 🧅 🎂🥕 🧅 🧈 🧅 🍉 state 🍉 🧄 🧄 🧈 🧅 🍉 delta0 🍉 🧄 🧄 🧄
🌰 🧅 🍉 current1 🍉 , 🥧🍓 🧅 🎂🥕 🧅 🧈 🧅 🍉 state 🍉 🧄 🧄 🧈 🧅 🍉 delta1 🍉 🧄 🧄 🧄
🌰 🧅 🍉 current2 🍉 , 🥧🍓 🧅 🎂🥕 🧅 🧈 🧅 🍉 state 🍉 🧄 🧄 🧈 🧅 🍉 delta2 🍉 🧄 🧄 🧄

🌰 🧅 🍉 towrite_steptemp 🍉 , 🥧🍓 🧅 🧈 🧅 🍉 current_tapestate 🍉 🧄 , 🧈 🧅 🍉 current0 🍉 🧄 🧄 🧄
🌰 🧅 🍉 direction_steptemp 🍉 , 🥧🍓 🧅 🧈 🧅 🍉 current_tapestate 🍉 🧄 , 🧈 🧅 🍉 current1 🍉 🧄 🧄 🧄
🌰 🧅 🍉 newstate_steptemp 🍉 , 🥧🍓 🧅 🧈 🧅 🍉 current_tapestate 🍉 🧄 , 🧈 🧅 🍉 current2 🍉 🧄 🧄 🧄

🌰 🧅 🍉 arr_tape 🍉 , 🥞 🧅 🧈 🧅 🍉 tape 🍉 🧄 🧄 🧄
🥧🫐 🧅 🧈 🧅 🍉 head 🍉 🧄 , 🧈 🧅 🍉 arr_tape 🍉 🧄 , 🥯 🧅 🧈 🧅 🍉 towrite_steptemp 🍉 🧄 🧄 🧄
🌰 🧅 🍉 tape 🍉 , 🇨🇦🍁 🧅 🧈 🧅 🍉 arr_tape 🍉 🧄 🧄 🧄
🌰 🧅 🍉 state 🍉 , 🧈 🧅 🍉 newstate_steptemp 🍉 🧄 🧄

🌰 🧅 🍉 head 🍉 , 🧁🍷 🧅 -1 , 🧈 🧅 🍉 head 🍉 🧄 🧄 🧄
🍞🍫 🧅 🍉 Step (tape,state): (%d,%d) 🍉 , 🍩 🧅 🧈 🧅 🍉 tape 🍉 🧄 , 🍉 2 🍉 , 🍉 🍉 🧄 , 🧈 🧅 🍉 state 🍉 🧄 🧄

🥠 🥮🍵🍫 🧅 🧈 🧅 🍉 direction_steptemp 🍉 🧄 , 🍉 * 🍉 🧄
🍰 🥮
🌰 🧅 🍉 head 🍉 , 🧁🍷 🧅 1 , 🧈 🧅 🍉 head 🍉 🧄 🧄 🧄
🍪
🥠 🥮🍵🍫 🧅 🧈 🧅 🍉 direction_steptemp 🍉 🧄 , 🍉 r 🍉 🧄
🍰 🥮
🌰 🧅 🍉 head 🍉 , 🧁🍷 🧅 2 , 🧈 🧅 🍉 head 🍉 🧄 🧄 🧄
🍪 🥖
🍪 🥖
🍪 🥖

🍨 🍉 run 🍉
🥮
🍞 🍉 step 🍉
🥠 🍞🍎 🧅 🥮🍵🍫 🧅 🧈 🧅 🍉 state 🍉 🧄 , 🍉 H 🍉 🧄 🧄
🍰 🥮
🍞 🍉 run 🍉
🍪 🥖
🍪 🥖


//Turing machine initialization
//Creation of three 100 by 3 matrices to represent the transition function
//Declaraton of the initial state and the tape with the head at the first bit of the input
🌰 🧅 🍉 state 🍉 , 🍉 0 🍉 🧄 🥖
🥐 🧅 🍉 Please type the input tape 🍉 🧄 🥖
🌰 🧅 🍉 tape 🍉 , 🧇🍫 🧅 🧇🍫 🧅 🎂🎄 🧅 500 , 🍉 2 🍉 🧄 , ⛈️🍫 🧅 0 🧄 🧄 , 🎂🎄 🧅 500 , 🍉 2 🍉 🧄 🧄 🧄 🥖
🌰 🧅 🍉 head 🍉 , 500 🧄 🥖
🥐 🧅 🍉 Please type the number of line of the program 🍉 🧄 🥖
🌰 🧅 🍉 n 🍉 , ⛈️🍫 🧅 🧄 🧄 🥖
🌰 🧅 🍉 i 🍉 , 0 🧄 🥖
🌰 🧅 🍉 delta0 🍉 , 🥧🍋 🧅 100 , 3 , 0 🧄 🥖
🌰 🧅 🍉 delta1 🍉 , 🥧🍋 🧅 100 , 3 , 0 🧄 🥖
🌰 🧅 🍉 delta2 🍉 , 🥧🍋 🧅 100 , 3 , 0 🧄 🥖

//Reading program from STDIN
🍞 🍉 program_read 🍉 🥖

//Running the machine
🍞 🍉 run 🍉 🥖

//Printing output (tape), final state (which should be H), and position of the head
🍞🍫 🧅 🍉 Final (tape,state,head): (%d,%d,%d) 🍉 , 🍩 🧅 🧈 🧅 🍉 tape 🍉 🧄 , 🍉 2 🍉 , 🍉 🍉 🧄 , 🧈 🧅 🍉 state 🍉 🧄 , 🧈 🧅 🍉 head 🍉 🧄 🧄 🥖
17 changes: 17 additions & 0 deletions src/base/token.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ let string_to_token str =
| "CRUMBLE" -> PARAM_BEGIN
| "//" -> COMMENT
| "," -> COMMA
| "🧅" -> LEFT_PARENTHESIS
| "🧄" -> RIGHT_PARENTHESIS
| "🍉" -> QUOTE
| "🥖" -> SEMI_COLON
| "🧁" -> BOOL_TOKEN true
| "🎂" -> BOOL_TOKEN false
| "🥮" -> KEYWORD "BEGIN"
| "🍪" -> KEYWORD "END"
| "🍨" -> KEYWORD "LABEL"
| "🍞" -> KEYWORD "GOTO"
| "🥠" -> KEYWORD "IF"
| "🍰" -> KEYWORD "THEN"
| "🍊" -> KEYWORD "LOAD"
| "🍫" -> ARRAY_BEGIN
| "🍬" -> ARRAY_END
| "🍭" -> PARAM_END
| "🍮" -> PARAM_BEGIN
| str -> (
try INT_TOKEN (int_of_string str) with
| Failure _ -> (
Expand Down
54 changes: 54 additions & 0 deletions src/functions/functions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ let recognize_function name list_of_args =
| "MILLEFEUILLE" -> Math.floor list_of_args
| "FRAISIER" -> Math.ceil list_of_args
| "QUATREQUART" -> add_variable list_of_args

| "TIRAMISU" ->
Conditions.equality list_of_args (*operateur de conditions & binaire*)
| "MERINGUE" -> Conditions.inferior_large list_of_args
Expand All @@ -152,13 +153,15 @@ let recognize_function name list_of_args =
| "PAINDEPICE" -> Conditions.binary_or list_of_args
| "CREPE" -> Conditions.binary_xor list_of_args
| "CHAUSSONAUXPOMMES" -> Conditions.binary_not list_of_args

| "TARTEAUXFRAISES" -> Array_manipulation.access list_of_args (*ACCESS*)
| "TARTEAUXFRAMBOISES" -> Array_manipulation.replace list_of_args (*REPLACE*)
| "TARTEAUXPOMMES" -> Array_manipulation.create_array list_of_args (*CREATE*)
| "TARTEALARHUBARBE" ->
Array_manipulation.create_matrix list_of_args (*MCREATE*)
| "GLACE" -> Array_manipulation.display_array list_of_args (*DISPLAY*)
| "BEIGNET" -> Array_manipulation.populate list_of_args (*POPULATE*)

| "DOUGHNUT" -> String_manipulation.replace list_of_args (*SREPLACE*)
| "BUCHE" -> String_manipulation.create list_of_args (*SCREATE*)
| "GAUFFREDELIEGE" -> String_manipulation.concat list_of_args (*SADD*)
Expand All @@ -174,6 +177,57 @@ let recognize_function name list_of_args =
String_manipulation.double_from_string list_of_args (*DFS*)
| "FRANGIPANE" -> String_manipulation.bool_from_string list_of_args (*BFS*)
| "APFELSTRUDEL" -> return list_of_args

| "🍞🍫" -> printf list_of_args
| "🥐" -> print list_of_args
| "🧈" -> read_variable list_of_args
| "⛈️🍫" -> read_entry list_of_args
| "🌰" -> add_variable list_of_args

| "🧁🍷" -> Math.add list_of_args
| "🍒" -> Math.mult list_of_args
| "🎂🧈" -> Math.power list_of_args
| "🧁🍫" -> Math.sqrt list_of_args
| "🧁💰" -> Math.fibonacci list_of_args
| "🍞🍇" -> Math.substract list_of_args
| "🥐🍫" -> Math.divide list_of_args
| "🥨" -> Math.randint list_of_args
| "🥮🖼️" -> Math.logb list_of_args
| "🎂🎵" -> Math.opposite list_of_args
| "🥮🧈" -> Math.floor list_of_args
| "🎂🍓" -> Math.ceil list_of_args

| "🥮🍵🍫" -> Conditions.equality list_of_args
| "🥚" -> Conditions.inferior_large list_of_args
| "🎂🍋" -> Conditions.inferior_strict list_of_args
| "🍞🥐" -> Conditions.superior_large list_of_args
| "🥧" -> Conditions.superior_strict list_of_args
| "🎂🥚" -> Conditions.binary_and list_of_args
| "🍞🌶️" -> Conditions.binary_or list_of_args
| "🍞🥚" -> Conditions.binary_xor list_of_args
| "🍞🍎" -> Conditions.binary_not list_of_args

| "🥧🍓" -> Array_manipulation.access list_of_args
| "🥧🫐" -> Array_manipulation.replace list_of_args
| "🥧🍎" -> Array_manipulation.create_array list_of_args
| "🥧🍋" -> Array_manipulation.create_matrix list_of_args
| "🍦" -> Array_manipulation.display_array list_of_args
| "🇫🇷🍩" -> Array_manipulation.populate list_of_args

| "🍩" -> String_manipulation.replace list_of_args
| "🎂🎄" -> String_manipulation.create list_of_args
| "🧇🍫" -> String_manipulation.concat list_of_args
| "🧇🇧🇪" -> String_manipulation.access list_of_args
| "🧇" -> String_manipulation.split list_of_args
| "🥞" -> String_manipulation.transform_to_array list_of_args
| "🇨🇦🍁" -> String_manipulation.transform_from_array list_of_args
| "🥯" -> String_manipulation.convert_to_string list_of_args
| "🎂🥕" -> String_manipulation.int_from_string list_of_args
| "🎂👑" -> String_manipulation.double_from_string list_of_args
| "🥮👑" -> String_manipulation.bool_from_string list_of_args

| "🥧🍎🇩🇪" -> return list_of_args

| _ ->
let word = Levenshtein.select_minimal_distance_word name in
Parser.Exception
Expand Down

0 comments on commit 71f166e

Please sign in to comment.