Author: olivier
Date: 2007-06-22 02:27:10 -0400 (Fri, 22 Jun 2007)
New Revision: 80525
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ArrayLiteralExpression.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BinaryOperatorExpression.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BlockStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/CaseClause.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ChangeLog
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DeclarationForStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DefaultCaseClause.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DoStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionForStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ForStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/FunctionDefinition.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/WithStatement.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/ChangeLog
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ChangeLog
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ParserTest.cs
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/TokenizerTest.cs
Log:
2007-06-22 Olivier Dufour <[EMAIL PROTECTED]>
* Parser.cs : fix all unit tested thing
* ParserTest.cs : Add a test and fix typo
* TokenizerTest.cs : fix typo
* ArrayLiteralExpression.cs : cosmetic
* BinaryOperatorExpression.cs : cosmetic
* BlockStatement.cs : cosmetic
* CaseClause.cs : cosmetic
* DeclarationForStatement.cs : cosmetic
* DefaultCaseClause.cs : cosmetic
* ExpressionForStatement.cs : cosmetic
* ExpressionStatement.cs : cosmetic
* ForStatement.cs : cosmetic
* FunctionDefinition.cs : cosmetic
* WithStatement.cs : cosmetic
* DoStatement.cs : miss to save param
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/ChangeLog
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/ChangeLog
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/ChangeLog
2007-06-22 06:27:10 UTC (rev 80525)
@@ -1,3 +1,7 @@
+2007-06-22 Olivier Dufour <[EMAIL PROTECTED]>
+
+ * Parser.cs : fix all unit tested thing
+
2007-06-17 Olivier Dufour <[EMAIL PROTECTED]>
* Parser.cs
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -35,11 +35,11 @@
DList<Statement, BlockStatement> result = new
DList<Statement, BlockStatement> ();
while (current.Kind != Token.Type.EndOfInput) {
- Next ();
if (current.Kind == Token.Type.function)
result.Append (ParseFunctionDeclaration
());
else
result.Append (ParseStatement ());
+ Next ();
}
Comments = lexer.Comments;
return result;
@@ -191,7 +191,7 @@
Next ();
Expression initializer =
ParseExpression ();
declaration = new
InitializerVariableDeclaration (name, initializer, new TextSpan (start2,
current), new TextPoint (start2.StartPosition));
- Next ();
+ //Next ();
}
else
declaration = new VariableDeclaration
(name, new TextSpan (current, current));
@@ -210,10 +210,13 @@
Next ();
CheckSyntaxExpected (Token.Type.LeftParenthesis);
Token leftParen = current;
+ Next ();
Expression condition = ParseExpression ();
CheckSyntaxExpected (Token.Type.RightParenthesis);
Token rightParen = current;
+ Next ();
Statement ifBody = ParseStatement ();
+ Next ();
Statement elseBody = null;
TextPoint elsePoint = new TextPoint();
if (current.Kind == [EMAIL PROTECTED]) {
@@ -229,6 +232,7 @@
Next ();
CheckSyntaxExpected (Token.Type.LeftParenthesis);
Token leftParen = current;
+ Next ();
Expression condition = ParseExpression ();
CheckSyntaxExpected (Token.Type.RightParenthesis);
Token rightParen = current;
@@ -273,7 +277,7 @@
if (current.Kind == Token.Type.var) {
VariableDeclarationStatement varDecl =
ParseVarDeclaration ();
-
+
if (current.Kind == [EMAIL PROTECTED]) {
//DeclarationForInStatement
Token inToken = current;
@@ -298,6 +302,7 @@
firstSemiColon = current;
Next ();
condition = ParseExpression ();
+
CheckSyntaxExpected
(Token.Type.Semicolon);
secondSemiColon = current;
Next ();
@@ -561,7 +566,6 @@
Next ();
expr = ParseExpression ();
CheckSyntaxExpected
(Token.Type.RightParenthesis);
- Next ();
break;
//end primary
case Token.Type.function:
@@ -570,7 +574,6 @@
case [EMAIL PROTECTED]:
Next ();
Expression target = ParseExpression ();
- Next ();
ArgumentList arguments;
if (current.Kind ==
Token.Type.LeftParenthesis) {
arguments =
this.ParseArgumentList ();
@@ -583,6 +586,7 @@
SyntaxError.Add ("expression start with
a strange token :" + Enum.GetName (typeof (Token.Type), current.Kind));
return new Expression
(Expression.Operation.SyntaxError, new TextSpan (start, current));
}
+ Next (); // to go ahead for other part
return ParseRightExpression (expr);
}
@@ -591,23 +595,28 @@
private Expression ParseRightExpression (Expression expr)
{
Token start = current;
-
+
switch (current.Kind) {
case Token.Type.LeftParenthesis:
ArgumentList argumentList =
ParseArgumentList ();
- return new InvocationExpression (expr,
argumentList, Expression.Operation.Invocation, new TextSpan (start, current));
+ expr = new InvocationExpression (expr,
argumentList, Expression.Operation.Invocation, new TextSpan (start, current));
+ Next ();
+ break;
case Token.Type.LeftBracket:
Next ();
Expression subscript = ParseExpression
();
+ CheckSyntaxExpected
(Token.Type.RightBracket);
+ expr = new SubscriptExpression (expr,
subscript, new TextSpan (start, current), new TextPoint (start.StartPosition));
Next ();
- CheckSyntaxExpected
(Token.Type.RightBracket);
- return new SubscriptExpression (expr,
subscript, new TextSpan (start, current), new TextPoint (start.StartPosition));
+ break;
case Token.Type.Dot:
Next ();
Identifier id = null;
if (CheckSyntaxExpected
(Token.Type.Identifier))
id =
((IdentifierToken)current).Spelling;
- return new QualifiedExpression (expr,
id, new TextSpan (start, current), new TextPoint (start.StartPosition), new
TextPoint (current.StartPosition));
+ expr = new QualifiedExpression (expr,
id, new TextSpan (start, current), new TextPoint (start.StartPosition), new
TextPoint (current.StartPosition));
+ Next ();
+ break;
}
return expr;
}
@@ -615,13 +624,15 @@
private Expression ParsePostfixExpression ()
{
Expression expr = ParseLeftHandSideExpression ();
- Next();
+
switch (current.Kind) {
case Token.Type.PlusPlus :
expr = new UnaryOperatorExpression
(expr, Expression.Operation.PostfixPlusPlus, new TextSpan
(expr.Location.StartLine, expr.Location.StartColumn, current.StartLine,
current.StartColumn + current.Width, expr.Location.StartPosition,
current.StartPosition+current.Width));
+ Next ();
break;
case Token.Type.MinusMinus:
expr = new UnaryOperatorExpression
(expr, Expression.Operation.PostfixMinusMinus, new TextSpan
(expr.Location.StartLine, expr.Location.StartColumn, current.StartLine,
current.StartColumn + current.Width, expr.Location.StartPosition,
current.StartPosition + current.Width));
+ Next ();
break;
}
return expr;
@@ -634,40 +645,40 @@
// get by first token
switch (current.Kind) {
case Token.Type.delete:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.delete, new TextSpan (start,
current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.delete, new TextSpan (start,
current));
break;
case [EMAIL PROTECTED]:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), [EMAIL PROTECTED], new TextSpan (start, current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), [EMAIL PROTECTED], new TextSpan (start, current));
break;
case [EMAIL PROTECTED]:
- Next ();
expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), [EMAIL PROTECTED], new TextSpan (start, current));
+ Next ();
break;
case Token.Type.PlusPlus:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixPlusPlus, new TextSpan
(start, current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixPlusPlus, new TextSpan
(start, current));
break;
case Token.Type.MinusMinus:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixMinusMinus, new
TextSpan (start, current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixMinusMinus, new
TextSpan (start, current));
break;
case Token.Type.Plus:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixPlus, new TextSpan
(start, current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixPlus, new TextSpan
(start, current));
break;
case Token.Type.Minus:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixMinus, new TextSpan
(start, current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.PrefixMinus, new TextSpan
(start, current));
break;
case Token.Type.Tilda:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.Tilda, new TextSpan (start,
current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.Tilda, new TextSpan (start,
current));
break;
case Token.Type.Bang:
+ expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.Bang, new TextSpan (start,
current));
Next ();
- expr = new UnaryOperatorExpression
(this.ParseExpression (noIn), Expression.Operation.Bang, new TextSpan (start,
current));
break;
default:
expr = ParsePostfixExpression ();
@@ -904,7 +915,6 @@
{
Token start = current;
Expression expr = ParselogicalORExpression (noIn);
- Expression.Operation op;
if (current.Kind == Token.Type.Question) {
Next ();
Expression second = ParseAssignmentExpression
(noIn);
@@ -960,7 +970,7 @@
op = Expression.Operation.BarEqual;
break;
default:
- return ParseConditionalExpression
(noIn);
+ return expr;
}
//only left hand side expression
if (expr is TernaryOperatorExpression
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ArrayLiteralExpression.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ArrayLiteralExpression.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ArrayLiteralExpression.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -14,6 +14,4 @@
this.Elements = Elements;
}
}
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BinaryOperatorExpression.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BinaryOperatorExpression.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BinaryOperatorExpression.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -18,7 +18,4 @@
this.operatorLocation = OperatorLocation;
}
}
-
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BlockStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BlockStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/BlockStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -13,6 +13,5 @@
{
this.Children = Children;
}
-
}
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/CaseClause.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/CaseClause.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/CaseClause.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -12,7 +12,6 @@
public readonly TextSpan HeaderLocation;
public CaseClause(DList<Statement, CaseClause> Children,
TextSpan Location, TextSpan HeaderLocation, TextPoint Colon)
-
{
this.colon = Colon;
this.location = Location;
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ChangeLog
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ChangeLog
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ChangeLog
2007-06-22 06:27:10 UTC (rev 80525)
@@ -1,3 +1,18 @@
+2007-06-22 Olivier Dufour <[EMAIL PROTECTED]>
+
+ * ArrayLiteralExpression.cs : cosmetic
+ * BinaryOperatorExpression.cs : cosmetic
+ * BlockStatement.cs : cosmetic
+ * CaseClause.cs : cosmetic
+ * DeclarationForStatement.cs : cosmetic
+ * DefaultCaseClause.cs : cosmetic
+ * ExpressionForStatement.cs : cosmetic
+ * ExpressionStatement.cs : cosmetic
+ * ForStatement.cs : cosmetic
+ * FunctionDefinition.cs : cosmetic
+ * WithStatement.cs : cosmetic
+ * DoStatement.cs : miss to save param
+
2007-06-19 Olivier Dufour <[EMAIL PROTECTED]>
* Expression.cs : fix typo of enum
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DeclarationForStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DeclarationForStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DeclarationForStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -14,7 +14,4 @@
this.Initial = Initial;
}
}
-
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DefaultCaseClause.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DefaultCaseClause.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DefaultCaseClause.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -11,7 +11,4 @@
{
}
}
-
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DoStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DoStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/DoStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -14,8 +14,8 @@
:base(Operation.Do, Body, Location, LeftParen,
RightParen)
{
this.While = While;
+ this.Condition = Condition;
+ this.HeaderLocation = HeaderLocation;
}
}
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionForStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionForStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionForStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -14,7 +14,4 @@
this.Initial = Initial;
}
}
-
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ExpressionStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -14,6 +14,4 @@
this.Expression = Expression;
}
}
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ForStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ForStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/ForStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -22,7 +22,4 @@
this.SecondSemicolon = SecondSemicolon;
}
}
-
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/FunctionDefinition.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/FunctionDefinition.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/FunctionDefinition.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -27,6 +27,4 @@
this.RightParenLocation = RightParenLocation;
}
}
-
-
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/WithStatement.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/WithStatement.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.ParseTree/WithStatement.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -18,6 +18,9 @@
{
this.LeftParen = LeftParen;
this.RightParen = RightParen;
+ this.Body = Body;
+ this.HeaderLocation = HeaderLocation;
+ this.Scope = Scope;
}
}
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ChangeLog
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ChangeLog
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ChangeLog
2007-06-22 06:27:10 UTC (rev 80525)
@@ -1,3 +1,8 @@
+2007-06-22 Olivier Dufour <[EMAIL PROTECTED]>
+
+ * ParserTest.cs : Add a test and fix typo
+ * TokenizerTest.cs : fix typo
+
2007-06-19 Olivier Dufour <[EMAIL PROTECTED]>
* TokenizerTest.cs
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ParserTest.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ParserTest.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/ParserTest.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -28,8 +28,6 @@
DList<Statement, BlockStatement > list =
parser.ParseProgram (ref comments);
DList<Statement, BlockStatement>.Iterator it = new
DList<Statement,BlockStatement>.Iterator(list);
Assert.IsInstanceOfType
(typeof(VariableDeclarationStatement), it.Element, "#1.1");
- //VariableDeclarationStatement var =
((VariableDeclarationStatement)it.Element);
- //TODO check value 10
Assert.IsTrue (parser.SyntaxOK ());
}
@@ -93,9 +91,18 @@
Assert.IsInstanceOfType (typeof (DoStatement),
it.Element, "#6.1");
DoStatement dost = ((DoStatement)it.Element);
Assert.AreEqual ([EMAIL PROTECTED],
dost.Condition.Opcode, "#6.2");
- Assert.IsTrue (parser.SyntaxOK ());
+ Assert.IsTrue (parser.SyntaxOK (), PrintSyntax ("#6",
parser));
}
+ private string PrintSyntax (string id, Parser parser)
+ {
+ string result = string.Empty;
+ foreach (Diagnostic d in parser.Diagnostics) {
+ result += (id + Enum.GetName (typeof
(DiagnosticCode), d.Code));
+ }
+ return result;
+ }
+
[Test]
public void ForTest ()
{
@@ -105,10 +112,24 @@
DList<Statement, BlockStatement>.Iterator it = new
DList<Statement, BlockStatement>.Iterator (list);
Assert.IsInstanceOfType (typeof
(DeclarationForStatement), it.Element, "#7.1");
DeclarationForStatement forst =
((DeclarationForStatement)it.Element);
- //Assert.AreEqual ([EMAIL PROTECTED],
forst.Initial.i.Condition.Opcode, "#7.2");
- //TODO
Assert.IsTrue (parser.SyntaxOK ());
}
+ [Test]
+ public void AddTest ()
+ {
+ Parser parser = new Parser ("var i = 5 +
1;".ToCharArray ());
+ List<Comment> comments = new List<Comment> ();
+ DList<Statement, BlockStatement> list =
parser.ParseProgram (ref comments);
+ DList<Statement, BlockStatement>.Iterator it = new
DList<Statement, BlockStatement>.Iterator (list);
+ Assert.IsInstanceOfType (typeof
(VariableDeclarationStatement), it.Element, "#8.1");
+ VariableDeclarationStatement varst =
((VariableDeclarationStatement)it.Element);
+ Assert.AreEqual ("i",
varst.Declarations[0].Declaration.Name.Spelling, "#8.2");
+ Assert.IsInstanceOfType (typeof
(InitializerVariableDeclaration), varst.Declarations[0].Declaration, "#8.3");
+ InitializerVariableDeclaration ini =
(InitializerVariableDeclaration)varst.Declarations[0].Declaration;
+ Assert.IsInstanceOfType (typeof
(BinaryOperatorExpression), ini.Initializer, "#8.4");
+ Assert.AreEqual (Expression.Operation.Plus,
ini.Initializer.Opcode, "#8.5");
+ Assert.IsTrue (parser.SyntaxOK ());
+ }
}
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/TokenizerTest.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/TokenizerTest.cs
2007-06-22 05:00:19 UTC (rev 80524)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Test/Microsoft.JScript.Compiler/TokenizerTest.cs
2007-06-22 06:27:10 UTC (rev 80525)
@@ -11,60 +11,62 @@
public void AffectTest()
{
Tokenizer l1 = new Tokenizer ("var i =
10;".ToCharArray(), new IdentifierTable ());
- Assert.AreEqual(Token.Type.var, l1.GetNext().Kind);
- Assert.AreEqual (Token.Type.Identifier,
l1.GetNext().Kind);
+ 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);
- Assert.AreEqual (Token.Type.NumericLiteral,
l1.GetNext().Kind);
+ 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);
+ Assert.AreEqual (Token.Type.Semicolon, l1.GetNext
().Kind, "#1.5");
//Assert.IsFalse(l1.Advance());
- Assert.AreEqual (Token.Type.EndOfInput,
l1.GetNext().Kind);
+ Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext
().Kind, "#1.6");
}
[Test]
public void PlusTest()
{
Tokenizer l1 = new Tokenizer
("$test_var++;".ToCharArray (), new IdentifierTable ());
- Assert.AreEqual (Token.Type.Identifier,
l1.GetNext().Kind);
+ Assert.AreEqual (Token.Type.Identifier, l1.GetNext
().Kind, "#2.1");
//Assert.AreEqual("$test_var", l1.Value());
- Assert.AreEqual (Token.Type.PlusPlus,
l1.GetNext().Kind);
- Assert.AreEqual (Token.Type.Semicolon,
l1.GetNext().Kind);
+ Assert.AreEqual (Token.Type.PlusPlus, l1.GetNext
().Kind, "#2.2");
+ Assert.AreEqual (Token.Type.Semicolon, l1.GetNext
().Kind, "#2.3");
//Assert.IsFalse(l1.Advance());
- Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext
().Kind);
+ Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext
().Kind, "#2.4");
}
[Test]
public void MinusTest()
{
Tokenizer l1 = new Tokenizer
("$test_var--;".ToCharArray (), new IdentifierTable ());
- Assert.AreEqual (Token.Type.Identifier,
l1.GetNext().Kind);
+ Assert.AreEqual (Token.Type.Identifier, l1.GetNext
().Kind, "#3.1");
//Assert.AreEqual("$test_var", l1.Value());
- Assert.AreEqual (Token.Type.MinusMinus,
l1.GetNext().Kind);
- Assert.AreEqual (Token.Type.Semicolon, l1.GetNext
().Kind);
+ 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);
+ Assert.AreEqual (Token.Type.EndOfInput, l1.GetNext
().Kind, "#3.4");
}
[Test]
public void WhitespaceTest ()
{
Tokenizer t = new Tokenizer (" ".ToCharArray (), new
IdentifierTable ());
- Assert.AreEqual (Token.Type.EndOfInput, t.GetNext
().Kind);
+ Assert.AreEqual (Token.Type.EndOfInput, t.GetNext
().Kind, "#4.1");
}
[Test]
public void LineCommentTest ()
{
Tokenizer t = new Tokenizer ("// \n ;".ToCharArray (),
new IdentifierTable ());
- Assert.AreEqual (Token.Type.Semicolon, t.GetNext
().Kind);
+ Assert.AreEqual (Token.Type.Semicolon, t.GetNext
().Kind, "#5.1");
+ Assert.AreEqual (" ",t.Comments[0].Spelling, "#5.1");
}
[Test]
public void BlockCommentTest ()
{
Tokenizer t = new Tokenizer ("/*abcdef*/ ;".ToCharArray
(), new IdentifierTable ());
- Assert.AreEqual (Token.Type.Semicolon, t.GetNext
().Kind);
+ Assert.AreEqual (Token.Type.Semicolon, t.GetNext
().Kind, "#6.1");
+ Assert.AreEqual ("abcdef", t.Comments[0].Spelling,
"#6.2");
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches