-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:coco33920/ocaml-baguettesharp-int…
…erpreter
- Loading branch information
Showing
8 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
🥐 🧅 🍞🥚 🧅 🧁 🎂 🧄 🧄 🥖 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
🥐 🧅 🍉 Hello, World ! 🍉 🧄 🥖 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 🧄 🧄 🥖 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
🥐 🧅 🥐🍫 🧅 🧄 🧄 🥖 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 🍉 🧄 🧄 🥖 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters