1
|
/**
|
2
|
*
|
3
|
* OOAS Compiler (Deprecated)
|
4
|
*
|
5
|
* Copyright 2015, Institute for Software Technology, Graz University of
|
6
|
* Technology. Portions are copyright 2015 by the AIT Austrian Institute
|
7
|
* of Technology. All rights reserved.
|
8
|
*
|
9
|
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
10
|
*
|
11
|
* Please notice that this version of the OOAS compiler is considered de-
|
12
|
* precated. Only the Java version is maintained.
|
13
|
*
|
14
|
* Contributors:
|
15
|
* Willibald Krenn (TU Graz/AIT)
|
16
|
* Stefan Tiran (TU Graz/AIT)
|
17
|
*/
|
18
|
|
19
|
|
20
|
using System;
|
21
|
using System.Collections.Generic;
|
22
|
using System.Text;
|
23
|
using TUG.Mogentes;
|
24
|
using TUG.Mogentes.Codegen.PrologSymbolic;
|
25
|
using TUG.Mogentes.Codegen.Prolog;
|
26
|
|
27
|
|
28
|
namespace TUG.Mogentes.Codegen.PrologSymbolic
|
29
|
{
|
30
|
|
31
|
public sealed class OoaPrologSymbolicVisitor : OoaPrologVisitor
|
32
|
{
|
33
|
public override void visit(MainModule mainModule)
|
34
|
{
|
35
|
m_emitter.AppendLine("% Argos Generated");
|
36
|
m_emitter.AppendLine(String.Format("%{0}", Mogentes.Program.GetProgramVersion().ToString().Replace(Environment.NewLine, Environment.NewLine + "%")));
|
37
|
m_emitter.AppendLine("% Code-Gen Version: 0.3 symbolic");
|
38
|
m_emitter.Append("% Generated: "); m_emitter.AppendLine(System.DateTime.Now.ToString());
|
39
|
m_emitter.AppendLine("%------------------------------------------------------------------------");
|
40
|
m_emitter.AppendLine("");
|
41
|
String nameSpace = TUG.Mogentes.Program.Options.nameSpace;
|
42
|
m_emitter.AppendLine(":- module(" + nameSpace + ", [var/2, input/1, searchDepth/1, qspace/2]).");
|
43
|
m_emitter.AppendLine(":- use_module(library(file_systems)).");
|
44
|
m_emitter.AppendLine(":- use_module(library(process)).");
|
45
|
m_emitter.AppendLine(":- use_module(library(clpfd)).");
|
46
|
m_emitter.AppendLine(":- use_module(library(clpb)).");
|
47
|
m_emitter.AppendLine(":- use_module(library(lists)).");
|
48
|
m_emitter.AppendLine(":- use_module(library(avl)).");
|
49
|
m_emitter.AppendLine(":- use_module(library(ordsets)).");
|
50
|
m_emitter.AppendLine(":- use_module(library(system)).");
|
51
|
m_emitter.AppendLine(":- use_module(library(gauge)).");
|
52
|
m_emitter.AppendLine(":- use_module(library(terms)).");
|
53
|
m_emitter.AppendLine(":- use_module(library(sets)).");
|
54
|
m_emitter.AppendLine(":- use_module(library(random)).");
|
55
|
|
56
|
m_emitter.AppendLine(":- public(as/0).");
|
57
|
m_emitter.AppendLine(":- dynamic(as/0).");
|
58
|
m_emitter.AppendLine(":- dynamic(qstate_init/1).");
|
59
|
m_emitter.AppendLine(":- dynamic(qstate_constraints/1).");
|
60
|
m_emitter.AppendLine(":- public(qstate_init/1).");
|
61
|
m_emitter.AppendLine(":- public(qstate_constraints/1).");
|
62
|
m_emitter.AppendLine(":- dynamic(type/2).");
|
63
|
|
64
|
/*definition of search depth*/
|
65
|
m_emitter.AppendLine("");
|
66
|
m_emitter.AppendLine("% maximal search depth (change at will)");
|
67
|
m_emitter.AppendLine("searchDepth(" + TUG.Mogentes.Program.Options.searchDepth + ").");
|
68
|
m_emitter.AppendLine("");
|
69
|
|
70
|
/*definition of types*/
|
71
|
ExportTypes(mainModule);
|
72
|
/* variable definition */
|
73
|
ExportVariables(mainModule);
|
74
|
|
75
|
/* state definition */
|
76
|
ExportState(mainModule);
|
77
|
/* initial state */
|
78
|
ExportInitialState(mainModule);
|
79
|
/* input actions (controllables) */
|
80
|
ExportControllableActions(mainModule);
|
81
|
/* output actions (observables) */
|
82
|
ExportObservableActions(mainModule);
|
83
|
/* named actions */
|
84
|
ExportMethodsAndActions(mainModule);
|
85
|
|
86
|
/* all types */
|
87
|
m_emitter.AppendLine("%definition of types");
|
88
|
m_emitter.AppendLine(OoaPrologType.typeDefinitions.ToString());
|
89
|
m_emitter.AppendLine(createTypeVisitor().GetInternalTypeDefinitions());
|
90
|
}
|
91
|
|
92
|
|
93
|
public OoaPrologSymbolicVisitor(ParserState aState)
|
94
|
: base(aState,
|
95
|
new OoaPrologSymbolicExpression.Factory(),
|
96
|
new OoaPrologIdentifier.Factory(),
|
97
|
new OoaPrologSymbolicStatement.Factory(),
|
98
|
new OoaPrologSymbolicType.Factory())
|
99
|
{ }
|
100
|
}
|
101
|
}
|