A top-down parser that is back-tracking. It also:

  • Allows for mutually recursive functions where each function implements Non-terminals

Process

Continue deriving from Productions until you match the required character in the input. If you get stuck, backtrack

Example

https://www.youtube.com/watch?v=nv9J5Jb7IxM

Drawing 2025-01-01 17.19.20.excalidraw

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠

Text Elements

input:

production rules:

Step 1: Set root node to E

Step 2: Derive T from E

Step 3: Derive int from T. Wrong, backtrack

Step 4: Derive int * T from T. Wrong. Backtrack

Step 5: Derive ( E ) from T. Match! advance input

Step 4: Derive int * T from T. Wrong. Backtrack

Step 6: Derive T from E

Step 7: Derive int from T

Step 8: Check match

Step 8: Check match

Now, we are at EOF, we can conclude the algorithm

Embedded files

47256e99f3fb6234bf9174684922d2e581e80d37: Pasted Image 20250101171922_286.png d0d5618ba1b755030f22c99105c1211f2c58fdb9: Pasted Image 20250101171922_291.png fa4edcdbcc09a1a04291f82f8d0f40610d75c81b: Pasted Image 20250101172145_373.png 751adf62351c338eb17608a23cdd41c335a26609: Pasted Image 20250101172200_373.png 9b69c5d8dbc9a22fc68bfb99ccfd30a8edd67a46: Pasted Image 20250101172230_374.png bd51cc85d5213350f7716fcb6f0440dd19a6c193: Pasted Image 20250101172249_375.png 11167cc32558d4bb6a67cc267945fad4ecb2f272: Pasted Image 20250101172319_376.png e027b9b3f35c8e998f8cfb6a5188380879980e5d: Pasted Image 20250101172402_260.png 7f38d58e0e63e39ba8779372412149ed697da07c: Pasted Image 20250101172456_400.png f75bc202fc27c85b0a330b3d459bed299ff68df3: Pasted Image 20250101172521_153.png

Link to original