summaryrefslogtreecommitdiffstats
blob: 624c2e64ae8431464eb49ee7c83c3eb37723dbaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*******************************************************************************
 * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/

grammar org.eclipse.etrice.generator.FSMtest with org.eclipse.xtext.common.Terminals

generate fsmtest "http://www.eclipse.org/etrice/generator/FSMtest"

Model:
	(
		FsmDefinitions+=FsmDefinition |
		RandomTests+=RandomTest
	)*;
	
FsmDefinition:
	'fsmdefinition' name=ID
	'initial' states+=StateDeclaration
	(states+=StateDeclaration)*
	';' 
;
	
RandomTest:
	'randomtest' name=ID
	'fsm:' fsm=[FsmDefinition|ID]
	loopsDeclaration = LoopsDeclaration
	(seedDeclaration = SeedDeclaration)?
	';' 
;

GuardDeclaration:
	signal=SignalDeclaration
;

TransitionDeclaration:
	'transition' name=ID 'to' destination=[StateDeclaration|ID]
	(
		'trigger:' trigger=SignalDeclaration
	)?
	(
		'guards:'
		(triggers+=GuardDeclaration)+
	)?
	(
		'constraints:'
		(
			precondition+=PreconditionDeclaration |
			postcondition+=PostconditionDeclaration
		)+
	)?
	';' 
;

ConditionDeclaration:
	'condition' signal=SignalDeclaration
;

PreconditionDeclaration:
	'precondition' signal=SignalDeclaration
;

PostconditionDeclaration:
	'postcondition' signal=SignalDeclaration
;

StateDeclaration:
	'state' name=ID 
	(
		'constraints:'
		(condition+=ConditionDeclaration)+
	)?
	(transitions+=TransitionDeclaration)+
	';' 
;

LoopsDeclaration:
	'loops:' val=INT
;

SeedDeclaration:
	'randseed:' val=INT
;

SignalDeclaration:
	(port=ID '.')? signame=ID (('=' intVal=INT) | ('=' strVal=STRING))?
;