Author: olivier
Date: 2007-05-27 14:17:24 -0400 (Sun, 27 May 2007)
New Revision: 78016
Modified:
trunk/olive/class/Makefile
trunk/olive/class/Mono.JScript.Compiler/ChangeLog
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler.suo
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Identifier.cs
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/IdentifierTable.cs
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Tokenizer.cs
Log:
2007-05-27 Olivier Dufour <[EMAIL PROTECTED]>
* Fill IdentifierTable, Identifier
* Manage comments in tokenizer
* Add to global makefile
Rem: if someone can check my makefile because i work on windows without
Makefile I have copy and change some things...
Modified: trunk/olive/class/Makefile
===================================================================
--- trunk/olive/class/Makefile 2007-05-27 16:27:28 UTC (rev 78015)
+++ trunk/olive/class/Makefile 2007-05-27 18:17:24 UTC (rev 78016)
@@ -12,6 +12,7 @@
System.Workflow.ComponentModel \
System.Workflow.Activities \
WindowsBase \
+ Mono.JScript.Compiler \
PresentationFramework \
System.Runtime.Serialization \
System.IdentityModel \
Modified: trunk/olive/class/Mono.JScript.Compiler/ChangeLog
===================================================================
--- trunk/olive/class/Mono.JScript.Compiler/ChangeLog 2007-05-27 16:27:28 UTC
(rev 78015)
+++ trunk/olive/class/Mono.JScript.Compiler/ChangeLog 2007-05-27 18:17:24 UTC
(rev 78016)
@@ -1,5 +1,10 @@
2007-05-27 Olivier Dufour <[EMAIL PROTECTED]>
+ * Fill IdentifierTable
+ * manage comments in tokenizer
+
+2007-05-27 Olivier Dufour <[EMAIL PROTECTED]>
+
* Go ahead in parser
2007-05-27 Olivier Dufour <[EMAIL PROTECTED]>
Modified:
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Identifier.cs
===================================================================
--- trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Identifier.cs
2007-05-27 16:27:28 UTC (rev 78015)
+++ trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Identifier.cs
2007-05-27 18:17:24 UTC (rev 78016)
@@ -4,7 +4,32 @@
namespace Mono.JScript.Compiler
{
- public class Identifier
+ public class Identifier : IComparable<Identifier>
{
+ public readonly Token.Type KeywordValue;
+ public readonly string Spelling;
+ private int identifierID;
+
+ public Identifier (string Spelling, IdentifierTable IDTable)
+ : this(Spelling,Token.Type.Identifier,IDTable)
+ {
+ }
+
+ public Identifier (string Spelling, Token.Type KeywordValue,
IdentifierTable IDTable)
+ {
+ this.Spelling = Spelling;
+ this.KeywordValue = KeywordValue;
+ identifierID = IDTable.NextIdentifierID;
+ }
+
+ public int CompareTo (Identifier Other)
+ {
+ if (identifierID > Other.identifierID)
+ return 1;
+ else if (identifierID < Other.identifierID)
+ return -1;
+ else
+ return 0;
+ }
}
}
Modified:
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/IdentifierTable.cs
===================================================================
---
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/IdentifierTable.cs
2007-05-27 16:27:28 UTC (rev 78015)
+++
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/IdentifierTable.cs
2007-05-27 18:17:24 UTC (rev 78016)
@@ -6,24 +6,31 @@
{
public class IdentifierTable
{
+
+ private Dictionary<string, Identifier> identifiers;
public IdentifierTable ()
{
- throw new NotImplementedException ();
+ identifiers = new Dictionary<string, Identifier> ();
}
public Identifier InsertIdentifier (string Spelling)
{
- throw new NotImplementedException ();
+ Identifier result = identifiers[Spelling];
+ if (result == null) {
+ result = new Identifier (Spelling, this);
+ identifiers.Add (Spelling, result);
+ }
+ return result;
}
public Identifier InsertIdentifier (char[] Text, int
StartIndex, int Count)
{
- throw new NotImplementedException ();
+ return InsertIdentifier (Text.ToString ());
+ //TODO : must have to do something to do with count and
StartIndex
}
-
-
+
public int NextIdentifierID {
- get { throw new NotImplementedException (); }
+ get { return identifiers.Count; }
}
}
Modified:
trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Tokenizer.cs
===================================================================
--- trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Tokenizer.cs
2007-05-27 16:27:28 UTC (rev 78015)
+++ trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler/Tokenizer.cs
2007-05-27 18:17:24 UTC (rev 78016)
@@ -525,6 +525,9 @@
keywords.Add("null", Token.Type.Null);
keywords.Add("true", Token.Type.True);
keywords.Add("false", Token.Type.False);
+
+ foreach (string key in keywords.Keys)
+ IDTable.InsertIdentifier (key);
}
private void StripWhiteSpace()
@@ -554,12 +557,34 @@
private void CreateBlockComment()
{
- throw new Exception("The method or operation is not
implemented.");
+ int startPosition = position;
+ int startline = row;
+ int startcolumn = position - lineStartPosition;
+ char next = source[position];
+ StringBuilder builder = new StringBuilder ();
+ while ((next != '*') && (position + 1 < source.Length)
&& (source[position + 1] != '/')) {
+ builder.Append (next);
+ if (next == '\n') {
+ row++;
+ lineStartPosition = position;
+ }
+ position++;
+ next = source[position];
+ }
+ comments.Add (new Comment (builder.ToString (), new
TextSpan (startline, startcolumn, row, position - lineStartPosition,
startPosition, position)));
}
private void CreateLineComment()
{
- throw new Exception("The method or operation is not
implemented.");
+ int startPosition = position;
+ char next = source[position];
+ StringBuilder builder = new StringBuilder();
+ while (next != '\n' && position < source.Length) {
+ builder.Append (next);
+ position++;
+ next = source[position];
+ }
+ comments.Add(new Comment(builder.ToString(),new
TextSpan(row, startPosition - lineStartPosition, row, position -
lineStartPosition, startPosition,position)));
}
}
}
Modified: trunk/olive/class/Mono.JScript.Compiler/Mono.JScript.Compiler.suo
===================================================================
(Binary files differ)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches