Пример #1
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     t1             = new Token(NodeType.Keyword, "return");
     t2             = new Token(NodeType.Identifier, "result");
     t3             = new Token(NodeType.Symbol, ";");
 }
Пример #2
0
 public void Setup()
 {
     sd1            = new Token(NodeType.Keyword, "constructor");
     sd1a           = new Token(NodeType.Keyword, "function");
     sd1b           = new Token(NodeType.Keyword, "method");
     sd2            = new Token(NodeType.Keyword, "void");
     sd3            = new Token(NodeType.Identifier, "doSomething");
     sd4            = new Token(NodeType.Symbol, "(");
     sd5            = new Token(NodeType.Keyword, "int");
     sd6            = new Token(NodeType.Identifier, "x");
     sd7            = new Token(NodeType.Symbol, ",");
     sd8            = new Token(NodeType.Identifier, "Game");
     sd9            = new Token(NodeType.Identifier, "game");
     sd10           = new Token(NodeType.Symbol, ")");
     sd11           = new Token(NodeType.Symbol, "{");
     vd1            = new Token(NodeType.Keyword, "var");
     vd2            = new Token(NodeType.Keyword, "boolean");
     vd3            = new Token(NodeType.Identifier, "hasStarted");
     vd4            = new Token(NodeType.Symbol, ",");
     vd5            = new Token(NodeType.Identifier, "hasFinished");
     vd6            = new Token(NodeType.Symbol, ";");
     vd7            = new Token(NodeType.Keyword, "var");
     vd8            = new Token(NodeType.Identifier, "Player");
     vd9            = new Token(NodeType.Identifier, "player");
     vd10           = new Token(NodeType.Symbol, ";");
     sd12           = new Token(NodeType.Symbol, "}");
     classUnderTest = new Grammarian();
 }
Пример #3
0
 public void Setup()
 {
     t1             = new Token(NodeType.Keyword, "class");
     t2             = new Token(NodeType.Identifier, "blah");
     t3             = new Token(NodeType.Symbol, "{");
     t4             = new Token(NodeType.Symbol, "}");
     classUnderTest = new Grammarian();
 }
Пример #4
0
 public void Setup()
 {
     cvd1           = new Token(NodeType.Keyword, "static");
     cvd1a          = new Token(NodeType.Keyword, "field");
     cvd2           = new Token(NodeType.Keyword, "boolean");
     cvd3           = new Token(NodeType.Identifier, "hasStarted");
     cvd4           = new Token(NodeType.Symbol, ",");
     cvd5           = new Token(NodeType.Identifier, "hasFinished");
     cvd6           = new Token(NodeType.Symbol, ";");
     classUnderTest = new Grammarian();
 }
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Keyword, "let"),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, "="),
         new Token(NodeType.IntegerConstant, "1234"),
         new Token(NodeType.Symbol, ";")
         );
 }
Пример #6
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Identifier, "myClass"),
         new Token(NodeType.Symbol, "."),
         new Token(NodeType.Identifier, "doSomething"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.IntegerConstant, "5"),
         new Token(NodeType.Symbol, ")")
         );
 }
Пример #7
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Identifier, "subroutineName"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.IntegerConstant, "5"),
         new Token(NodeType.Symbol, ","),
         new Token(NodeType.StringConstant, "rhubarb"),
         new Token(NodeType.Symbol, ")")
         );
 }
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Keyword, "do"),
         new Token(NodeType.Identifier, "something"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, ";")
         );
 }
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Keyword, "while"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.Identifier, "inProgress"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, "{"),
         new Token(NodeType.Keyword, "let"),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, "="),
         new Token(NodeType.Identifier, "y"),
         new Token(NodeType.Symbol, ";"),
         new Token(NodeType.Symbol, "}")
         );
 }
Пример #10
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Keyword, "do"),
         new Token(NodeType.Identifier, "myClass"),
         new Token(NodeType.Symbol, "."),
         new Token(NodeType.Identifier, "something"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.IntegerConstant, "5"),
         new Token(NodeType.Symbol, "+"),
         new Token(NodeType.IntegerConstant, "3"),
         new Token(NodeType.Symbol, ","),
         new Token(NodeType.Identifier, "blah"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, ";")
         );
     classUnderTest.AddToSymbolTable("blah", IdentifierKind.Argument, null);
     classUnderTest.AddToSymbolTable("myClass", IdentifierKind.Field, "MyClass");
 }
Пример #11
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     classUnderTest.LoadTokens(
         new Token(NodeType.Keyword, "while"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.Identifier, "inProgress"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, "{"),
         new Token(NodeType.Keyword, "let"),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, "="),
         new Token(NodeType.Identifier, "y"),
         new Token(NodeType.Symbol, ";"),
         new Token(NodeType.Symbol, "}")
         );
     classUnderTest.AddToSymbolTable("x", IdentifierKind.Var, null);
     classUnderTest.AddToSymbolTable("y", IdentifierKind.Var, null);
     classUnderTest.AddToSymbolTable("inProgress", IdentifierKind.Field, null);
 }
Пример #12
0
 public void Setup()
 {
     classUnderTest = new Grammarian();
     t1             = new Token(NodeType.Keyword, "if");
     t2             = new Token(NodeType.Symbol, "(");
     t3             = new Token(NodeType.Symbol, "(");
     t4             = new Token(NodeType.Identifier, "x");
     t5             = new Token(NodeType.Symbol, "*");
     t6             = new Token(NodeType.IntegerConstant, "5");
     t7             = new Token(NodeType.Symbol, ")");
     t8             = new Token(NodeType.Symbol, ">");
     t9             = new Token(NodeType.IntegerConstant, "30");
     t10            = new Token(NodeType.Symbol, ")");
     t11            = new Token(NodeType.Symbol, "{");
     t12            = new Token(NodeType.Keyword, "return");
     t13            = new Token(NodeType.Symbol, ";");
     t14            = new Token(NodeType.Symbol, "}");
     t15            = new Token(NodeType.Keyword, "else");
     t16            = new Token(NodeType.Symbol, "{");
     t17            = new Token(NodeType.Keyword, "return");
     t18            = new Token(NodeType.Identifier, "result");
     t19            = new Token(NodeType.Symbol, ";");
     t20            = new Token(NodeType.Symbol, "}");
 }
Пример #13
0
 public void Setup()
 {
     tokens = new[] {
         new Token(NodeType.Keyword, "class"),
         new Token(NodeType.Identifier, "MyClass"),
         new Token(NodeType.Symbol, "{"),
         new Token(NodeType.Keyword, "function"),
         new Token(NodeType.Keyword, "void"),
         new Token(NodeType.Identifier, "doSomething"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.Keyword, "int"),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, "{"),
         new Token(NodeType.Keyword, "var"),
         new Token(NodeType.Keyword, "boolean"),
         new Token(NodeType.Identifier, "hasStarted"),
         new Token(NodeType.Symbol, ";"),
         new Token(NodeType.Symbol, "}"),
         new Token(NodeType.Keyword, "function"),
         new Token(NodeType.Keyword, "void"),
         new Token(NodeType.Identifier, "doSomethingElse"),
         new Token(NodeType.Symbol, "("),
         new Token(NodeType.Keyword, "int"),
         new Token(NodeType.Identifier, "x"),
         new Token(NodeType.Symbol, ")"),
         new Token(NodeType.Symbol, "{"),
         new Token(NodeType.Keyword, "var"),
         new Token(NodeType.Keyword, "boolean"),
         new Token(NodeType.Identifier, "hasStarted"),
         new Token(NodeType.Symbol, ";"),
         new Token(NodeType.Symbol, "}"),
         new Token(NodeType.Symbol, "}")
     };
     classUnderTest = new Grammarian();
 }