Skip to content

Latest commit

 

History

History
88 lines (83 loc) · 6.87 KB

abudsl-grammar.md

File metadata and controls

88 lines (83 loc) · 6.87 KB

Full syntax of AbU DSL

In the following, we denote with ( exp )* zero or more repetitions of exp, while with ( exp )+ one or more repetitions of exp. Furthermore, [ exp ] represents an optional occurrence of exp, while exp1 | exp2 stands for either exp1 or exp2.

Syntax for programs, devices and ECA rules

Program  ::=  ( TypeDeclaration )* ( Device [ has RuleIdList ] )+ ( ECARule )*
TypeDeclaration  ::=  define CompoundType as { FieldDeclaration }
FieldDeclaration  ::=  ( ResourceId : ( physical input PrimitiveType | physical output PrimitiveType | logical PrimitiveType ) )+
Device  ::=  DeviceId : Description { ResourceDeclaration [ where BooleanExpression ] }
ResourceDeclaration  ::=  ( PhysicalResource | LogicalResource | CompoundResource )+
PhysicalResource  ::=  physical output PrimitiveType ResourceId = Value | physical input PrimitiveType ResourceId
LogicalResource  ::=  logical PrimitiveType ResourceId = Value
CompoundResource  ::=  CompoundType ResourceId = ( [ Constructor ] )
Constructor  ::=  ResourceId = Value ( , ResourceId = Value )*
RuleIdList  ::=  ( RuleId )+
ECARule  ::=  rule RuleId on Event ( Task )+
    |  rule RuleId on Event default Action ( Task )*
    |  rule RuleId on Event for [ all ] Condition do Action owise Action
    |  rule RuleId on Event let LetDeclaration in ( Task )+
Event  ::=  ( ResourceId | *ResourceId [ ResourceId ] )+
Task  ::=  for [ all ] Condition do Action
Action  ::=  Assignment ( , Assignment ) *
Assignment  ::=  LocalResourceAccess = Expression | RemoteResourceAccess = Expression
LocalResourceAccess  ::=  [ this. ] ResourceId | [ this. ] ResourceId [ ResourceId ]
RemoteResourceAccess  ::=  ext. ResourceId | ext. ResourceId [ ResourceId ]
LetDeclaration  ::=  ResourceId := Expression ( ; ResourceId := Expression ) *

Syntax for expressions and conditions

Expression  ::=  BooleanExpression | NonBooleanExpression
Condition  ::=  BooleanExpression
BooleanExpression  ::=  BooleanValue
    |  LocalResourceAccess
    |  RemoteResourceAccess
    |  ForeignFunction
    |  ( BooleanExpression )
    |  not BooleanExpression
    |  BooleanExpression and BooleanExpression
    |  BooleanExpression or BooleanExpression
    |  NonBooleanExpression == NonBooleanExpression
    |  NonBooleanExpression != NonBooleanExpression
    |  NonBooleanExpression < NonBooleanExpression
    |  NonBooleanExpression <= NonBooleanExpression
    |  NonBooleanExpression > NonBooleanExpression
    |  NonBooleanExpression >= NonBooleanExpression
NonBooleanExpression  ::=  NumericExpression | StringExpression
NumericExpression  ::=  NumericValue
    |  LocalResourceAccess
    |  RemoteResourceAccess
    |  ForeignFunction
    |  ( NumericExpression )
    |  absint NumericExpression
    |  absdec NumericExpression
    |  NumericExpression + NumericExpression
    |  NumericExpression - NumericExpression
    |  NumericExpression * NumericExpression
    |  NumericExpression / NumericExpression
    |  NumericExpression % NumericExpression
StringExpression  ::=  StringValue
    |  LocalResourceAccess
    |  RemoteResourceAccess
    |  ForeignFunction
    |  StringExpression :: StringExpression
ForeignFunction  ::=  foreign ( StringValue ) | foreign ( StringValue ( , Param )+ )
Param  ::=  Value | LocalResourceAccess

Syntax for values, types and identifiers

ResourceId  ::=  Identifier
Identifier  ::=  Character ( Character | Digit )*
Character  ::=  a | b ... | z | A | B ... | Z
SpecialCharacter  ::=   | ! | # | ... | ~
Digit  ::=  0 | 1 | ... | 9
Value  ::=  BooleanValue | NumericValue | StringValue
BooleanValue  ::=  true | false
NumericValue  ::=  IntegerValue | DecimalValue
IntegerValue  ::=  [ - ] ( Digit )+
DecimalValue  ::=  IntegerValue . ( Digit )+
StringValue  ::=  " ( Character | SpecialCharacter | Digit )* "
Type  ::=  PrimitiveType | CompoundType
PrimitiveType  ::=  boolean | integer | decimal | string
CompoundType  ::=  Identifier
DeviceId  ::=  Identifier
Description  ::=  StringValue
RuleId  ::=  Identifier

Comments

Inline comments keyword: #
Multi-line comments start delimiter: \@
Multi-line comments end delimiter: @\