blob: 351678b2eba22270463cceb1c399d9ce12009c0a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* The Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*
*******************************************************************************/
grammar org.eclipse.vorto.fbeditor.Functionblock with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/vorto/metamodel/Functionblock"
FunctionblockModel:
'functionblock' name= ID '{'
functionblock = FunctionBlock
'}'
(elements += Entity)*
(enums+=Enum)* ;
FunctionBlock:
'displayname' displayname=STRING
('description' description=STRING)?
'vendor' vendor=VENDOR
'category' category=CATEGORY
'version' version=VERSION
('configuration' '{'
configuration = FBFeature
'}')?
('status' '{'
status = FBFeature
'}')?
('fault' '{'
fault = FBFeature
'}')?
('events' '{'
(events+=Event)*
'}')?
('operations' '{'
(features += Operation)*
'}')?
;
Event :
name = ID '{'
feature = FBFeature
'}'
;
terminal VERSION : ('0'..'9')* '.' ('0'..'9')* '.' ('0'..'9')*('-'ID)?;
terminal VENDOR : ('a'..'z')+ "." ('a'..'z')+ ("." ('a'..'z')+)?;
CATEGORY : ID ('/' ID)*;
FBFeature:
(properties += Property)*
;
enum PrimitiveType: string = 'string' | int = 'int' | float = 'float' | boolean = 'boolean' | datetime = 'dateTime' | double = 'double' | long = 'long' | short = 'short' | base64Binary ='base64Binary' | byte = 'byte';
ObjectType:
Entity | Enum
;
Property:
PrimitiveProperty | ObjectProperty
;
Entity:
'entity' name = ID ('extends' superType = [Entity])? '{'
properties = FBFeature
'}'
;
Presence:
mandatory = 'mandatory' | optional = 'optional'
;
PrimitiveProperty:
presence = Presence (multiplicity = 'multiple')? propName = ID 'as' type = PrimitiveType
('<' Constraints += Constraint ("," Constraints += Constraint)* '>')?
(description=STRING)?
;
ObjectProperty:
presence = Presence (multiplicity = 'multiple')? propName = ID 'as' type = [ObjectType]
(description=STRING)?
;
enum ConstraintIntervalType: min = 'MIN' | max = 'MAX' | strlen = 'STRLEN' | regex = 'REGEX' ;
terminal FLOAT: ('-')?('0'..'9')*'.'('0'..'9')*;
terminal DATE:
('0'..'9')('0'..'9')('0'..'9')('0'..'9')('-')('0'..'9')('0'..'9')('-')('0'..'9')('0'..'9')
;
terminal TIME:
('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9')(TIMEZONE)?
;
terminal fragment TIMEZONE:
'Z'|(('+'|'-')('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9'))
;
terminal DATETIME:
DATE('T')TIME
;
terminal SIGNEDINT :
'-'INT
;
IntervalType:
INT | SIGNEDINT | FLOAT | DATETIME | STRING
;
Constraint:
type = ConstraintIntervalType constraintValues = IntervalType
;
Operation :
methodName=ID '(' (params += Parameter (',' params+=Parameter)*)?')' ('returns' returnType = ReturnType)? (description=STRING)?
;
ReturnType :
ReturnObjectType | ReturnPrimitiveType
;
ReturnObjectType :
(multiplicity = 'multiple')? returnType = [ObjectType]
;
ReturnPrimitiveType :
(multiplicity = 'multiple')? returnType = PrimitiveType
;
Parameter:
PrimitiveParam | ObjectParam
;
ObjectParam :
(multiplicity = 'multiple')? paramName = ID 'as' paramType = [ObjectType]
;
PrimitiveParam :
(multiplicity = 'multiple')? paramName = ID 'as' paramType = PrimitiveType
;
Enum:
'enum' name = ID '{'
( enums += EnumLiteral (',' enums += EnumLiteral)* )?
'}'
;
EnumLiteral:
literal = ID
;