logoPlayer-syntax.galgas 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. syntax logoPlayer_syntax (logoPlayer_lexique) {
  2. rule <start_symbol> {
  3. # Routine definition
  4. $PROGRAM$
  5. @routineMap routineArray = {}
  6. <routines> !? routineArray
  7. $BEGIN$
  8. <instructions> !? routineArray
  9. $END$
  10. $.$
  11. }
  12. rule <routines> ?! @routineMap routineArray {
  13. repeat
  14. while
  15. <routine> !? routineArray
  16. end
  17. }
  18. rule <routine> ?! @routineMap ioRoutineArray {
  19. $ROUTINE$
  20. $identifier$ ?let @lstring routineId
  21. $BEGIN$
  22. <instructions> !? ioRoutineArray
  23. $END$
  24. [ !? ioRoutineArray insertKey !routineId ]
  25. }
  26. rule <instructions> ?! @routineMap ioRoutineArray {
  27. repeat
  28. while
  29. <instruction> !? ioRoutineArray
  30. end
  31. }
  32. rule <instruction> ?! @routineMap ioRoutineArray {
  33. select
  34. <move>
  35. or
  36. <set_pen>
  37. or
  38. <call_routine> !? ioRoutineArray
  39. end
  40. $;$
  41. }
  42. rule <move> {
  43. select
  44. $FORWARD$
  45. or
  46. $ROTATE$
  47. end
  48. $integer$ ?let @luint moveLen
  49. }
  50. rule <set_pen> {
  51. $PEN$
  52. select
  53. $UP$
  54. or
  55. $DOWN$
  56. end
  57. }
  58. rule <call_routine> ?! @routineMap ioRoutineArray {
  59. $CALL$
  60. $identifier$ ?let @lstring routineId
  61. [ ioRoutineArray searchKey !routineId ]
  62. }
  63. }