root / trunk / compiler / ooasCompiler / src / org / momut / ooas / codegen / prologsymbolic / OoaPrologSymbolicVisitor.java @ 7
1 |
/**
|
---|---|
2 |
*
|
3 |
* OOAS Compiler
|
4 |
*
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology.
|
6 |
* This code is based on the C# Version of the OOAS Compiler, which is
|
7 |
* copyright 2015 by the Institute of Software Technology, Graz University
|
8 |
* of Technology with portions copyright by the AIT Austrian Institute of
|
9 |
* Technology. All rights reserved.
|
10 |
*
|
11 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
12 |
*
|
13 |
* If you modify the file please update the list of contributors below to in-
|
14 |
* clude your name. Please also stick to the coding convention of using TABs
|
15 |
* to do the basic (block-level) indentation and spaces for anything after
|
16 |
* that. (Enable the display of special chars and it should be pretty obvious
|
17 |
* what this means.) Also, remove all trailing whitespace.
|
18 |
*
|
19 |
* Contributors:
|
20 |
* Willibald Krenn (AIT)
|
21 |
* Stephan Zimmerer (AIT)
|
22 |
* Markus Demetz (AIT)
|
23 |
* Christoph Czurda (AIT)
|
24 |
*
|
25 |
*/
|
26 |
|
27 |
|
28 |
package org.momut.ooas.codegen.prologsymbolic; |
29 |
|
30 |
import java.util.Date; |
31 |
|
32 |
import org.momut.ooas.ast.identifiers.MainModule; |
33 |
import org.momut.ooas.codegen.prolog.OoaPrologIdentifier; |
34 |
import org.momut.ooas.codegen.prolog.OoaPrologVisitor; |
35 |
import org.momut.ooas.parser.ParserState; |
36 |
|
37 |
public final class OoaPrologSymbolicVisitor extends OoaPrologVisitor |
38 |
{ |
39 |
@Override
|
40 |
public void visit(MainModule mainModule) |
41 |
{ |
42 |
m_emitter.AppendLine("% OOAS Compiler Generated");
|
43 |
// m_emitter.AppendLine("%" + Mogentes.Program.GetProgramVersion().ToString().Replace(Environment.NewLine, Environment.NewLine + "%")));
|
44 |
m_emitter.AppendLine("% Code-Gen Version: 0.3 symbolic");
|
45 |
m_emitter.Append("% Generated: "); m_emitter.AppendLine(new Date().toString()); |
46 |
m_emitter.AppendLine("%------------------------------------------------------------------------");
|
47 |
m_emitter.AppendLine("");
|
48 |
m_emitter.AppendLine(String.format(":- module(%s, [var/2, input/1, searchDepth/1, qspace/2]).", m_nameSpace)); |
49 |
m_emitter.AppendLine(":- use_module(library(file_systems)).");
|
50 |
m_emitter.AppendLine(":- use_module(library(process)).");
|
51 |
m_emitter.AppendLine(":- use_module(library(clpfd)).");
|
52 |
m_emitter.AppendLine(":- use_module(library(clpb)).");
|
53 |
m_emitter.AppendLine(":- use_module(library(lists)).");
|
54 |
m_emitter.AppendLine(":- use_module(library(avl)).");
|
55 |
m_emitter.AppendLine(":- use_module(library(ordsets)).");
|
56 |
m_emitter.AppendLine(":- use_module(library(system)).");
|
57 |
// m_emitter.AppendLine(":- use_module(library(gauge)).");
|
58 |
m_emitter.AppendLine(":- use_module(library(terms)).");
|
59 |
m_emitter.AppendLine(":- use_module(library(sets)).");
|
60 |
m_emitter.AppendLine(":- use_module(library(random)).");
|
61 |
|
62 |
m_emitter.AppendLine(":- public(as/0).");
|
63 |
m_emitter.AppendLine(":- dynamic(as/0).");
|
64 |
m_emitter.AppendLine(":- dynamic(qstate_init/1).");
|
65 |
m_emitter.AppendLine(":- dynamic(qstate_constraints/1).");
|
66 |
m_emitter.AppendLine(":- public(qstate_init/1).");
|
67 |
m_emitter.AppendLine(":- public(qstate_constraints/1).");
|
68 |
m_emitter.AppendLine(":- dynamic(type/2).");
|
69 |
|
70 |
/*definition of search depth*/
|
71 |
m_emitter.AppendLine("");
|
72 |
m_emitter.AppendLine("% maximal search depth (change at will)");
|
73 |
m_emitter.AppendLine(String.format("searchDepth(%s).", m_maxSearchDepth)); |
74 |
m_emitter.AppendLine("");
|
75 |
|
76 |
/*definition of types*/
|
77 |
ExportTypes(mainModule); |
78 |
/* variable definition */
|
79 |
ExportVariables(mainModule); |
80 |
|
81 |
/* state definition */
|
82 |
ExportState(mainModule); |
83 |
/* initial state */
|
84 |
ExportInitialState(mainModule); |
85 |
/* input actions (controllables) */
|
86 |
ExportControllableActions(mainModule); |
87 |
/* output actions (observables) */
|
88 |
ExportObservableActions(mainModule); |
89 |
/* named actions */
|
90 |
ExportMethodsAndActions(mainModule); |
91 |
|
92 |
/* all types */
|
93 |
m_emitter.AppendLine("%definition of types");
|
94 |
m_emitter.AppendLine(m_scratchbook.typeDefinitions().toString()); |
95 |
m_emitter.AppendLine(createTypeVisitor().GetInternalTypeDefinitions()); |
96 |
} |
97 |
|
98 |
|
99 |
public OoaPrologSymbolicVisitor(ParserState aState, int maxSearchDepth, String nameSpace ) |
100 |
{ |
101 |
super(aState,
|
102 |
maxSearchDepth, |
103 |
nameSpace, |
104 |
new OoaPrologSymbolicExpression.Factory(),
|
105 |
new OoaPrologIdentifier.Factory(),
|
106 |
new OoaPrologSymbolicStatement.Factory(),
|
107 |
new OoaPrologSymbolicType.Factory());
|
108 |
} |
109 |
} |