Author: olivier
Date: 2007-06-04 17:07:43 -0400 (Mon, 04 Jun 2007)
New Revision: 78597
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.suo
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
trunk/olive/class/Microsoft.JScript.Compiler/TODO.txt
Log:
2007-06-04 Olivier Dufour <[EMAIL PROTECTED]>
* Finished all parsing of statement
* Remove ref to own MS.Scripting
Note : Dlist seems core list to build the tree. So it must use the splaytree to
have better search because according wikipedia splay tree is good to make a
search.
Modified: trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog 2007-06-04
21:00:37 UTC (rev 78596)
+++ trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog 2007-06-04
21:07:43 UTC (rev 78597)
@@ -1,5 +1,12 @@
2007-06-04 Olivier Dufour <[EMAIL PROTECTED]>
+ * Finished all parsing of statement
+ * Remove ref to own MS.Scripting
+
+Note : Dlist seems core list to build the tree. So it must use the splaytree
to have better search because according wikipedia splay tree is good to make a
search.
+
+2007-06-04 Olivier Dufour <[EMAIL PROTECTED]>
+
* Add switch to parser
* fix bug for null ref and not initialize ref for test
* Add small test for Parser
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-04 21:00:37 UTC (rev 78596)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/Parser.cs
2007-06-04 21:07:43 UTC (rev 78597)
@@ -70,6 +70,10 @@
#endregion
+ #region private methods
+
+ #region statements
+
private FunctionStatement ParseFunctionDeclaration ()
{
Token start = current;
@@ -94,7 +98,7 @@
TextSpan location = new TextSpan (start,current);
TextSpan HeaderLocation = new TextSpan
(start,headerEnd);
- FunctionDefinition func = new
FunctionDefinition(id,parametters,body,location,HeaderLocation,NameLocation,leftParenLocation,rightParenLocation);
+ FunctionDefinition func = new FunctionDefinition(id,
parametters, body, location, HeaderLocation, NameLocation, leftParenLocation,
rightParenLocation);
return new FunctionStatement (func);
}
@@ -169,8 +173,9 @@
case Token.Type.Try:
return ParseTry ();
case Token.Type.Throw:
+ return ParseThrow ();
case Token.Type.Return:
- return ParseReturnOrThrow ();
+ return ParseReturn ();
case Token.Type.Function:
return ParseFunctionDeclaration ();
case Token.Type.Identifier:
@@ -449,31 +454,78 @@
return result;
}
- private ReturnOrThrowStatement ParseReturnOrThrow ()
+ private ReturnOrThrowStatement ParseReturn ()
{
- throw new Exception ("The method or operation is not
implemented.");
+ Token start = current;
+ Next ();
+ Expression expr = null;
+ if (current.Kind != Token.Type.SemiColon)
+ expr = ParseExpression();
+
+ return new ReturnOrThrowStatement
(Statement.Operation.Return, expr, new TextSpan (start, current));
+
}
+ private ReturnOrThrowStatement ParseThrow ()
+ {
+ Token start = current;
+ Next ();
+ Expression expr = ParseExpression ();
+ return new ReturnOrThrowStatement
(Statement.Operation.Throw, expr, new TextSpan (start, current));
+ }
+
private TryStatement ParseTry ()
{
- throw new Exception ("The method or operation is not
implemented.");
+ Token start = current;
+ Next ();
+ BlockStatement block = ParseBlock ();
+ Next();
+ bool flag = false;
+ CatchClause catchClause = null;
+ FinallyClause finallyClause = null;
+
+ if (current.Kind == Token.Type.Catch) {
+ Token start2 = current;
+ flag = true;
+ Next ();
+ CheckSyntaxExpected
(Token.Type.LeftParenthesis);
+ Token left = current;
+ Next ();
+ CheckSyntaxExpected (Token.Type.Identifier);
+ Token id = current;
+ Identifier name = (current as
IdentifierToken).Spelling;
+ Next();
+ CheckSyntaxExpected
(Token.Type.RightParenthesis);
+ Token right = current;
+ Next();
+ BlockStatement handler = ParseBlock();
+ catchClause = new CatchClause(name, handler,new
TextSpan(start2,current), new TextSpan(id, id), new
TextPoint(left.StartPosition),new TextPoint(right.StartPosition));
+ }
+
+ if (current.Kind == Token.Type.Finally) {
+ Token start3 = current;
+ flag = true;
+ Next ();
+ BlockStatement handler2 = ParseBlock();
+ finallyClause = new FinallyClause(handler2,new
TextSpan(start3,current));
+ }
+
+ if (flag) {
+ diagnostics.Add(new
Diagnostic(DiagnosticCode.TryHasNoHandlers,new TextSpan(start,current)));
+ }
+ return new TryStatement (block, catchClause,
finallyClause, new TextSpan (start, current));
}
/*
ArgumentList.cs
ArrayLiteralExpression.cs
BinaryOperatorExpression.cs
- CaseClause.cs
- CatchClause.cs
- DefaultCaseClause.cs
ExpressionListElement.cs
- FinallyClause.cs
ForInStatement.cs
FunctionDefinition.cs
HexLiteralExpression.cs
IdentifierExpression.cs
InvocationExpression.cs
LabelStatement.cs
- LoopStatement.cs
NullExpression.cs
NumericLiteralExpression.cs
ObjectLiteralElement.cs
@@ -486,10 +538,14 @@
SubscriptExpression.cs
TernaryOperatorExpression.cs
UnaryOperatorExpression.cs
- ValueCaseClause.cs
VariableDeclaration.cs
VariableDeclarationListElement.cs
*/
+
+ #endregion
+
+ #region expressions
+
private Expression ParseExpression ()
{
Token start = current; //ident
@@ -617,6 +673,10 @@
throw new Exception ("The method or operation is not
implemented.");
}
+ #endregion
+
+ #region helpers
+
private void Next ()
{
current = lexer.GetNext ();
@@ -649,13 +709,17 @@
return;
}
diagnostics.Add(new Diagnostic(code, new
TextSpan(current.StartLine,current.StartColumn, lexer.Position.Line,
lexer.Position.Column,current.StartPosition, lexer.Position.Index)));
- }
+ }
+ #endregion
+
+ #endregion
+
private List<Diagnostic> diagnostics;
public List<Diagnostic> Diagnostics { get { return
diagnostics; } }
+
/* TODO
- TryHasNoHandlers,
BadDivideOrRegularExpressionLiteral,
EnclosingLabelShadowed,
NoEnclosingLabel,
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
2007-06-04 21:00:37 UTC (rev 78596)
+++ trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
2007-06-04 21:07:43 UTC (rev 78597)
@@ -5,8 +5,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Microsoft.JScript.Compiler", "Microsoft.JScript.Compiler.csproj",
"{03952B85-C1DB-4253-B822-AF37BD6B1C66}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Scripting",
"..\Microsoft.Scripting\Microsoft.Scripting.csproj",
"{162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,10 +19,6 @@
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Debug|Any CPU.Build.0 =
Debug|Any CPU
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Release|Any
CPU.ActiveCfg = Release|Any CPU
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Release|Any CPU.Build.0
= Release|Any CPU
- {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
- {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Debug|Any CPU.Build.0 =
Debug|Any CPU
- {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Release|Any
CPU.ActiveCfg = Release|Any CPU
- {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Release|Any CPU.Build.0
= Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.suo
===================================================================
(Binary files differ)
Modified: trunk/olive/class/Microsoft.JScript.Compiler/TODO.txt
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/TODO.txt 2007-06-04
21:00:37 UTC (rev 78596)
+++ trunk/olive/class/Microsoft.JScript.Compiler/TODO.txt 2007-06-04
21:07:43 UTC (rev 78597)
@@ -1,5 +0,0 @@
-
-
-- do the parser and all extra stuff
-- do the Mono.scripting lib
-- move sourcelocation to it
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches