public void ProgramRepeatWithBreak() { string source = @"PROGRAM stexample VAR x : BOOL; END_VAR x := TRUE; REPEAT x := FALSE; BREAK; UNTIL x = FALSE END_REPEAT; END_PROGRAM; "; STCompiler compiler = new STCompiler(); Assert.IsTrue(compiler.Compile(source)); }
public void ProgramIf() { string source = @"PROGRAM stexample VAR OUTPUT1 : BOOL; END_VAR OUTPUT1 := TRUE; IF INPUT1 = TRUE THEN OUTPUT1 := TRUE; END_IF; END_PROGRAM; "; STCompiler compiler = new STCompiler(); Assert.IsTrue(compiler.Compile(source)); }
public void ProgramAssignCompositeID() { string source = @"PROGRAM pippo VAR x:BOOL; END_VAR x.y:='hello world'; END_PROGRAM;"; STCompiler compiler = new STCompiler(); Assert.IsTrue(compiler.Compile(source)); }
public void ProgramAssign() { string source = @"PROGRAM pippo VAR x:BOOL; END_VAR x:=1; END_PROGRAM;"; STCompiler compiler = new STCompiler(); Assert.IsTrue(compiler.Compile(source)); }
public void ProgramWhile() { string source = @"PROGRAM stexample VAR x,y : INTEGER; END_VAR WHILE Y < 10 DO y:= y+1; END_WHILE; END_PROGRAM; "; STCompiler compiler = new STCompiler(); var result = compiler.Compile(source); foreach (var x in compiler.Errors) { TestContext.WriteLine(String.Format("{0} {1} {2}", x.Line, x.Column, x.Message)); } Assert.IsTrue(result); }
public void ProgramFunctionCallAssign() { string source = @"PROGRAM stexample VAR x : BOOL; END_VAR x:= f(x:=10, y:= 20); END_PROGRAM; "; STCompiler compiler = new STCompiler(); var result = compiler.Compile(source); foreach (var x in compiler.Errors) { TestContext.WriteLine(String.Format("{0} {1} {2}", x.Line, x.Column, x.Message)); } Assert.IsTrue(result); }
public void ProgramCase() { string source = @"PROGRAM stexample VAR x : BOOL; END_VAR x := TRUE; CASE y OF 1: x:=1; 2: y:=2; END_CASE; END_PROGRAM; "; STCompiler compiler = new STCompiler(); var result = compiler.Compile(source); foreach (var x in compiler.Errors) { TestContext.WriteLine(String.Format("{0} {1} {2}", x.Line, x.Column, x.Message)); } Assert.IsTrue(result); }
public void ProgramIfElseIfMulti() { string source = @"PROGRAM stexample VAR OUTPUT1 : INTEGER; END_VAR OUTPUT1 := TRUE; IF INPUT1 = 1 THEN OUTPUT1 := TRUE; ELSEIF INPUT1 = 2 THEN OUTPUT1 := FALSE; ELSEIF INPUT1 = 3 THEN OUTPUT1 := FALSE; ELSE OUTPUT1 := FALSE; END_IF; END_PROGRAM; "; STCompiler compiler = new STCompiler(); Assert.IsTrue(compiler.Compile(source)); }