Commit 991de20e authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

refactored grammar: added TypeInstance :: DataType Name and renamed Program...

refactored grammar: added TypeInstance :: DataType Name  and renamed Program to Specification (based on cherry-picked (parts of) 9d2ca1)
parent e2a0f191
......@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace RobotCtrl
{
class Program
class Specification
{
public static string IP_ADDRESS = "127.0.0.1";
......@@ -20,7 +20,7 @@ namespace RobotCtrl
{
jointtarget val = new jointtarget { robax = new jointtarget.struct_robax(), extax = new jointtarget.struct_extax() };
TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Program.IP_ADDRESS), Program.PORT);
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Specification.IP_ADDRESS), Specification.PORT);
try
{
client.Connect(serverEndPoint);
......
......@@ -42,7 +42,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="LCRobot.cs" />
<Compile Include="Program.cs" />
<Compile Include="Specification.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......
......@@ -9,7 +9,7 @@ import se.lth.control.labcomm2014.TypeDefParser;
import se.lth.control.labcomm2014.ASTbuilder;
//import se.lth.control.labcomm2014.TypeBinding;
import se.lth.control.labcomm2014.compiler.Program;
import se.lth.control.labcomm2014.compiler.Specification;
import java.io.FileOutputStream;
import java.io.PrintStream;
......@@ -79,7 +79,7 @@ public class TDDecoder
if(d.isSampleDef()){
System.out.println("onTypeDef (sample): ");
ASTbuilder v = new ASTbuilder();
Program p = v.makeProgram((TypeDefParser.ParsedSampleDef) d);
Specification p = v.makeSpecification((TypeDefParser.ParsedSampleDef) d);
try {
//FileOutputStream f = new FileOutputStream("/tmp/foopp"+d.getName()+".txt");
//PrintStream out = new PrintStream(f);
......
......@@ -17,10 +17,11 @@ import se.lth.control.labcomm2014.compiler.LabComm;
import se.lth.control.labcomm2014.compiler.LabCommParser;
import se.lth.control.labcomm2014.compiler.List;
import se.lth.control.labcomm2014.compiler.Program;
import se.lth.control.labcomm2014.compiler.Specification;
import se.lth.control.labcomm2014.compiler.Decl;
import se.lth.control.labcomm2014.compiler.TypeDecl;
import se.lth.control.labcomm2014.compiler.SampleDecl;
import se.lth.control.labcomm2014.compiler.TypeInstance;
import se.lth.control.labcomm2014.compiler.DataType;
import se.lth.control.labcomm2014.compiler.VoidType;
import se.lth.control.labcomm2014.compiler.PrimType;
......@@ -94,8 +95,7 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
}
public void visit(TypeDefParser.ParsedField t){
t.getType().accept(this);
fieldStack.push(new Field(typeStack.pop(),t.getName()));
fieldStack.push(new Field(new TypeInstance(typeStack.pop(),t.getName())));
}
public void visit(TypeDefParser.ArrayType t){
boolean isFixed = true;
......@@ -123,12 +123,12 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
public Decl makeDecl(TypeDefParser.ParsedTypeDef d) {
d.getType().accept(this);
Decl result = new TypeDecl(typeStack.pop(), d.getName());
Decl result = new TypeDecl(new TypeInstance(typeStack.pop(), d.getName()));
return result;
}
private Program createAndCheckProgram(List<Decl> ds) {
Program p = new Program(ds);
private Specification createAndCheckSpecification(List<Decl> ds) {
Specification p = new Specification(ds);
LinkedList errors = new LinkedList();
p.errorCheck(errors);
if(errors.isEmpty()) {
......@@ -145,21 +145,21 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
}
}
public Program makeProgram(TypeDefParser.ParsedTypeDef d) {
public Specification makeSpecification(TypeDefParser.ParsedTypeDef d) {
assertStacksEmpty();
List<Decl> ds = new List<Decl>();
ds.add(makeDecl(d));
assertStacksEmpty();
return createAndCheckProgram(ds);
return createAndCheckSpecification(ds);
}
public Decl makeDecl(TypeDefParser.ParsedSampleDef d) {
d.getType().accept(this);
Decl result = new SampleDecl(typeStack.pop(), d.getName());
Decl result = new SampleDecl(new TypeInstance(typeStack.pop(), d.getName()));
return result;
}
public Program makeProgram(TypeDefParser.ParsedSampleDef d) {
public Specification makeSpecification(TypeDefParser.ParsedSampleDef d) {
assertStacksEmpty();
List<Decl> ds = new List<Decl>();
......@@ -171,7 +171,7 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
ds.add(makeDecl(d));
assertStacksEmpty();
return createAndCheckProgram(ds);
return createAndCheckSpecification(ds);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment