General updating.

Updated solution to VS 2017. Updated to newest version of coco/r.  Now  includes coco/r for easier building out of the box.
This commit is contained in:
Jordan Wages 2018-06-12 20:47:06 -05:00
parent 315ccb94eb
commit e4d6717ec2
46 changed files with 4606 additions and 127 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -84,9 +84,6 @@
<Name>csmic</Name> <Name>csmic</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Shadow Include="Test References\csmic.accessor" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0"> <BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible> <Visible>False</Visible>
@ -109,6 +106,7 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,2 +0,0 @@
csmic.dll
Desktop

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
36df016871eaf0623988524de0fae43fd7690943

View File

@ -0,0 +1,11 @@
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\obj\Debug\CSMICTests.csprojAssemblyReference.cache
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\CSMICTests.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\CSMICTests.pdb
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\csmic.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\csmic.pdb
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\bin\Debug\csmic.xml
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\obj\Debug\CSMICTests.csproj.CoreCompileInputs.cache
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\obj\Debug\CSMICTests.csproj.CopyComplete
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\obj\Debug\CSMICTests.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\CSMICTests\obj\Debug\CSMICTests.pdb

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
CS-MIC/csmic/UpgradeLog.htm Normal file

Binary file not shown.

View File

@ -1,31 +1,13 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csmic", "csmic\csmic.csproj", "{7BBA4BA2-E885-4D89-8710-F1A609616B7D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csmic", "csmic\csmic.csproj", "{7BBA4BA2-E885-4D89-8710-F1A609616B7D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSMICTests", "CSMICTests\CSMICTests.csproj", "{C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSMICTests", "CSMICTests\CSMICTests.csproj", "{C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}"
EndProject EndProject
Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "HelpFile", "HelpFile\HelpFile.shfbproj", "{B60970B9-771A-4EBB-9978-89F55163888F}"
EndProject
Global Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 4
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs35
SccLocalPath0 = .
SccProjectUniqueName1 = csmic\\csmic.csproj
SccProjectName1 = csmic
SccLocalPath1 = csmic
SccProjectUniqueName2 = CSMICTests\\CSMICTests.csproj
SccProjectName2 = CSMICTests
SccLocalPath2 = CSMICTests
SccProjectUniqueName3 = HelpFile\\HelpFile.shfbproj
SccProjectName3 = HelpFile
SccLocalPath3 = HelpFile
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = csmic8.vsmdi
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
@ -39,14 +21,16 @@ Global
{C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Debug|Any CPU.Build.0 = Debug|Any CPU {C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Release|Any CPU.ActiveCfg = Release|Any CPU {C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Release|Any CPU.Build.0 = Release|Any CPU {C03AD9DF-630F-4C88-A9D4-8B4B450CCB54}.Release|Any CPU.Build.0 = Release|Any CPU
{B60970B9-771A-4EBB-9978-89F55163888F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B60970B9-771A-4EBB-9978-89F55163888F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B60970B9-771A-4EBB-9978-89F55163888F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B60970B9-771A-4EBB-9978-89F55163888F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {27D51C21-4BAE-4773-83C2-C565983E8D2D}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = csmic8.vsmdi
EndGlobalSection
GlobalSection(SubversionScc) = preSolution GlobalSection(SubversionScc) = preSolution
Svn-Managed = True Svn-Managed = True
Manager = AnkhSVN - Subversion Support for Visual Studio Manager = AnkhSVN - Subversion Support for Visual Studio

View File

@ -252,7 +252,7 @@ namespace csmic
this.calculatedValue = p.CalculatedValue; this.calculatedValue = p.CalculatedValue;
if (p.errors.count > 0) if (p.errors.count > 0)
{ {
ProduceOutput(this.calculatedValue, p.errors.builder.ToString()); ProduceOutput(this.calculatedValue, p.errors.errMsgFormat);
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -5,13 +5,11 @@ using System.Collections.Generic;
using System; using System;
using System.CodeDom.Compiler;
namespace csmic.Interpreter { namespace csmic.Interpreter {
[GeneratedCodeAttribute("Coco/R", "")]
public class Parser { public class Parser {
public const int _EOF = 0; public const int _EOF = 0;
public const int _identifier = 1; public const int _identifier = 1;
@ -25,8 +23,8 @@ public class Parser {
public const int _COMPARER = 9; public const int _COMPARER = 9;
public const int maxT = 22; public const int maxT = 22;
const bool T = true; const bool _T = true;
const bool x = false; const bool _x = false;
const int minErrDist = 2; const int minErrDist = 2;
public Scanner scanner; public Scanner scanner;
@ -454,13 +452,12 @@ bool IsArrayCall()
CSMIC(); CSMIC();
Expect(0); Expect(0);
Expect(0);
} }
static readonly bool[,] set = { static readonly bool[,] set = {
{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, {_T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,x,T, T,T,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x}, {_x,_T,_x,_T, _T,_T,_x,_T, _x,_x,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x} {_x,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_x}
}; };
} // end Parser } // end Parser
@ -468,10 +465,10 @@ bool IsArrayCall()
public class Errors { public class Errors {
public int count = 0; // number of errors detected public int count = 0; // number of errors detected
public StringBuilder builder = new StringBuilder(); // error messages go to this stream public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- position {0}: {1}"; // 0=line, 1=column, 2=text public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public void SynErr (int line, int col, int n) { public virtual void SynErr (int line, int col, int n) {
string s; string s;
switch (n) { switch (n) {
case 0: s = "EOF expected"; break; case 0: s = "EOF expected"; break;
@ -503,26 +500,26 @@ public class Errors {
default: s = "error " + n; break; default: s = "error " + n; break;
} }
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (int line, int col, string s) { public virtual void SemErr (int line, int col, string s) {
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (string s) { public virtual void SemErr (string s) {
builder.AppendLine(s); errorStream.WriteLine(s);
count++; count++;
} }
public void Warning (int line, int col, string s) { public virtual void Warning (int line, int col, string s) {
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
} }
public void Warning(string s) { public virtual void Warning(string s) {
builder.AppendLine(s); errorStream.WriteLine(s);
} }
} // Errors } // Errors
@ -530,5 +527,4 @@ public class Errors {
public class FatalError: Exception { public class FatalError: Exception {
public FatalError(string m): base(m) {} public FatalError(string m): base(m) {}
} }
} }

View File

@ -0,0 +1,530 @@
using csmic;
using System.Text;
using System.Collections.Generic;
using System;
namespace csmic.Interpreter {
public class Parser {
public const int _EOF = 0;
public const int _identifier = 1;
public const int _sign = 2;
public const int _binary = 3;
public const int _hex = 4;
public const int _number = 5;
public const int _string = 6;
public const int _LPAREN = 7;
public const int _RPAREN = 8;
public const int _COMPARER = 9;
public const int maxT = 22;
const bool _T = true;
const bool _x = false;
const int minErrDist = 2;
public Scanner scanner;
public Errors errors;
public Token t; // last recognized token
public Token la; // lookahead token
int errDist = minErrDist;
private decimal calcValue = 0;
private string stringValue = string.Empty;
public decimal CalculatedValue
{
get
{
return this.calcValue;
}
set
{
this.calcValue = value;
}
}
private InputInterpreter interpreter = null;
public InputInterpreter Interpreter
{
get
{
return this.interpreter;
}
set
{
this.interpreter = value;
}
}
bool IsFunctionCall()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.kind == _LPAREN && la.kind == _identifier)
return true;
return false;
}
bool IsCompare()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.kind == _COMPARER)
return true;
return false;
}
bool IsAssignment()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.val == "::" || next.val == ":=" || next.val == "->")
return true;
return false;
}
bool IsArrayCall()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if(next.val == "[")
return true;
return false;
}
public Parser(Scanner scanner) {
this.scanner = scanner;
errors = new Errors();
}
void SynErr (int n) {
if (errDist >= minErrDist) errors.SynErr(la.line, la.col, n);
errDist = 0;
}
public void SemErr (string msg) {
if (errDist >= minErrDist) errors.SemErr(t.line, t.col, msg);
errDist = 0;
}
void Get () {
for (;;) {
t = la;
la = scanner.Scan();
if (la.kind <= maxT) { ++errDist; break; }
la = t;
}
}
void Expect (int n) {
if (la.kind==n) Get(); else { SynErr(n); }
}
bool StartOf (int s) {
return set[s, la.kind];
}
void ExpectWeak (int n, int follow) {
if (la.kind == n) Get();
else {
SynErr(n);
while (!StartOf(follow)) Get();
}
}
bool WeakSeparator(int n, int syFol, int repFol) {
int kind = la.kind;
if (kind == n) {Get(); return true;}
else if (StartOf(repFol)) {return false;}
else {
SynErr(n);
while (!(set[syFol, kind] || set[repFol, kind] || set[0, kind])) {
Get();
kind = la.kind;
}
return StartOf(syFol);
}
}
void CSMIC() {
decimal r = 0;
string s = string.Empty;
decimal[] a = new decimal[0];
bool success = true;
if(this.interpreter == null)
{
return;
}
if (IsCompare()) {
Comparison(out success);
this.calcValue = (success == true) ? 1 : 0; this.interpreter.ProduceOutput(success);
} else if (IsAssignment()) {
Assignment(out r);
this.calcValue = r;
} else if (StartOf(1)) {
Expression(out r);
this.calcValue = r; this.interpreter.ProduceOutput(r);
} else if (la.kind == 6) {
String(out s);
this.stringValue = s; this.interpreter.ProduceOutput(s);
} else SynErr(23);
}
void Comparison(out bool result) {
decimal firstValue = 0;
decimal secondValue = 0;
string compareType = string.Empty;
Expression(out firstValue);
Expect(9);
compareType = t.val;
Expression(out secondValue);
switch(compareType)
{
case "==":
result = (firstValue == secondValue);
break;
case ">":
result = (firstValue > secondValue);
break;
case "<":
result = (firstValue < secondValue);
break;
case ">=":
result = (firstValue >= secondValue);
break;
case "<=":
result = (firstValue <= secondValue);
break;
default:
result = false;
break;
}
}
void Assignment(out decimal r) {
string identifier = string.Empty;
string expression = string.Empty;
decimal[] d = new decimal[0];
r = 0;
Expect(1);
identifier = t.val;
if (la.kind == 19) {
Get();
Expression(out r);
this.interpreter.Assign(identifier, r);
this.interpreter.ProduceOutput(r);
} else if (la.kind == 20) {
Get();
AnyExpression(out expression);
this.interpreter.Assign(identifier, expression);
this.interpreter.ProduceOutput(expression);
} else if (la.kind == 21) {
Get();
ArrayL(out d);
this.interpreter.Assign(identifier, d); r = 0;
StringBuilder builder = new StringBuilder();
foreach(decimal dec in d)
{
builder.Append("," + dec.ToString());
}
builder.Remove(0,1);
this.interpreter.ProduceOutput(builder.ToString());
} else SynErr(24);
}
void Expression(out decimal r) {
decimal r1;
Term(out r);
while (la.kind == 10 || la.kind == 11) {
if (la.kind == 10) {
Get();
Term(out r1);
r += r1;
} else {
Get();
Term(out r1);
r -= r1;
}
}
}
void String(out string s) {
Expect(6);
s = t.val;
}
void Term(out decimal r) {
decimal r1;
Factor(out r);
while (la.kind == 12 || la.kind == 13 || la.kind == 14) {
if (la.kind == 12) {
Get();
Factor(out r1);
r *= r1;
} else if (la.kind == 13) {
Get();
Factor(out r1);
r /= r1;
} else {
Get();
Term(out r1);
r %= r1;
}
}
}
void Factor(out decimal r) {
decimal r1;
Value(out r);
while (la.kind == 15) {
Get();
Expression(out r1);
r = Convert.ToDecimal(Math.Pow(Convert.ToDouble(r), Convert.ToDouble(r1)));
}
}
void Value(out decimal r) {
r = 0;
decimal r1 = 0;
string fn;
int sign = 1;
if (la.kind == 10 || la.kind == 11) {
if (la.kind == 10) {
Get();
} else {
Get();
sign = -1;
}
}
if (IsFunctionCall()) {
Function(out r);
r = sign * r;
} else if (IsArrayCall()) {
ArrayCall(out r);
r = sign * r;
} else if (la.kind == 1) {
Get();
if(this.interpreter.variables.ContainsKey(t.val))
{
Variable v = this.interpreter.variables[t.val];
if(v.Type == VariableType.Equation)
{
InputInterpreter i = new InputInterpreter(this.interpreter);
i.Interpret(v.Value.ToString());
r = i.Decimal;
}
else if(v.Type == VariableType.Decimal)
{
r = Convert.ToDecimal(v.Value);
}
else
{
r = 0;
}
}
} else if (la.kind == 5) {
Get();
r = sign * Convert.ToDecimal (t.val);
} else if (la.kind == 4) {
Get();
string expression = t.val.Remove(0,2);
try
{
decimal value = Convert.ToDecimal(Convert.ToInt64(expression, 16));
r = sign * value;
}
catch
{
r = 0;
}
} else if (la.kind == 3) {
Get();
string expression = t.val.Remove(t.val.Length - 1);
try
{
decimal value = Convert.ToDecimal(Convert.ToInt64(expression, 2));
r = sign * value;
}
catch
{
r = 0;
}
} else if (la.kind == 7) {
Get();
Expression(out r);
Expect(8);
r = sign * r;
} else SynErr(25);
}
void Function(out decimal r) {
string functionName = string.Empty;
decimal[] d = new decimal[0];
Expect(1);
functionName = t.val;
Expect(7);
CommaList(out d);
Expect(8);
r = this.interpreter.ExecuteFunction(functionName, d);
}
void ArrayCall(out decimal r) {
string ident = string.Empty; r = 0; decimal pos = 0;
Expect(1);
ident = t.val;
Expect(16);
Expression(out pos);
int i = 0;
try
{
i = Convert.ToInt32(pos);
if(this.interpreter.variables.ContainsKey(ident))
{
decimal[] values = this.interpreter.variables[ident].Value as decimal[];
if(values != null)
{
r = values[i];
}
}
}
catch
{
}
Expect(17);
}
void ArrayL(out decimal[] d) {
Expect(16);
CommaList(out d);
Expect(17);
}
void CommaList(out decimal[] d) {
List<decimal> list = new List<decimal>(); decimal r = 0;
Expression(out r);
list.Add(r); d = list.ToArray();
while (la.kind == 18) {
Get();
Expression(out r);
list.Add(r); d = list.ToArray();
}
}
void AnyExpression(out string value) {
value = string.Empty; StringBuilder builder = new StringBuilder();
Get();
builder.Append(t.val);
while (StartOf(2)) {
Get();
builder.Append(t.val);
}
value = builder.ToString();
}
public void Parse() {
la = new Token();
la.val = "";
Get();
CSMIC();
Expect(0);
}
static readonly bool[,] set = {
{_T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_x,_T, _T,_T,_x,_T, _x,_x,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_x}
};
} // end Parser
public class Errors {
public int count = 0; // number of errors detected
public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public virtual void SynErr (int line, int col, int n) {
string s;
switch (n) {
case 0: s = "EOF expected"; break;
case 1: s = "identifier expected"; break;
case 2: s = "sign expected"; break;
case 3: s = "binary expected"; break;
case 4: s = "hex expected"; break;
case 5: s = "number expected"; break;
case 6: s = "string expected"; break;
case 7: s = "LPAREN expected"; break;
case 8: s = "RPAREN expected"; break;
case 9: s = "COMPARER expected"; break;
case 10: s = "\"+\" expected"; break;
case 11: s = "\"-\" expected"; break;
case 12: s = "\"*\" expected"; break;
case 13: s = "\"/\" expected"; break;
case 14: s = "\"%\" expected"; break;
case 15: s = "\"^\" expected"; break;
case 16: s = "\"[\" expected"; break;
case 17: s = "\"]\" expected"; break;
case 18: s = "\",\" expected"; break;
case 19: s = "\"::\" expected"; break;
case 20: s = "\":=\" expected"; break;
case 21: s = "\"->\" expected"; break;
case 22: s = "??? expected"; break;
case 23: s = "invalid CSMIC"; break;
case 24: s = "invalid Assignment"; break;
case 25: s = "invalid Value"; break;
default: s = "error " + n; break;
}
errorStream.WriteLine(errMsgFormat, line, col, s);
count++;
}
public virtual void SemErr (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s);
count++;
}
public virtual void SemErr (string s) {
errorStream.WriteLine(s);
count++;
}
public virtual void Warning (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s);
}
public virtual void Warning(string s) {
errorStream.WriteLine(s);
}
} // Errors
public class FatalError: Exception {
public FatalError(string m): base(m) {}
}
}

View File

@ -26,15 +26,13 @@ Coco/R itself) does not fall under the GNU General Public License.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
-->begin -->begin
using System; using System;
using System.CodeDom.Compiler;
-->namespace -->namespace
[GeneratedCodeAttribute("Coco/R", "")]
public class Parser { public class Parser {
-->constants -->constants
const bool T = true; const bool _T = true;
const bool x = false; const bool _x = false;
const int minErrDist = 2; const int minErrDist = 2;
public Scanner scanner; public Scanner scanner;
@ -110,7 +108,6 @@ public class Parser {
la.val = ""; la.val = "";
Get(); Get();
-->parseRoot -->parseRoot
Expect(0);
} }
static readonly bool[,] set = { static readonly bool[,] set = {
@ -121,35 +118,35 @@ public class Parser {
public class Errors { public class Errors {
public int count = 0; // number of errors detected public int count = 0; // number of errors detected
public StringBuilder builder = new StringBuilder(); // error messages go to this stream public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- position {0}: {1}"; // 0=line, 1=column, 2=text public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public void SynErr (int line, int col, int n) { public virtual void SynErr (int line, int col, int n) {
string s; string s;
switch (n) { switch (n) {
-->errors -->errors
default: s = "error " + n; break; default: s = "error " + n; break;
} }
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (int line, int col, string s) { public virtual void SemErr (int line, int col, string s) {
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (string s) { public virtual void SemErr (string s) {
builder.AppendLine(s); errorStream.WriteLine(s);
count++; count++;
} }
public void Warning (int line, int col, string s) { public virtual void Warning (int line, int col, string s) {
builder.AppendFormat(errMsgFormat, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
} }
public void Warning(string s) { public virtual void Warning(string s) {
builder.AppendLine(s); errorStream.WriteLine(s);
} }
} // Errors } // Errors
@ -157,4 +154,3 @@ public class Errors {
public class FatalError: Exception { public class FatalError: Exception {
public FatalError(string m): base(m) {} public FatalError(string m): base(m) {}
} }

View File

@ -2,12 +2,9 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.CodeDom.Compiler;
namespace csmic.Interpreter { namespace csmic.Interpreter {
[GeneratedCodeAttribute("Coco/R", "")]
public class Token { public class Token {
public int kind; // token kind public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0) public int pos; // token position in bytes in the source text (starting at 0)
@ -219,7 +216,7 @@ public class Scanner {
int col; // column number of current character int col; // column number of current character
int line; // line number of current character int line; // line number of current character
int oldEols; // EOLs that appeared in a comment; int oldEols; // EOLs that appeared in a comment;
static readonly Dictionary<int, int> start; // maps first token character to start state static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy) Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token Token pt; // current peek token
@ -228,7 +225,7 @@ public class Scanner {
int tlen; // length of current token int tlen; // length of current token
static Scanner() { static Scanner() {
start = new Dictionary<int, int>(128); start = new Hashtable(128);
for (int i = 65; i <= 90; ++i) start[i] = 1; for (int i = 65; i <= 90; ++i) start[i] = 1;
for (int i = 97; i <= 122; ++i) start[i] = 1; for (int i = 97; i <= 122; ++i) start[i] = 1;
start[43] = 2; start[43] = 2;
@ -332,7 +329,8 @@ public class Scanner {
t = new Token(); t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos; t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state; int state;
state = (int) start[ch]; if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh(); tlen = 0; AddCh();
switch (state) { switch (state) {

View File

@ -0,0 +1,489 @@
using System;
using System.IO;
using System.Collections;
namespace csmic.Interpreter {
public class Token {
public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0)
public int charPos; // token position in characters in the source text (starting at 0)
public int col; // token column (starting at 1)
public int line; // token line (starting at 1)
public string val; // token value
public Token next; // ML 2005-03-11 Tokens are kept in linked list
}
//-----------------------------------------------------------------------------------
// Buffer
//-----------------------------------------------------------------------------------
public class Buffer {
// This Buffer supports the following cases:
// 1) seekable stream (file)
// a) whole stream in buffer
// b) part of stream in buffer
// 2) non seekable stream (network, console)
public const int EOF = char.MaxValue + 1;
const int MIN_BUFFER_LENGTH = 1024; // 1KB
const int MAX_BUFFER_LENGTH = MIN_BUFFER_LENGTH * 64; // 64KB
byte[] buf; // input buffer
int bufStart; // position of first byte in buffer relative to input stream
int bufLen; // length of buffer
int fileLen; // length of input stream (may change if the stream is no file)
int bufPos; // current position in buffer
Stream stream; // input stream (seekable)
bool isUserStream; // was the stream opened by the user?
public Buffer (Stream s, bool isUserStream) {
stream = s; this.isUserStream = isUserStream;
if (stream.CanSeek) {
fileLen = (int) stream.Length;
bufLen = Math.Min(fileLen, MAX_BUFFER_LENGTH);
bufStart = Int32.MaxValue; // nothing in the buffer so far
} else {
fileLen = bufLen = bufStart = 0;
}
buf = new byte[(bufLen>0) ? bufLen : MIN_BUFFER_LENGTH];
if (fileLen > 0) Pos = 0; // setup buffer to position 0 (start)
else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
if (bufLen == fileLen && stream.CanSeek) Close();
}
protected Buffer(Buffer b) { // called in UTF8Buffer constructor
buf = b.buf;
bufStart = b.bufStart;
bufLen = b.bufLen;
fileLen = b.fileLen;
bufPos = b.bufPos;
stream = b.stream;
// keep destructor from closing the stream
b.stream = null;
isUserStream = b.isUserStream;
}
~Buffer() { Close(); }
protected void Close() {
if (!isUserStream && stream != null) {
stream.Close();
stream = null;
}
}
public virtual int Read () {
if (bufPos < bufLen) {
return buf[bufPos++];
} else if (Pos < fileLen) {
Pos = Pos; // shift buffer start to Pos
return buf[bufPos++];
} else if (stream != null && !stream.CanSeek && ReadNextStreamChunk() > 0) {
return buf[bufPos++];
} else {
return EOF;
}
}
public int Peek () {
int curPos = Pos;
int ch = Read();
Pos = curPos;
return ch;
}
// beg .. begin, zero-based, inclusive, in byte
// end .. end, zero-based, exclusive, in byte
public string GetString (int beg, int end) {
int len = 0;
char[] buf = new char[end - beg];
int oldPos = Pos;
Pos = beg;
while (Pos < end) buf[len++] = (char) Read();
Pos = oldPos;
return new String(buf, 0, len);
}
public int Pos {
get { return bufPos + bufStart; }
set {
if (value >= fileLen && stream != null && !stream.CanSeek) {
// Wanted position is after buffer and the stream
// is not seek-able e.g. network or console,
// thus we have to read the stream manually till
// the wanted position is in sight.
while (value >= fileLen && ReadNextStreamChunk() > 0);
}
if (value < 0 || value > fileLen) {
throw new FatalError("buffer out of bounds access, position: " + value);
}
if (value >= bufStart && value < bufStart + bufLen) { // already in buffer
bufPos = value - bufStart;
} else if (stream != null) { // must be swapped in
stream.Seek(value, SeekOrigin.Begin);
bufLen = stream.Read(buf, 0, buf.Length);
bufStart = value; bufPos = 0;
} else {
// set the position to the end of the file, Pos will return fileLen.
bufPos = fileLen - bufStart;
}
}
}
// Read the next chunk of bytes from the stream, increases the buffer
// if needed and updates the fields fileLen and bufLen.
// Returns the number of bytes read.
private int ReadNextStreamChunk() {
int free = buf.Length - bufLen;
if (free == 0) {
// in the case of a growing input stream
// we can neither seek in the stream, nor can we
// foresee the maximum length, thus we must adapt
// the buffer size on demand.
byte[] newBuf = new byte[bufLen * 2];
Array.Copy(buf, newBuf, bufLen);
buf = newBuf;
free = bufLen;
}
int read = stream.Read(buf, bufLen, free);
if (read > 0) {
fileLen = bufLen = (bufLen + read);
return read;
}
// end of stream reached
return 0;
}
}
//-----------------------------------------------------------------------------------
// UTF8Buffer
//-----------------------------------------------------------------------------------
public class UTF8Buffer: Buffer {
public UTF8Buffer(Buffer b): base(b) {}
public override int Read() {
int ch;
do {
ch = base.Read();
// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EOF));
if (ch < 128 || ch == EOF) {
// nothing to do, first 127 chars are the same in ascii and utf8
// 0xxxxxxx or end of file character
} else if ((ch & 0xF0) == 0xF0) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x07; ch = base.Read();
int c2 = ch & 0x3F; ch = base.Read();
int c3 = ch & 0x3F; ch = base.Read();
int c4 = ch & 0x3F;
ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
} else if ((ch & 0xE0) == 0xE0) {
// 1110xxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x0F; ch = base.Read();
int c2 = ch & 0x3F; ch = base.Read();
int c3 = ch & 0x3F;
ch = (((c1 << 6) | c2) << 6) | c3;
} else if ((ch & 0xC0) == 0xC0) {
// 110xxxxx 10xxxxxx
int c1 = ch & 0x1F; ch = base.Read();
int c2 = ch & 0x3F;
ch = (c1 << 6) | c2;
}
return ch;
}
}
//-----------------------------------------------------------------------------------
// Scanner
//-----------------------------------------------------------------------------------
public class Scanner {
const char EOL = '\n';
const int eofSym = 0; /* pdt */
const int maxT = 22;
const int noSym = 22;
public Buffer buffer; // scanner buffer
Token t; // current token
int ch; // current input character
int pos; // byte position of current character
int charPos; // position by unicode characters starting with 0
int col; // column number of current character
int line; // line number of current character
int oldEols; // EOLs that appeared in a comment;
static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token
char[] tval = new char[128]; // text of current token
int tlen; // length of current token
static Scanner() {
start = new Hashtable(128);
for (int i = 65; i <= 90; ++i) start[i] = 1;
for (int i = 97; i <= 122; ++i) start[i] = 1;
start[43] = 2;
for (int i = 50; i <= 57; ++i) start[i] = 6;
start[48] = 17;
start[49] = 18;
start[34] = 11;
start[40] = 13;
start[41] = 14;
start[61] = 15;
start[60] = 19;
start[62] = 20;
start[42] = 21;
start[47] = 22;
start[37] = 23;
start[94] = 24;
start[91] = 25;
start[93] = 26;
start[44] = 27;
start[58] = 31;
start[45] = 32;
start[Buffer.EOF] = -1;
}
public Scanner (string fileName) {
try {
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
buffer = new Buffer(stream, false);
Init();
} catch (IOException) {
throw new FatalError("Cannot open file " + fileName);
}
}
public Scanner (Stream s) {
buffer = new Buffer(s, true);
Init();
}
void Init() {
pos = -1; line = 1; col = 0; charPos = -1;
oldEols = 0;
NextCh();
if (ch == 0xEF) { // check optional byte order mark for UTF-8
NextCh(); int ch1 = ch;
NextCh(); int ch2 = ch;
if (ch1 != 0xBB || ch2 != 0xBF) {
throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
}
buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
NextCh();
}
pt = tokens = new Token(); // first token is a dummy
}
void NextCh() {
if (oldEols > 0) { ch = EOL; oldEols--; }
else {
pos = buffer.Pos;
// buffer reads unicode chars, if UTF8 has been detected
ch = buffer.Read(); col++; charPos++;
// replace isolated '\r' by '\n' in order to make
// eol handling uniform across Windows, Unix and Mac
if (ch == '\r' && buffer.Peek() != '\n') ch = EOL;
if (ch == EOL) { line++; col = 0; }
}
}
void AddCh() {
if (tlen >= tval.Length) {
char[] newBuf = new char[2 * tval.Length];
Array.Copy(tval, 0, newBuf, 0, tval.Length);
tval = newBuf;
}
if (ch != Buffer.EOF) {
tval[tlen++] = (char) ch;
NextCh();
}
}
void CheckLiteral() {
switch (t.val) {
case "+": t.kind = 10; break;
case "-": t.kind = 11; break;
default: break;
}
}
Token NextToken() {
while (ch == ' ' ||
ch == 9 || ch == 13
) NextCh();
int recKind = noSym;
int recEnd = pos;
t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state;
if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh();
switch (state) {
case -1: { t.kind = eofSym; break; } // NextCh already done
case 0: {
if (recKind != noSym) {
tlen = recEnd - t.pos;
SetScannerBehindT();
}
t.kind = recKind; break;
} // NextCh already done
case 1:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
else {t.kind = 1; break;}
case 2:
{t.kind = 2; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 3:
{t.kind = 3; break;}
case 4:
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 5;}
else {goto case 0;}
case 5:
recEnd = pos; recKind = 4;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 5;}
else {t.kind = 4; break;}
case 6:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 7:
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else if (ch == '+' || ch == '-') {AddCh(); goto case 8;}
else {goto case 0;}
case 8:
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else {goto case 0;}
case 9:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else {t.kind = 5; break;}
case 10:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 10;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else {t.kind = 5; break;}
case 11:
if (ch <= '!' || ch >= '#' && ch <= 65535) {AddCh(); goto case 11;}
else if (ch == '"') {AddCh(); goto case 12;}
else {goto case 0;}
case 12:
{t.kind = 6; break;}
case 13:
{t.kind = 7; break;}
case 14:
{t.kind = 8; break;}
case 15:
if (ch == '=') {AddCh(); goto case 16;}
else {goto case 0;}
case 16:
{t.kind = 9; break;}
case 17:
recEnd = pos; recKind = 5;
if (ch >= '2' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'B' || ch == 'b') {AddCh(); goto case 3;}
else if (ch >= '0' && ch <= '1') {AddCh(); goto case 18;}
else if (ch == 'x') {AddCh(); goto case 4;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 18:
recEnd = pos; recKind = 5;
if (ch >= '2' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'B' || ch == 'b') {AddCh(); goto case 3;}
else if (ch >= '0' && ch <= '1') {AddCh(); goto case 18;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 19:
recEnd = pos; recKind = 9;
if (ch == '=') {AddCh(); goto case 16;}
else {t.kind = 9; break;}
case 20:
recEnd = pos; recKind = 9;
if (ch == '=') {AddCh(); goto case 16;}
else {t.kind = 9; break;}
case 21:
{t.kind = 12; break;}
case 22:
{t.kind = 13; break;}
case 23:
{t.kind = 14; break;}
case 24:
{t.kind = 15; break;}
case 25:
{t.kind = 16; break;}
case 26:
{t.kind = 17; break;}
case 27:
{t.kind = 18; break;}
case 28:
{t.kind = 19; break;}
case 29:
{t.kind = 20; break;}
case 30:
{t.kind = 21; break;}
case 31:
if (ch == ':') {AddCh(); goto case 28;}
else if (ch == '=') {AddCh(); goto case 29;}
else {goto case 0;}
case 32:
recEnd = pos; recKind = 2;
if (ch == '>') {AddCh(); goto case 30;}
else {t.kind = 2; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
}
t.val = new String(tval, 0, tlen);
return t;
}
private void SetScannerBehindT() {
buffer.Pos = t.pos;
NextCh();
line = t.line; col = t.col; charPos = t.charPos;
for (int i = 0; i < tlen; i++) NextCh();
}
// get the next token (possibly a token already seen during peeking)
public Token Scan () {
if (tokens.next == null) {
return NextToken();
} else {
pt = tokens = tokens.next;
return tokens;
}
}
// peek for the next token, ignore pragmas
public Token Peek () {
do {
if (pt.next == null) {
pt.next = NextToken();
}
pt = pt.next;
} while (pt.kind > maxT); // skip pragmas
return pt;
}
// make sure that peeking starts at the current scan position
public void ResetPeek () { pt = tokens; }
} // end Scanner
}

View File

@ -28,12 +28,9 @@ Coco/R itself) does not fall under the GNU General Public License.
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.CodeDom.Compiler;
-->namespace -->namespace
[GeneratedCodeAttribute("Coco/R", "")]
public class Token { public class Token {
public int kind; // token kind public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0) public int pos; // token position in bytes in the source text (starting at 0)
@ -243,7 +240,7 @@ public class Scanner {
int col; // column number of current character int col; // column number of current character
int line; // line number of current character int line; // line number of current character
int oldEols; // EOLs that appeared in a comment; int oldEols; // EOLs that appeared in a comment;
static readonly Dictionary<int, int> start; // maps first token character to start state static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy) Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token Token pt; // current peek token
@ -252,7 +249,7 @@ public class Scanner {
int tlen; // length of current token int tlen; // length of current token
static Scanner() { static Scanner() {
start = new Dictionary<int, int>(128); start = new Hashtable(128);
-->initialization -->initialization
} }
@ -330,7 +327,8 @@ public class Scanner {
t = new Token(); t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos; t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state; int state;
state = (int) start[ch]; if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh(); tlen = 0; AddCh();
switch (state) { switch (state) {

View File

@ -5,13 +5,11 @@ using System.Collections.Generic;
using System; using System;
using System.CodeDom.Compiler;
namespace csmic.Scripting { namespace csmic.Scripting {
[GeneratedCodeAttribute("Coco/R", "")]
public class Parser { public class Parser {
public const int _EOF = 0; public const int _EOF = 0;
public const int _identifier = 1; public const int _identifier = 1;
@ -26,8 +24,8 @@ public class Parser {
public const int _COMPARER = 10; public const int _COMPARER = 10;
public const int maxT = 34; public const int maxT = 34;
const bool T = true; const bool _T = true;
const bool x = false; const bool _x = false;
const int minErrDist = 2; const int minErrDist = 2;
public Scanner scanner; public Scanner scanner;
@ -702,15 +700,14 @@ bool IsArrayCall()
SCRIPT(); SCRIPT();
Expect(0); Expect(0);
Expect(0);
} }
static readonly bool[,] set = { static readonly bool[,] set = {
{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, {_T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,x,T, T,T,x,x, T,x,x,T, x,x,x,T, T,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x}, {_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_T, _x,_x,_x,_T, _T,_x,_T,_T, _T,_T,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,x,T, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x}, {_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,x,T, T,T,x,x, T,x,x,T, x,x,x,T, T,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x}, {_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_T, _x,_x,_x,_T, _T,_x,_x,_T, _T,_T,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,T,x} {_x,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_x,_T,_x}
}; };
} // end Parser } // end Parser
@ -719,9 +716,9 @@ bool IsArrayCall()
public class Errors { public class Errors {
public int count = 0; // number of errors detected public int count = 0; // number of errors detected
public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public void SynErr (int line, int col, int n) { public virtual void SynErr (int line, int col, int n) {
string s; string s;
switch (n) { switch (n) {
case 0: s = "EOF expected"; break; case 0: s = "EOF expected"; break;
@ -771,21 +768,21 @@ public class Errors {
count++; count++;
} }
public void SemErr (int line, int col, string s) { public virtual void SemErr (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (string s) { public virtual void SemErr (string s) {
errorStream.WriteLine(s); errorStream.WriteLine(s);
count++; count++;
} }
public void Warning (int line, int col, string s) { public virtual void Warning (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
} }
public void Warning(string s) { public virtual void Warning(string s) {
errorStream.WriteLine(s); errorStream.WriteLine(s);
} }
} // Errors } // Errors
@ -794,5 +791,4 @@ public class Errors {
public class FatalError: Exception { public class FatalError: Exception {
public FatalError(string m): base(m) {} public FatalError(string m): base(m) {}
} }
} }

View File

@ -0,0 +1,794 @@
using csmic;
using System.Text;
using System.Collections.Generic;
using System;
namespace csmic.Scripting {
public class Parser {
public const int _EOF = 0;
public const int _identifier = 1;
public const int _sign = 2;
public const int _binary = 3;
public const int _hex = 4;
public const int _number = 5;
public const int _newline = 6;
public const int _string = 7;
public const int _LPAREN = 8;
public const int _RPAREN = 9;
public const int _COMPARER = 10;
public const int maxT = 34;
const bool _T = true;
const bool _x = false;
const int minErrDist = 2;
public Scanner scanner;
public Errors errors;
public Token t; // last recognized token
public Token la; // lookahead token
int errDist = minErrDist;
private MacroOperation root = new MacroOperation(OperationType.Unknown);
internal MacroOperation Root
{
get
{
return this.root;
}
set
{
this.root = value;
}
}
bool IsFunctionCall()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.kind == _LPAREN && la.kind == _identifier)
return true;
return false;
}
bool IsCompare()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.kind == _COMPARER)
return true;
return false;
}
bool IsAssignment()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if (next.val == "::" || next.val == ":=" || next.val == "->")
return true;
return false;
}
bool IsArrayCall()
{
scanner.ResetPeek();
Token next = scanner.Peek();
if(next.val == "[")
return true;
return false;
}
public Parser(Scanner scanner) {
this.scanner = scanner;
errors = new Errors();
}
void SynErr (int n) {
if (errDist >= minErrDist) errors.SynErr(la.line, la.col, n);
errDist = 0;
}
public void SemErr (string msg) {
if (errDist >= minErrDist) errors.SemErr(t.line, t.col, msg);
errDist = 0;
}
void Get () {
for (;;) {
t = la;
la = scanner.Scan();
if (la.kind <= maxT) { ++errDist; break; }
la = t;
}
}
void Expect (int n) {
if (la.kind==n) Get(); else { SynErr(n); }
}
bool StartOf (int s) {
return set[s, la.kind];
}
void ExpectWeak (int n, int follow) {
if (la.kind == n) Get();
else {
SynErr(n);
while (!StartOf(follow)) Get();
}
}
bool WeakSeparator(int n, int syFol, int repFol) {
int kind = la.kind;
if (kind == n) {Get(); return true;}
else if (StartOf(repFol)) {return false;}
else {
SynErr(n);
while (!(set[syFol, kind] || set[repFol, kind] || set[0, kind])) {
Get();
kind = la.kind;
}
return StartOf(syFol);
}
}
void SCRIPT() {
string statement = string.Empty;
while (StartOf(1)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
this.root.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref this.root);
break;
}
case 15: {
WhileBlock(ref this.root);
break;
}
case 18: {
FunctionDeclaration(ref this.root);
break;
}
case 19: {
EchoStatement(ref this.root);
break;
}
case 20: {
SayStatement(ref this.root);
break;
}
case 21: {
DisplayStatement(ref this.root);
break;
}
case 16: {
ForBlock(ref this.root);
break;
}
}
}
}
void Statement(out string value) {
value = string.Empty;
StringBuilder builder = new StringBuilder();
if (IsAssignment()) {
Assignment(ref builder);
value = builder.ToString();
} else if (StartOf(2)) {
Expression(ref builder);
value = builder.ToString();
} else SynErr(35);
}
void IfBlock(ref MacroOperation parent) {
MacroOperation ifBlock = new MacroOperation(OperationType.If);
MacroOperation elseBlock = new MacroOperation(OperationType.Else);
string ifStatement = string.Empty;
string statement = string.Empty;
StringBuilder builder = new StringBuilder();
bool hasElse = false;
Expect(11);
Expect(8);
Comparison(ref builder);
ifStatement = builder.ToString(); ifBlock.Input.Add(ifStatement);
Expect(9);
Expect(12);
while (StartOf(3)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
ifBlock.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref ifBlock);
break;
}
case 15: {
WhileBlock(ref ifBlock);
break;
}
case 19: {
EchoStatement(ref ifBlock);
break;
}
case 20: {
SayStatement(ref ifBlock);
break;
}
case 21: {
DisplayStatement(ref ifBlock);
break;
}
case 16: {
ForBlock(ref ifBlock);
break;
}
}
}
Expect(13);
if (la.kind == 14) {
Get();
hasElse = true;
Expect(12);
while (StartOf(3)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
elseBlock.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref elseBlock);
break;
}
case 15: {
WhileBlock(ref elseBlock);
break;
}
case 19: {
EchoStatement(ref elseBlock);
break;
}
case 20: {
SayStatement(ref elseBlock);
break;
}
case 21: {
DisplayStatement(ref elseBlock);
break;
}
case 16: {
ForBlock(ref elseBlock);
break;
}
}
}
Expect(13);
}
if(hasElse)
{
MacroOperation ifelse = new MacroOperation(OperationType.IfElse);
ifelse.Children.Add(ifBlock);
ifelse.Children.Add(elseBlock);
parent.Children.Add(ifelse);
}
else
{
parent.Children.Add(ifBlock);
}
}
void WhileBlock(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
MacroOperation whileBlock = new MacroOperation(OperationType.While);
string statement = string.Empty;
Expect(15);
Expect(8);
Comparison(ref builder);
whileBlock.Input.Add(builder.ToString());
Expect(9);
Expect(12);
while (StartOf(3)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
whileBlock.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref whileBlock);
break;
}
case 15: {
WhileBlock(ref whileBlock);
break;
}
case 19: {
EchoStatement(ref whileBlock);
break;
}
case 20: {
SayStatement(ref whileBlock);
break;
}
case 21: {
DisplayStatement(ref whileBlock);
break;
}
case 16: {
ForBlock(ref whileBlock);
break;
}
}
}
Expect(13);
parent.Children.Add(whileBlock);
}
void FunctionDeclaration(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
string statement = string.Empty;
MacroOperation func = new MacroOperation(OperationType.FunctionDeclaration);
Expect(18);
Expect(8);
CommaList(ref builder);
string[] args = builder.ToString().Split(','); func.Input.AddRange(args);
Expect(9);
Expect(12);
while (StartOf(3)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
func.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref func);
break;
}
case 15: {
WhileBlock(ref func);
break;
}
case 19: {
EchoStatement(ref func);
break;
}
case 20: {
SayStatement(ref func);
break;
}
case 21: {
DisplayStatement(ref func);
break;
}
case 16: {
ForBlock(ref func);
break;
}
}
}
Expect(13);
parent.Children.Add(func);
}
void EchoStatement(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
MacroOperation echoStatement = new MacroOperation(OperationType.Echo);
string statement = string.Empty;
Expect(19);
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
echoStatement.Children.Add(operation);
parent.Children.Add(echoStatement);
}
void SayStatement(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
MacroOperation sayStatement = new MacroOperation(OperationType.Say);
string statement = string.Empty;
Expect(20);
Expect(7);
statement = t.val.Replace("\"", "");
sayStatement.Input.Add(statement);
parent.Children.Add(sayStatement);
}
void DisplayStatement(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
MacroOperation displayStatement = new MacroOperation(OperationType.Display);
string statement = string.Empty;
Expect(21);
if (StartOf(2)) {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
displayStatement.Children.Add(operation);
} else if (la.kind == 7) {
Get();
statement = t.val.Replace("\"", "");
MacroOperation operation = new MacroOperation(OperationType.String);
operation.Input.Add(statement);
displayStatement.Children.Add(operation);
} else SynErr(36);
while (la.kind == 17) {
Get();
if (StartOf(2)) {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
displayStatement.Children.Add(operation);
} else if (la.kind == 7) {
Get();
statement = t.val.Replace("\"", "");
MacroOperation operation = new MacroOperation(OperationType.String);
operation.Input.Add(statement);
displayStatement.Children.Add(operation);
} else SynErr(37);
}
parent.Children.Add(displayStatement);
}
void ForBlock(ref MacroOperation parent) {
StringBuilder builder = new StringBuilder();
string statement = string.Empty;
string statement2 = string.Empty;
MacroOperation forBlock = new MacroOperation(OperationType.For);
Expect(16);
Expect(8);
Statement(out statement);
Expect(17);
Comparison(ref builder);
Expect(17);
Statement(out statement2);
forBlock.Input.Add(statement); forBlock.Input.Add(builder.ToString()); forBlock.Input.Add(statement2);
Expect(9);
Expect(12);
while (StartOf(3)) {
switch (la.kind) {
case 1: case 3: case 4: case 5: case 8: case 22: case 23: {
Statement(out statement);
MacroOperation operation = new MacroOperation(OperationType.Statement);
operation.Input.Add(statement);
forBlock.Children.Add(operation);
break;
}
case 11: {
IfBlock(ref forBlock);
break;
}
case 15: {
WhileBlock(ref forBlock);
break;
}
case 19: {
EchoStatement(ref forBlock);
break;
}
case 20: {
SayStatement(ref forBlock);
break;
}
case 21: {
DisplayStatement(ref forBlock);
break;
}
case 16: {
ForBlock(ref forBlock);
break;
}
}
}
Expect(13);
parent.Children.Add(forBlock);
}
void Comparison(ref StringBuilder result) {
Expression(ref result);
Expect(10);
result.Append(t.val);
Expression(ref result);
}
void CommaList(ref StringBuilder builder) {
Expression(ref builder);
while (la.kind == 17) {
Get();
builder.Append(t.val);
Expression(ref builder);
}
}
void Assignment(ref StringBuilder builder) {
Expect(1);
builder.Append(t.val);
if (la.kind == 30) {
Get();
builder.Append(t.val);
Expression(ref builder);
} else if (la.kind == 31) {
Get();
builder.Append(t.val); string value = string.Empty;
AnyExpression(out value);
builder.Append(value);
Expect(6);
} else if (la.kind == 32) {
Get();
builder.Append(t.val);
ArrayL(ref builder);
} else SynErr(38);
}
void Expression(ref StringBuilder builder) {
Term(ref builder);
while (la.kind == 22 || la.kind == 23 || la.kind == 24) {
if (la.kind == 22) {
Get();
builder.Append(t.val);
Term(ref builder);
} else if (la.kind == 23) {
Get();
builder.Append(t.val);
Term(ref builder);
} else {
Get();
builder.Append(t.val);
Term(ref builder);
}
}
}
void Term(ref StringBuilder builder) {
Factor(ref builder);
while (la.kind == 25 || la.kind == 26) {
if (la.kind == 25) {
Get();
builder.Append(t.val);
Factor(ref builder);
} else {
Get();
builder.Append(t.val);
Factor(ref builder);
}
}
}
void Factor(ref StringBuilder builder) {
Value(ref builder);
while (la.kind == 27) {
Get();
builder.Append(t.val);
Value(ref builder);
}
}
void Value(ref StringBuilder builder) {
if (la.kind == 22 || la.kind == 23) {
if (la.kind == 22) {
Get();
builder.Append(t.val);
} else {
Get();
builder.Append(t.val);
}
}
if (IsFunctionCall()) {
Function(ref builder);
} else if (IsArrayCall()) {
ArrayCall(ref builder);
} else if (la.kind == 1) {
Get();
builder.Append(t.val);
} else if (la.kind == 5) {
Get();
builder.Append(t.val);
} else if (la.kind == 4) {
Get();
builder.Append(t.val);
} else if (la.kind == 3) {
Get();
builder.Append(t.val);
} else if (la.kind == 8) {
Get();
builder.Append(t.val);
Expression(ref builder);
Expect(9);
builder.Append(t.val);
} else SynErr(39);
}
void Function(ref StringBuilder builder) {
Expect(1);
builder.Append(t.val);
Expect(8);
builder.Append(t.val);
CommaList(ref builder);
Expect(9);
builder.Append(t.val);
}
void ArrayCall(ref StringBuilder builder) {
Expect(1);
builder.Append(t.val);
Expect(28);
builder.Append(t.val);
Expression(ref builder);
Expect(29);
builder.Append(t.val);
}
void ArrayL(ref StringBuilder builder) {
Expect(28);
builder.Append(t.val);
CommaList(ref builder);
Expect(29);
builder.Append(t.val);
}
void AnyExpression(out string value) {
value = string.Empty; StringBuilder builder = new StringBuilder();
Get();
builder.Append(t.val);
while (StartOf(4)) {
Get();
builder.Append(t.val);
}
Expect(33);
value = builder.ToString();
}
public void Parse() {
la = new Token();
la.val = "";
Get();
SCRIPT();
Expect(0);
}
static readonly bool[,] set = {
{_T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_T, _x,_x,_x,_T, _T,_x,_T,_T, _T,_T,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_x,_T, _T,_T,_x,_x, _T,_x,_x,_T, _x,_x,_x,_T, _T,_x,_x,_T, _T,_T,_T,_T, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x},
{_x,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_x,_T,_x}
};
} // end Parser
public class Errors {
public int count = 0; // number of errors detected
public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public virtual void SynErr (int line, int col, int n) {
string s;
switch (n) {
case 0: s = "EOF expected"; break;
case 1: s = "identifier expected"; break;
case 2: s = "sign expected"; break;
case 3: s = "binary expected"; break;
case 4: s = "hex expected"; break;
case 5: s = "number expected"; break;
case 6: s = "newline expected"; break;
case 7: s = "string expected"; break;
case 8: s = "LPAREN expected"; break;
case 9: s = "RPAREN expected"; break;
case 10: s = "COMPARER expected"; break;
case 11: s = "\"if\" expected"; break;
case 12: s = "\"{\" expected"; break;
case 13: s = "\"}\" expected"; break;
case 14: s = "\"else\" expected"; break;
case 15: s = "\"while\" expected"; break;
case 16: s = "\"for\" expected"; break;
case 17: s = "\",\" expected"; break;
case 18: s = "\"function\" expected"; break;
case 19: s = "\"echo:\" expected"; break;
case 20: s = "\"say:\" expected"; break;
case 21: s = "\"display:\" expected"; break;
case 22: s = "\"+\" expected"; break;
case 23: s = "\"-\" expected"; break;
case 24: s = "\"%\" expected"; break;
case 25: s = "\"*\" expected"; break;
case 26: s = "\"/\" expected"; break;
case 27: s = "\"^\" expected"; break;
case 28: s = "\"[\" expected"; break;
case 29: s = "\"]\" expected"; break;
case 30: s = "\"::\" expected"; break;
case 31: s = "\":=\" expected"; break;
case 32: s = "\"->\" expected"; break;
case 33: s = "\"\\n\" expected"; break;
case 34: s = "??? expected"; break;
case 35: s = "invalid Statement"; break;
case 36: s = "invalid DisplayStatement"; break;
case 37: s = "invalid DisplayStatement"; break;
case 38: s = "invalid Assignment"; break;
case 39: s = "invalid Value"; break;
default: s = "error " + n; break;
}
errorStream.WriteLine(errMsgFormat, line, col, s);
count++;
}
public virtual void SemErr (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s);
count++;
}
public virtual void SemErr (string s) {
errorStream.WriteLine(s);
count++;
}
public virtual void Warning (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s);
}
public virtual void Warning(string s) {
errorStream.WriteLine(s);
}
} // Errors
public class FatalError: Exception {
public FatalError(string m): base(m) {}
}
}

View File

@ -26,15 +26,13 @@ Coco/R itself) does not fall under the GNU General Public License.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
-->begin -->begin
using System; using System;
using System.CodeDom.Compiler;
-->namespace -->namespace
[GeneratedCodeAttribute("Coco/R", "")]
public class Parser { public class Parser {
-->constants -->constants
const bool T = true; const bool _T = true;
const bool x = false; const bool _x = false;
const int minErrDist = 2; const int minErrDist = 2;
public Scanner scanner; public Scanner scanner;
@ -110,7 +108,6 @@ public class Parser {
la.val = ""; la.val = "";
Get(); Get();
-->parseRoot -->parseRoot
Expect(0);
} }
static readonly bool[,] set = { static readonly bool[,] set = {
@ -122,9 +119,9 @@ public class Parser {
public class Errors { public class Errors {
public int count = 0; // number of errors detected public int count = 0; // number of errors detected
public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream public System.IO.TextWriter errorStream = Console.Out; // error messages go to this stream
public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public void SynErr (int line, int col, int n) { public virtual void SynErr (int line, int col, int n) {
string s; string s;
switch (n) { switch (n) {
-->errors -->errors
@ -134,21 +131,21 @@ public class Errors {
count++; count++;
} }
public void SemErr (int line, int col, string s) { public virtual void SemErr (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
count++; count++;
} }
public void SemErr (string s) { public virtual void SemErr (string s) {
errorStream.WriteLine(s); errorStream.WriteLine(s);
count++; count++;
} }
public void Warning (int line, int col, string s) { public virtual void Warning (int line, int col, string s) {
errorStream.WriteLine(errMsgFormat, line, col, s); errorStream.WriteLine(errMsgFormat, line, col, s);
} }
public void Warning(string s) { public virtual void Warning(string s) {
errorStream.WriteLine(s); errorStream.WriteLine(s);
} }
} // Errors } // Errors
@ -157,4 +154,3 @@ public class Errors {
public class FatalError: Exception { public class FatalError: Exception {
public FatalError(string m): base(m) {} public FatalError(string m): base(m) {}
} }

View File

@ -2,12 +2,9 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.CodeDom.Compiler;
namespace csmic.Scripting { namespace csmic.Scripting {
[GeneratedCodeAttribute("Coco/R", "")]
public class Token { public class Token {
public int kind; // token kind public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0) public int pos; // token position in bytes in the source text (starting at 0)
@ -219,7 +216,7 @@ public class Scanner {
int col; // column number of current character int col; // column number of current character
int line; // line number of current character int line; // line number of current character
int oldEols; // EOLs that appeared in a comment; int oldEols; // EOLs that appeared in a comment;
static readonly Dictionary<int, int> start; // maps first token character to start state static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy) Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token Token pt; // current peek token
@ -228,7 +225,7 @@ public class Scanner {
int tlen; // length of current token int tlen; // length of current token
static Scanner() { static Scanner() {
start = new Dictionary<int, int>(128); start = new Hashtable(128);
for (int i = 65; i <= 90; ++i) start[i] = 1; for (int i = 65; i <= 90; ++i) start[i] = 1;
for (int i = 97; i <= 99; ++i) start[i] = 1; for (int i = 97; i <= 99; ++i) start[i] = 1;
for (int i = 102; i <= 114; ++i) start[i] = 1; for (int i = 102; i <= 114; ++i) start[i] = 1;
@ -393,7 +390,8 @@ public class Scanner {
t = new Token(); t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos; t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state; int state;
state = (int) start[ch]; if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh(); tlen = 0; AddCh();
switch (state) { switch (state) {

View File

@ -0,0 +1,635 @@
using System;
using System.IO;
using System.Collections;
namespace csmic.Scripting {
public class Token {
public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0)
public int charPos; // token position in characters in the source text (starting at 0)
public int col; // token column (starting at 1)
public int line; // token line (starting at 1)
public string val; // token value
public Token next; // ML 2005-03-11 Tokens are kept in linked list
}
//-----------------------------------------------------------------------------------
// Buffer
//-----------------------------------------------------------------------------------
public class Buffer {
// This Buffer supports the following cases:
// 1) seekable stream (file)
// a) whole stream in buffer
// b) part of stream in buffer
// 2) non seekable stream (network, console)
public const int EOF = char.MaxValue + 1;
const int MIN_BUFFER_LENGTH = 1024; // 1KB
const int MAX_BUFFER_LENGTH = MIN_BUFFER_LENGTH * 64; // 64KB
byte[] buf; // input buffer
int bufStart; // position of first byte in buffer relative to input stream
int bufLen; // length of buffer
int fileLen; // length of input stream (may change if the stream is no file)
int bufPos; // current position in buffer
Stream stream; // input stream (seekable)
bool isUserStream; // was the stream opened by the user?
public Buffer (Stream s, bool isUserStream) {
stream = s; this.isUserStream = isUserStream;
if (stream.CanSeek) {
fileLen = (int) stream.Length;
bufLen = Math.Min(fileLen, MAX_BUFFER_LENGTH);
bufStart = Int32.MaxValue; // nothing in the buffer so far
} else {
fileLen = bufLen = bufStart = 0;
}
buf = new byte[(bufLen>0) ? bufLen : MIN_BUFFER_LENGTH];
if (fileLen > 0) Pos = 0; // setup buffer to position 0 (start)
else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
if (bufLen == fileLen && stream.CanSeek) Close();
}
protected Buffer(Buffer b) { // called in UTF8Buffer constructor
buf = b.buf;
bufStart = b.bufStart;
bufLen = b.bufLen;
fileLen = b.fileLen;
bufPos = b.bufPos;
stream = b.stream;
// keep destructor from closing the stream
b.stream = null;
isUserStream = b.isUserStream;
}
~Buffer() { Close(); }
protected void Close() {
if (!isUserStream && stream != null) {
stream.Close();
stream = null;
}
}
public virtual int Read () {
if (bufPos < bufLen) {
return buf[bufPos++];
} else if (Pos < fileLen) {
Pos = Pos; // shift buffer start to Pos
return buf[bufPos++];
} else if (stream != null && !stream.CanSeek && ReadNextStreamChunk() > 0) {
return buf[bufPos++];
} else {
return EOF;
}
}
public int Peek () {
int curPos = Pos;
int ch = Read();
Pos = curPos;
return ch;
}
// beg .. begin, zero-based, inclusive, in byte
// end .. end, zero-based, exclusive, in byte
public string GetString (int beg, int end) {
int len = 0;
char[] buf = new char[end - beg];
int oldPos = Pos;
Pos = beg;
while (Pos < end) buf[len++] = (char) Read();
Pos = oldPos;
return new String(buf, 0, len);
}
public int Pos {
get { return bufPos + bufStart; }
set {
if (value >= fileLen && stream != null && !stream.CanSeek) {
// Wanted position is after buffer and the stream
// is not seek-able e.g. network or console,
// thus we have to read the stream manually till
// the wanted position is in sight.
while (value >= fileLen && ReadNextStreamChunk() > 0);
}
if (value < 0 || value > fileLen) {
throw new FatalError("buffer out of bounds access, position: " + value);
}
if (value >= bufStart && value < bufStart + bufLen) { // already in buffer
bufPos = value - bufStart;
} else if (stream != null) { // must be swapped in
stream.Seek(value, SeekOrigin.Begin);
bufLen = stream.Read(buf, 0, buf.Length);
bufStart = value; bufPos = 0;
} else {
// set the position to the end of the file, Pos will return fileLen.
bufPos = fileLen - bufStart;
}
}
}
// Read the next chunk of bytes from the stream, increases the buffer
// if needed and updates the fields fileLen and bufLen.
// Returns the number of bytes read.
private int ReadNextStreamChunk() {
int free = buf.Length - bufLen;
if (free == 0) {
// in the case of a growing input stream
// we can neither seek in the stream, nor can we
// foresee the maximum length, thus we must adapt
// the buffer size on demand.
byte[] newBuf = new byte[bufLen * 2];
Array.Copy(buf, newBuf, bufLen);
buf = newBuf;
free = bufLen;
}
int read = stream.Read(buf, bufLen, free);
if (read > 0) {
fileLen = bufLen = (bufLen + read);
return read;
}
// end of stream reached
return 0;
}
}
//-----------------------------------------------------------------------------------
// UTF8Buffer
//-----------------------------------------------------------------------------------
public class UTF8Buffer: Buffer {
public UTF8Buffer(Buffer b): base(b) {}
public override int Read() {
int ch;
do {
ch = base.Read();
// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EOF));
if (ch < 128 || ch == EOF) {
// nothing to do, first 127 chars are the same in ascii and utf8
// 0xxxxxxx or end of file character
} else if ((ch & 0xF0) == 0xF0) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x07; ch = base.Read();
int c2 = ch & 0x3F; ch = base.Read();
int c3 = ch & 0x3F; ch = base.Read();
int c4 = ch & 0x3F;
ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
} else if ((ch & 0xE0) == 0xE0) {
// 1110xxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x0F; ch = base.Read();
int c2 = ch & 0x3F; ch = base.Read();
int c3 = ch & 0x3F;
ch = (((c1 << 6) | c2) << 6) | c3;
} else if ((ch & 0xC0) == 0xC0) {
// 110xxxxx 10xxxxxx
int c1 = ch & 0x1F; ch = base.Read();
int c2 = ch & 0x3F;
ch = (c1 << 6) | c2;
}
return ch;
}
}
//-----------------------------------------------------------------------------------
// Scanner
//-----------------------------------------------------------------------------------
public class Scanner {
const char EOL = '\n';
const int eofSym = 0; /* pdt */
const int maxT = 34;
const int noSym = 34;
public Buffer buffer; // scanner buffer
Token t; // current token
int ch; // current input character
int pos; // byte position of current character
int charPos; // position by unicode characters starting with 0
int col; // column number of current character
int line; // line number of current character
int oldEols; // EOLs that appeared in a comment;
static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token
char[] tval = new char[128]; // text of current token
int tlen; // length of current token
static Scanner() {
start = new Hashtable(128);
for (int i = 65; i <= 90; ++i) start[i] = 1;
for (int i = 97; i <= 99; ++i) start[i] = 1;
for (int i = 102; i <= 114; ++i) start[i] = 1;
for (int i = 116; i <= 122; ++i) start[i] = 1;
start[43] = 2;
for (int i = 50; i <= 57; ++i) start[i] = 6;
for (int i = 10; i <= 10; ++i) start[i] = 12;
for (int i = 13; i <= 13; ++i) start[i] = 11;
start[48] = 19;
start[49] = 20;
start[34] = 13;
start[40] = 15;
start[41] = 16;
start[61] = 17;
start[60] = 21;
start[62] = 22;
start[123] = 23;
start[125] = 24;
start[44] = 25;
start[101] = 38;
start[115] = 39;
start[100] = 40;
start[37] = 29;
start[42] = 30;
start[47] = 31;
start[94] = 32;
start[91] = 33;
start[93] = 34;
start[58] = 41;
start[45] = 42;
start[Buffer.EOF] = -1;
}
public Scanner (string fileName) {
try {
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
buffer = new Buffer(stream, false);
Init();
} catch (IOException) {
throw new FatalError("Cannot open file " + fileName);
}
}
public Scanner (Stream s) {
buffer = new Buffer(s, true);
Init();
}
void Init() {
pos = -1; line = 1; col = 0; charPos = -1;
oldEols = 0;
NextCh();
if (ch == 0xEF) { // check optional byte order mark for UTF-8
NextCh(); int ch1 = ch;
NextCh(); int ch2 = ch;
if (ch1 != 0xBB || ch2 != 0xBF) {
throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
}
buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
NextCh();
}
pt = tokens = new Token(); // first token is a dummy
}
void NextCh() {
if (oldEols > 0) { ch = EOL; oldEols--; }
else {
pos = buffer.Pos;
// buffer reads unicode chars, if UTF8 has been detected
ch = buffer.Read(); col++; charPos++;
// replace isolated '\r' by '\n' in order to make
// eol handling uniform across Windows, Unix and Mac
if (ch == '\r' && buffer.Peek() != '\n') ch = EOL;
if (ch == EOL) { line++; col = 0; }
}
}
void AddCh() {
if (tlen >= tval.Length) {
char[] newBuf = new char[2 * tval.Length];
Array.Copy(tval, 0, newBuf, 0, tval.Length);
tval = newBuf;
}
if (ch != Buffer.EOF) {
tval[tlen++] = (char) ch;
NextCh();
}
}
bool Comment0() {
int level = 1, pos0 = pos, line0 = line, col0 = col, charPos0 = charPos;
NextCh();
if (ch == '/') {
NextCh();
for(;;) {
if (ch == 10) {
level--;
if (level == 0) { oldEols = line - line0; NextCh(); return true; }
NextCh();
} else if (ch == Buffer.EOF) return false;
else NextCh();
}
} else {
buffer.Pos = pos0; NextCh(); line = line0; col = col0; charPos = charPos0;
}
return false;
}
bool Comment1() {
int level = 1, pos0 = pos, line0 = line, col0 = col, charPos0 = charPos;
NextCh();
if (ch == '*') {
NextCh();
for(;;) {
if (ch == '*') {
NextCh();
if (ch == '/') {
level--;
if (level == 0) { oldEols = line - line0; NextCh(); return true; }
NextCh();
}
} else if (ch == '/') {
NextCh();
if (ch == '*') {
level++; NextCh();
}
} else if (ch == Buffer.EOF) return false;
else NextCh();
}
} else {
buffer.Pos = pos0; NextCh(); line = line0; col = col0; charPos = charPos0;
}
return false;
}
void CheckLiteral() {
switch (t.val) {
case "if": t.kind = 11; break;
case "else": t.kind = 14; break;
case "while": t.kind = 15; break;
case "for": t.kind = 16; break;
case "function": t.kind = 18; break;
case "+": t.kind = 22; break;
case "-": t.kind = 23; break;
case "\n": t.kind = 33; break;
default: break;
}
}
Token NextToken() {
while (ch == ' ' ||
ch >= 9 && ch <= 10 || ch == 13
) NextCh();
if (ch == '/' && Comment0() ||ch == '/' && Comment1()) return NextToken();
int recKind = noSym;
int recEnd = pos;
t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state;
if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh();
switch (state) {
case -1: { t.kind = eofSym; break; } // NextCh already done
case 0: {
if (recKind != noSym) {
tlen = recEnd - t.pos;
SetScannerBehindT();
}
t.kind = recKind; break;
} // NextCh already done
case 1:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 2:
{t.kind = 2; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 3:
{t.kind = 3; break;}
case 4:
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 5;}
else {goto case 0;}
case 5:
recEnd = pos; recKind = 4;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 5;}
else {t.kind = 4; break;}
case 6:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 7:
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else if (ch == '+' || ch == '-') {AddCh(); goto case 8;}
else {goto case 0;}
case 8:
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else {goto case 0;}
case 9:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
else {t.kind = 5; break;}
case 10:
recEnd = pos; recKind = 5;
if (ch >= '0' && ch <= '9') {AddCh(); goto case 10;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else {t.kind = 5; break;}
case 11:
if (ch == 10) {AddCh(); goto case 12;}
else {goto case 0;}
case 12:
{t.kind = 6; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 13:
if (ch <= '!' || ch >= '#' && ch <= 65535) {AddCh(); goto case 13;}
else if (ch == '"') {AddCh(); goto case 14;}
else {goto case 0;}
case 14:
{t.kind = 7; break;}
case 15:
{t.kind = 8; break;}
case 16:
{t.kind = 9; break;}
case 17:
if (ch == '=') {AddCh(); goto case 18;}
else {goto case 0;}
case 18:
{t.kind = 10; break;}
case 19:
recEnd = pos; recKind = 5;
if (ch >= '2' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'B' || ch == 'b') {AddCh(); goto case 3;}
else if (ch >= '0' && ch <= '1') {AddCh(); goto case 20;}
else if (ch == 'x') {AddCh(); goto case 4;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 20:
recEnd = pos; recKind = 5;
if (ch >= '2' && ch <= '9') {AddCh(); goto case 6;}
else if (ch == 'B' || ch == 'b') {AddCh(); goto case 3;}
else if (ch >= '0' && ch <= '1') {AddCh(); goto case 20;}
else if (ch == 'E' || ch == 'e') {AddCh(); goto case 7;}
else if (ch == '.') {AddCh(); goto case 10;}
else {t.kind = 5; break;}
case 21:
recEnd = pos; recKind = 10;
if (ch == '=') {AddCh(); goto case 18;}
else {t.kind = 10; break;}
case 22:
recEnd = pos; recKind = 10;
if (ch == '=') {AddCh(); goto case 18;}
else {t.kind = 10; break;}
case 23:
{t.kind = 12; break;}
case 24:
{t.kind = 13; break;}
case 25:
{t.kind = 17; break;}
case 26:
{t.kind = 19; break;}
case 27:
{t.kind = 20; break;}
case 28:
{t.kind = 21; break;}
case 29:
{t.kind = 24; break;}
case 30:
{t.kind = 25; break;}
case 31:
{t.kind = 26; break;}
case 32:
{t.kind = 27; break;}
case 33:
{t.kind = 28; break;}
case 34:
{t.kind = 29; break;}
case 35:
{t.kind = 30; break;}
case 36:
{t.kind = 31; break;}
case 37:
{t.kind = 32; break;}
case 38:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'b' || ch >= 'd' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'c') {AddCh(); goto case 43;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 39:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'b' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'a') {AddCh(); goto case 44;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 40:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'h' || ch >= 'j' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'i') {AddCh(); goto case 45;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 41:
if (ch == ':') {AddCh(); goto case 35;}
else if (ch == '=') {AddCh(); goto case 36;}
else {goto case 0;}
case 42:
recEnd = pos; recKind = 2;
if (ch == '>') {AddCh(); goto case 37;}
else {t.kind = 2; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 43:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'g' || ch >= 'i' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'h') {AddCh(); goto case 46;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 44:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'x' || ch == 'z') {AddCh(); goto case 1;}
else if (ch == 'y') {AddCh(); goto case 47;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 45:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'r' || ch >= 't' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 's') {AddCh(); goto case 48;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 46:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'n' || ch >= 'p' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'o') {AddCh(); goto case 49;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 47:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == ':') {AddCh(); goto case 27;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 48:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'o' || ch >= 'q' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'p') {AddCh(); goto case 50;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 49:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == ':') {AddCh(); goto case 26;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 50:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'k' || ch >= 'm' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'l') {AddCh(); goto case 51;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 51:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'b' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == 'a') {AddCh(); goto case 52;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 52:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'x' || ch == 'z') {AddCh(); goto case 1;}
else if (ch == 'y') {AddCh(); goto case 53;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
case 53:
recEnd = pos; recKind = 1;
if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
else if (ch == ':') {AddCh(); goto case 28;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
}
t.val = new String(tval, 0, tlen);
return t;
}
private void SetScannerBehindT() {
buffer.Pos = t.pos;
NextCh();
line = t.line; col = t.col; charPos = t.charPos;
for (int i = 0; i < tlen; i++) NextCh();
}
// get the next token (possibly a token already seen during peeking)
public Token Scan () {
if (tokens.next == null) {
return NextToken();
} else {
pt = tokens = tokens.next;
return tokens;
}
}
// peek for the next token, ignore pragmas
public Token Peek () {
do {
if (pt.next == null) {
pt.next = NextToken();
}
pt = pt.next;
} while (pt.kind > maxT); // skip pragmas
return pt;
}
// make sure that peeking starts at the current scan position
public void ResetPeek () { pt = tokens; }
} // end Scanner
}

View File

@ -28,12 +28,9 @@ Coco/R itself) does not fall under the GNU General Public License.
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.CodeDom.Compiler;
-->namespace -->namespace
[GeneratedCodeAttribute("Coco/R", "")]
public class Token { public class Token {
public int kind; // token kind public int kind; // token kind
public int pos; // token position in bytes in the source text (starting at 0) public int pos; // token position in bytes in the source text (starting at 0)
@ -243,7 +240,7 @@ public class Scanner {
int col; // column number of current character int col; // column number of current character
int line; // line number of current character int line; // line number of current character
int oldEols; // EOLs that appeared in a comment; int oldEols; // EOLs that appeared in a comment;
static readonly Dictionary<int, int> start; // maps first token character to start state static readonly Hashtable start; // maps first token character to start state
Token tokens; // list of tokens already peeked (first token is a dummy) Token tokens; // list of tokens already peeked (first token is a dummy)
Token pt; // current peek token Token pt; // current peek token
@ -252,7 +249,7 @@ public class Scanner {
int tlen; // length of current token int tlen; // length of current token
static Scanner() { static Scanner() {
start = new Dictionary<int, int>(128); start = new Hashtable(128);
-->initialization -->initialization
} }
@ -330,7 +327,8 @@ public class Scanner {
t = new Token(); t = new Token();
t.pos = pos; t.col = col; t.line = line; t.charPos = charPos; t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
int state; int state;
state = (int) start[ch]; if (start.ContainsKey(ch)) { state = (int) start[ch]; }
else { state = 0; }
tlen = 0; AddCh(); tlen = 0; AddCh();
switch (state) { switch (state) {

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

BIN
CS-MIC/csmic/csmic/coco.exe Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
5775a073493428828d0febeeaa7c8078a54e5d15

View File

@ -0,0 +1,6 @@
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\bin\Debug\csmic.XML
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\bin\Debug\csmic.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\bin\Debug\csmic.pdb
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\obj\Debug\csmic.csproj.CoreCompileInputs.cache
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\obj\Debug\csmic.dll
C:\Users\wages\Documents\GitHub\cs-mic\CS-MIC\csmic\csmic\obj\Debug\csmic.pdb

Binary file not shown.

Binary file not shown.