Language Grammar

From ABL
(Redirected from ABL Language Grammar)
Jump to: navigation, search

Introduction

The following grammar is generated by JJDoc and a custom elisp script.

Any productions referred to but not defined are part of the Java grammar itself, and are mostly self-explanatory.

Grammar

BehaviorUnit ::= ( "package" Name ";" )? ( ( ImportDeclaration ) | ( ConstantDeclaration ) )* <BEHAVING_ENTITY> AblName <LBRACE> ( TeamNeededForSuccessDefaultDeclaration )? ( DecisionCycleSMCallDeclaration )? ( ConflictDeclaration )* ( AblDeclaration )* ( BehaviorDefinition )* ( InitialTree )* <RBRACE> <EOF>
ConstantDeclaration ::= <CONSTANTS> Name ( "." "*" )? ";"
ConflictDeclaration ::= <CONFLICT> AblName ( AblName )+ <SEMICOLON>
PropertyDeclaration ::= <PROPERTY> Type AblName <SEMICOLON>
AblDeclaration ::= ( AblVariableDeclaration <SEMICOLON> )
| WMERegistration
| ActionRegistration
| WMEDeclaration
| PropertyDeclaration
WMERegistration ::= <REGISTER> <WME> WMEClass <WITH> Name <SEMICOLON>
ActionRegistration ::= <REGISTER> <ACTION> AblName <LPAREN> ( AblSimpleType ( <COMMA> AblSimpleType )* )? <RPAREN> <WITH> Name <SEMICOLON>
BehaviorDefinition ::= ( BehaviorTypeModifier )* BehaviorType <BEHAVIOR> AblName <LPAREN> ( AblSimpleType AblSimpleType ( <COMMA> AblSimpleType AblSimpleType )* )? <RPAREN> <LBRACE> ( BehaviorModifiers )* ( AblVariableDeclaration <SEMICOLON> )* ( BehaviorStep )* <RBRACE>
BehaviorModifiers ::= ( Precondition | Specificity | ContextCondition | EntryCondition | NumberNeededForSuccess | TeamMemberSpecifier | SuccessCondition | ReinforcementSignals | ReinforcementState )
Specificity ::= <SPECIFICITY> <INTEGER_LITERAL> <SEMICOLON>
NumberNeededForSuccess ::= <NUMBER_NEEDED_FOR_SUCCESS> <INTEGER_LITERAL> <SEMICOLON>
TeamMemberSpecifier ::= <TEAMMEMBERS> ( <IDENTIFIER> )+ <SEMICOLON>
InitialTree ::= <INITIAL_TREE> <LBRACE> ( BehaviorStep )* <RBRACE>
BehaviorType ::= ( <SEQUENTIAL> | <PARALLEL> | <COLLECTION> )
BehaviorTypeModifier ::= ( <ATOMIC> )
| ( <JOINT> )
| ( <ADAPTIVE> )
Precondition ::= <PRECONDITION> <LBRACE> TestExpression <RBRACE>
TestExpression ::= ( <IDENTIFIER> )? ( WMETestSequence )+
DefaultMemoryLookahead ::= <IDENTIFIER> WMETestSequence
WMETestSequence ::= <LBRACE> <IDENTIFIER> ( WMETest | <LPAREN> ConditionalExpression <RPAREN> )+ <RBRACE>
| ( WMETest | <LPAREN> ConditionalExpression <RPAREN> )
WMETest ::= ( <BANG> )? ( Name <ASSIGN> )? <LPAREN> WMEClass ( WMEFieldTest )* <RPAREN>
WMEClass ::= AblName
WMEFieldTest ::= <IDENTIFIER> ( <V_BIND> | <GT> | <LT> | <EQ> | <LE> | <GE> | <NE> ) AblExpression
AblLiteral ::= ( <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> | <DOUBLE_LITERAL> | <CHARACTER_LITERAL> | <STRING_LITERAL> | BooleanLiteral | NullLiteral )
AblExpression ::= ( Name | AblLiteral )
ContextCondition ::= <CONTEXT_CONDITION> <LBRACE> TestExpression <RBRACE>
EntryCondition ::= <ENTRY_CONDITION> <LBRACE> TestExpression <RBRACE>
SuccessCondition ::= <SUCCESS_CONDITION> <LBRACE> TestExpression <RBRACE>
ReinforcementSignals ::= <R_SIGNAL> <LBRACE> ( ReinforcementSignal )* <RBRACE>
ReinforcementSignal ::= AblExpression <IF> <LBRACE> TestExpression <RBRACE>
ReinforcementState ::= <STATE> <LBRACE> StateCondition ( ( AblVariableDeclaration <SEMICOLON> ) | ( Statement ) )* StateReturn <RBRACE>
StateCondition ::= <LBRACE> TestExpression <RBRACE>
StateReturn ::= <STATE> <RETURN> <LPAREN> AblExpression ( <COMMA> AblExpression )* <RPAREN> <SEMICOLON>
BehaviorStep ::= ( <WITH> <LPAREN> StepModifier ( <COMMA> StepModifier )* <RPAREN> )? ModifiableStep
| FailStep
| SucceedStep
ModifiableStep ::= PrimitiveActStep
| MentalActStep
| GoalStep
| ModifyStep
| AnonymousStep
| WaitStep
PrimitiveActStep ::= PrimitiveAct
MentalActStep ::= MentalAct
GoalStep ::= Goal
WaitStep ::= Wait
AnonymousStep ::= AnonymousBlock
ModifyStep ::= ( ( <MOVE_STEP> Name <INTEGER_LITERAL> Name <INTEGER_LITERAL> Name Name <SEMICOLON> ) | ( <DELETE_STEP> Name <INTEGER_LITERAL> Name Name <SEMICOLON> ) | ( <ADD_STEP> Name <INTEGER_LITERAL> Name Name BehaviorStep ) )
FailStep ::= <FAIL> <SEMICOLON>
SucceedStep ::= <SUCCEED> <SEMICOLON>
AnonymousBlock ::= BehaviorType <LBRACE> ( AblVariableDeclaration <SEMICOLON> )* ( BehaviorStep )+ <RBRACE>
StepModifier ::= SuccessTest
| PriorityModifier
| <IGNORE_FAILURE>
| Persistence
| <EFFECT_ONLY>
| <TEAM_EFFECT_ONLY>
| NamedProperty
| <POST>
| <POST_TO> <IDENTIFIER>
| <ONE_NEEDED_FOR_SUCCESS>
| <TEAM_NEEDED_FOR_SUCCESS>
SuccessTest ::= <SUCCESS_TEST> <LBRACE> TestExpression <RBRACE>
PriorityModifier ::= ( <PRIORITY_MODIFIER> <INTEGER_LITERAL> )
| ( <PRIORITY> <INTEGER_LITERAL> )
Persistence ::= ( <PERSISTENT> PersistenceType )
| ( <PERSISTENT> )
NamedProperty ::= <PROPERTY> AblName AblExpression
PersistenceType ::= ( <WHEN_FAILS> | <WHEN_SUCCEEDS> )
PrimitiveAct ::= <ACT> AblName <LPAREN> ( AblExpression ( <COMMA> AblExpression )* )? <RPAREN> <SEMICOLON>
MentalAct ::= <MENTAL_ACT> <LBRACE> ( ( AblVariableDeclaration <SEMICOLON> ) | ( Statement ) )* <RBRACE>
Goal ::= ( <JOINT> )? ( <SUBGOAL> | <SPAWNGOAL> ) AblName <LPAREN> ( AblExpression ( <COMMA> AblExpression )* )? <RPAREN> ( <AT> Name )? <SEMICOLON>
Wait ::= <WAIT> <SEMICOLON>
AblVariableDeclaration ::= Type VariableDeclarator ( "," VariableDeclarator )*
AblSimpleType ::= ( PrimitiveType | <IDENTIFIER> )
AblName ::= <IDENTIFIER>
WMEDeclaration ::= <WME> AblName ( <EXTENDS> AblName )? <LBRACE> ( AblVariableDeclaration <SEMICOLON> )* <RBRACE>
TeamNeededForSuccessDefaultDeclaration ::= <JOINT_GOAL_SUCCESS_NEGOTIATION> ( <TEAM_NEEDED_FOR_SUCCESS> | <ONE_NEEDED_FOR_SUCCESS> ) <SEMICOLON>
DecisionCycleSMCallDeclaration ::= <DECISION_CYCLE_SM_CALL> Name <SEMICOLON>