123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- syntax logoPlayer_syntax (logoPlayer_lexique) {
- rule <start_symbol> {
- # Routine definition
- $PROGRAM$
- @routineMap routineArray = {}
- <routines> !? routineArray
- $BEGIN$
- <instructions> !? routineArray
- $END$
- $.$
- }
- rule <routines> ?! @routineMap routineArray {
- repeat
- while
- <routine> !? routineArray
- end
- }
- rule <routine> ?! @routineMap ioRoutineArray {
- $ROUTINE$
- $identifier$ ?let @lstring routineId
- $BEGIN$
- <instructions> !? ioRoutineArray
- $END$
- [ !? ioRoutineArray insertKey !routineId ]
- }
- rule <instructions> ?! @routineMap ioRoutineArray {
- repeat
- while
- <instruction> !? ioRoutineArray
- end
- }
- rule <instruction> ?! @routineMap ioRoutineArray {
- select
- <move>
- or
- <set_pen>
- or
- <call_routine> !? ioRoutineArray
- end
- $;$
- }
- rule <move> {
- select
- <move_forward>
- or
- <move_rotate>
- end
- }
- rule <move_forward> {
- $FORWARD$
- $integer$ ?let @luint moveLen
- @instruction move = @forward.new { !moveLen }
- }
- rule <move_rotate> {
- $ROTATE$
- $integer$ ?let @luint moveAngle
- @instruction move = @rotate.new { !moveAngle }
- }
- rule <set_pen> {
- $PEN$
- select
- $UP$
- @instruction setPen = @penUp.new {}
- or
- $DOWN$
- @instruction setPen = @penDown.new {}
- end
- }
- rule <call_routine> ?! @routineMap ioRoutineArray {
- $CALL$
- $identifier$ ?let @lstring routineId
- [ ioRoutineArray searchKey !routineId ]
- }
-
- }
|