KAREL OMI Version 1.2 por Cesar Cepeda
Para comentarios escriba a cesar@auronix.com

Revisado por Eduardo Urias Barrientos AKA Wero Shinoda

 TUTORIAL DE KAREL

BNF for Karel
Java Syntax

ClassDeclaration ::= "class" Identifier  ClassBody  EOF
ClassBody ::= "{"
     [ MethodDeclaration] ...
      ConstructorDeclaration  
     [ MethodDeclaration] ...
"}"
MethodDeclaration ::= ResultType   MethodDeclarator  Block
ConstructorDeclaration ::= MethodDeclarator  Block
MethodDeclarator ::= Identifier  OptionalFormalParameter
OptionalFormalParameter ::= "(" [ Identifier ] ")"
ResultType ::= { "void" | "define" }
EmptyArguments ::= "(" ")"
OptionalArgument ::= "(" [ IntExp ] ")"
Statement ::= ( Block
| EmptyStatement
| IfStatement
| WhileStatement
| IterateStatement
| TurnoffStatement
| TurnleftStatement
| MoveStatement
| PickbeeperStatement
| PutbeeperStatement
| CallStatement )
Block ::= "{" [ Statement ] ... "}"
EmptyStatement ::= ";"
CallStatement ::= Identifier   OptionalArgument ";"
IntExp ::= { Decimal | Identifier | "pred" "(" IntExp ")" | "succ" "(" IntExp ")" }
Expression ::= AndClause [ "||" AndClause ] ...
AndClause ::= NotClause [ "&&" NotClause ] ...
NotClause ::= [ "!" ] AtomClause
AtomClause ::= { "iszero" "(" IntExp ")" | BooleanFunction EmptyArguments | "(" Expression ")" }
IfStatement ::= "if" "(" Expression ")" Statement ["else" Statement ]
WhileStatement ::= "while" "(" Expression ")" Statement
IterateStatement ::= "iterate" "(" IntExp ")" Statement
TurnoffStatement ::= "turnoff" EmptyArguments ";"
TurnleftStatement ::= "turnleft" EmptyArguments ";"
MoveStatement ::= "move" EmptyArguments ";"
PickbeeperStatement ::= "pickbeeper" EmptyArguments ";"
PutbeeperStatement ::= "putbeeper" EmptyArguments ";"
Identifier ::= Letter [ Letter | Digit | "-" ] ...
Decimal ::= { {"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"} [ Digit ] ...
| "0" }
String ::= anything in quotes on a single line
BooleanFunction ::= {"frontIsClear"
| "frontIsBlocked"
| "leftIsClear"
| "leftIsBlocked"
| "rightIsClear"
| "rightIsBlocked"
| "nextToABeeper"
| "notNextToABeeper"
| "anyBeepersInBeeperBag"
| "noBeepersInBeeperBag"
| "facingNorth"
| "facingSouth"
| "facingEast"
| "facingWest"
| "notFacingNorth"
| "notFacingSouth"
| "notFacingEast"
| "notFacingWest"}
Digit ::= {"0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"}
Letter ::= a letter of the alphabet
EOF ::= end of file mark

Instant Pane Definition

InstantProgram ::= [ MethodDeclaration | NativeDeclaration | Statement ] ...  EOF


Comments

The two Java/C++ comment styles are supported:
  • /* In line comment */
  • // Rest of line comment


End-Of-Page