Skip to content

Latest commit

 

History

History
88 lines (75 loc) · 1.5 KB

SEMANTICS.md

File metadata and controls

88 lines (75 loc) · 1.5 KB

Semantics

This page is a first try at describing the semantics of Hedy. Because Hedy code is transpiled into Python, we define the semantics of an Hedy program in terms of the semantics of the resulting Python code, or, in case of an error, the resulting HedyException.

Level 1

Commands

Level 1 supports:

  • print
  • ask
  • forward
  • turn
  • echo

Correct Programs

Hedy Python
print x print('x')
forward t = turtle.Turtle()
t.forward(50)
turn t = turtle.Turtle()
t.right(90)
ask x answer = input('x')
ask x
echo y
answer = input('x')
print('y', answer)

Incorrect Programs

Hedy Exception
print Incomplete Exception
ask Incomplete Exception
echo Incomplete Exception
(print | ask | forward | turn | echo) (any text)? Invalid Exception
any valid line(s) of code not using ask
echo x
Lonely Echo
_SPACE (print | ask | forward | turn | echo) (any text)? Invalid space