Ejemplo n.º 1
0
		public Parser (char[] Input, IdentifierTable IDTable, bool ECMA3Mode)
		{
			this.ECMA3Mode = ECMA3Mode;
			lexer = new Tokenizer (Input, IDTable);
			diagnostics = new List<Diagnostic> ();
			Next (); // innit on first token 
		}
Ejemplo n.º 2
0
		public override void Initialize(object state, TextReader textreader, SourceUnit sourceUnit, SS.SourceLocation initialLocation)
		{
			tokenizer = new Tokenizer (textreader.ReadToEnd ().ToCharArray (), new IdentifierTable ());
			tokenizer.Position = ConvertToMJCSrcLocation(initialLocation);
			this.sourceUnit = sourceUnit;
			this.state = state;
		}
Ejemplo n.º 3
0
		public void MinusTest()
		{
			Tokenizer l1 = new Tokenizer ("$test_var--;".ToCharArray (), new IdentifierTable ());
			Assert.AreEqual (Token.Type.Identifier, l1.GetNext ().Kind, "#3.1");
			//Assert.AreEqual("$test_var", l1.Value());
			Assert.AreEqual (Token.Type.MinusMinus, l1.GetNext ().Kind, "#3.2");
			Assert.AreEqual (Token.Type.Semicolon, l1.GetNext ().Kind, "#3.3");
			//Assert.IsFalse(l1.Advance());
			Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext ().Kind, "#3.4");
		}
Ejemplo n.º 4
0
		public void AffectTest()
		{
			Tokenizer l1 = new Tokenizer ("var i = 10;".ToCharArray(), new IdentifierTable ());
			Assert.AreEqual (Token.Type.var, l1.GetNext ().Kind, "#1.1");
			Assert.AreEqual (Token.Type.Identifier, l1.GetNext().Kind,"#1.2");
			//Assert.AreEqual("i", l1.Value());
			Assert.AreEqual (Token.Type.Equal, l1.GetNext ().Kind, "#1.3");
			Assert.AreEqual (Token.Type.NumericLiteral, l1.GetNext ().Kind, "#1.4");
			//Assert.AreEqual("10", l1.Value());
			Assert.AreEqual (Token.Type.Semicolon, l1.GetNext ().Kind, "#1.5");    
			//Assert.IsFalse(l1.Advance());
			Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext ().Kind, "#1.6");   
		}
Ejemplo n.º 5
0
		public void BlockCommentTest ()
		{
			Tokenizer t = new Tokenizer ("/*abcdef*/ ;".ToCharArray (), new IdentifierTable ());
			Assert.AreEqual (Token.Type.Semicolon, t.GetNext ().Kind, "#6.1");
			Assert.AreEqual ("/*abcdef*/", t.Comments[0].Spelling, "#6.2");
		}
Ejemplo n.º 6
0
		public void LineCommentTest ()
		{
			Tokenizer t = new Tokenizer ("// \n ;".ToCharArray (), new IdentifierTable ());
			Assert.AreEqual (Token.Type.Semicolon, t.GetNext ().Kind, "#5.1");
			Assert.AreEqual ("// ",t.Comments[0].Spelling, "#5.1");
		}
Ejemplo n.º 7
0
		public void WhitespaceTest ()
		{
			Tokenizer t = new Tokenizer (" ".ToCharArray (), new IdentifierTable ());
			Assert.AreEqual (Token.Type.EndOfInput, t.GetNext ().Kind, "#4.1");
		}