mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add project files.
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLex
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Session;
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLex
|
||||
{
|
||||
private int m_state;
|
||||
private char[] m_currentChar;
|
||||
private SSLexTable m_table;
|
||||
private SSLexConsumer m_consumer;
|
||||
public bool m_hasErrors;
|
||||
|
||||
public SSLex(SSLexTable q_table, SSLexConsumer q_consumer)
|
||||
{
|
||||
q_table.Reset();
|
||||
m_table = q_table;
|
||||
m_consumer = q_consumer;
|
||||
m_currentChar = new char[1];
|
||||
}
|
||||
|
||||
public void Reset(SSLexConsumer consumer)
|
||||
{
|
||||
m_table.Reset();
|
||||
m_consumer = consumer;
|
||||
m_currentChar[0] = char.MinValue;
|
||||
m_state = 0;
|
||||
m_hasErrors = false;
|
||||
}
|
||||
|
||||
public SSLexConsumer consumer() => m_consumer;
|
||||
|
||||
public virtual bool error(SSLexLexeme q_lexeme)
|
||||
{
|
||||
m_hasErrors = true;
|
||||
string message = string.Format("Syntax Error: Unexpected character encountered: '{0}'", m_currentChar[0]);
|
||||
ErrorManager.ReportError(q_lexeme.line(), q_lexeme.offset() + q_lexeme.length() - 1, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool HasErrors => m_hasErrors;
|
||||
|
||||
public virtual bool complete(SSLexLexeme q_lexeme) => true;
|
||||
|
||||
public SSLexLexeme next()
|
||||
{
|
||||
SSLexLexeme ssLexLexeme = null;
|
||||
while (true)
|
||||
{
|
||||
SSLexMark? q_mark;
|
||||
SSLexFinalState q_final;
|
||||
do
|
||||
{
|
||||
m_state = 0;
|
||||
bool flag = false;
|
||||
q_mark = new SSLexMark?();
|
||||
q_final = m_table.lookupFinal(m_state);
|
||||
if (q_final.isFinal())
|
||||
m_consumer.mark();
|
||||
while (m_consumer.next())
|
||||
{
|
||||
flag = true;
|
||||
m_currentChar[0] = m_consumer.getCurrent();
|
||||
m_state = m_table.lookup(m_state, m_currentChar[0]);
|
||||
if (m_state != -1)
|
||||
{
|
||||
SSLexFinalState ssLexFinalState = m_table.lookupFinal(m_state);
|
||||
if (ssLexFinalState.isFinal())
|
||||
{
|
||||
q_mark = new SSLexMark?(m_consumer.mark());
|
||||
q_final = ssLexFinalState;
|
||||
}
|
||||
if (ssLexFinalState.isContextStart())
|
||||
{
|
||||
SSLexMark? nullable = new SSLexMark?(m_consumer.mark());
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
if (q_final.isContextEnd() && q_mark.HasValue)
|
||||
m_consumer.flushEndOfLine(ref q_mark);
|
||||
if (q_final.isIgnore() && q_mark.HasValue)
|
||||
{
|
||||
m_consumer.flushLexeme(q_mark.Value);
|
||||
if (q_final.isPop() && q_final.isPush())
|
||||
m_table.gotoSubtable(q_final.pushIndex());
|
||||
else if (q_final.isPop())
|
||||
m_table.popSubtable();
|
||||
}
|
||||
else
|
||||
goto label_19;
|
||||
}
|
||||
else
|
||||
goto label_34;
|
||||
}
|
||||
while (!q_final.isPush());
|
||||
m_table.pushSubtable(q_final.pushIndex());
|
||||
continue;
|
||||
label_19:
|
||||
if (!q_final.isFinal() || !q_mark.HasValue)
|
||||
{
|
||||
ssLexLexeme = new SSLexLexeme(m_consumer);
|
||||
if (!error(ssLexLexeme))
|
||||
{
|
||||
m_consumer.flushLexeme();
|
||||
ssLexLexeme = null;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (q_final.isPop() && q_final.isPush())
|
||||
m_table.gotoSubtable(q_final.pushIndex());
|
||||
else if (q_final.isPop())
|
||||
m_table.popSubtable();
|
||||
else if (q_final.isPush())
|
||||
m_table.pushSubtable(q_final.pushIndex());
|
||||
if (q_final.isStartOfLine() && m_consumer.line() != 0 && m_consumer.offset() != 0)
|
||||
m_consumer.flushStartOfLine(ref q_mark);
|
||||
ssLexLexeme = new SSLexLexeme(m_consumer, q_final, q_mark.Value);
|
||||
if (q_final.isKeyword())
|
||||
m_table.findKeyword(ssLexLexeme);
|
||||
m_consumer.flushLexeme(q_mark.Value);
|
||||
if (!complete(ssLexLexeme))
|
||||
ssLexLexeme = null;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
label_34:
|
||||
return ssLexLexeme;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexConsumer
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal abstract class SSLexConsumer
|
||||
{
|
||||
private int m_docOriginLine;
|
||||
private int m_docOriginColumn;
|
||||
private int m_line;
|
||||
private int m_start;
|
||||
protected int m_index;
|
||||
private int m_offset;
|
||||
public char m_current;
|
||||
private int m_scanLine;
|
||||
private int m_scanOffset;
|
||||
public int m_bufferLexemeStart;
|
||||
private char m_bof;
|
||||
private bool m_endOfData;
|
||||
|
||||
public abstract bool getNext();
|
||||
|
||||
public abstract string getSubstring(int start, int length);
|
||||
|
||||
public bool next()
|
||||
{
|
||||
if (m_endOfData)
|
||||
return false;
|
||||
if ((m_current = m_bof) != char.MinValue)
|
||||
{
|
||||
m_bof = char.MinValue;
|
||||
return true;
|
||||
}
|
||||
if (!getNext())
|
||||
{
|
||||
++m_index;
|
||||
m_endOfData = true;
|
||||
return false;
|
||||
}
|
||||
++m_index;
|
||||
if (m_current == '\n')
|
||||
{
|
||||
++m_scanLine;
|
||||
m_scanOffset = 1;
|
||||
}
|
||||
else
|
||||
++m_scanOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int line() => m_docOriginLine + m_line;
|
||||
|
||||
public int offset() => m_line != 0 ? m_offset : m_docOriginColumn + m_offset;
|
||||
|
||||
public char getCurrent() => m_current;
|
||||
|
||||
public SSLexMark mark() => new SSLexMark(m_scanLine, m_scanOffset, m_index);
|
||||
|
||||
public void flushEndOfLine(ref SSLexMark? q_mark)
|
||||
{
|
||||
SSLexMark ssLexMark = new SSLexMark(q_mark.Value.m_line - 1, q_mark.Value.m_offset, q_mark.Value.m_index - 1);
|
||||
q_mark = new SSLexMark?(ssLexMark);
|
||||
}
|
||||
|
||||
public void flushStartOfLine(ref SSLexMark? q_mark)
|
||||
{
|
||||
++m_line;
|
||||
++m_start;
|
||||
SSLexMark ssLexMark = new SSLexMark(q_mark.Value.m_line - 1, q_mark.Value.m_offset, q_mark.Value.m_index);
|
||||
q_mark = new SSLexMark?(ssLexMark);
|
||||
m_offset = 1;
|
||||
}
|
||||
|
||||
public virtual void flushLexeme(SSLexMark q_mark)
|
||||
{
|
||||
m_start = m_index = q_mark.m_index;
|
||||
m_line += q_mark.m_line;
|
||||
m_offset = q_mark.m_offset;
|
||||
m_scanLine = 0;
|
||||
m_scanOffset = q_mark.m_offset;
|
||||
m_bufferLexemeStart = m_index;
|
||||
}
|
||||
|
||||
public void flushLexeme()
|
||||
{
|
||||
m_start = m_index;
|
||||
m_line += m_scanLine;
|
||||
m_offset = m_scanOffset;
|
||||
m_scanLine = 0;
|
||||
m_bufferLexemeStart = m_index;
|
||||
}
|
||||
|
||||
public int lexemeLength() => m_index - m_start;
|
||||
|
||||
public int lexemeLength(SSLexMark q_mark) => q_mark.index() - m_start;
|
||||
|
||||
public string lexemeBuffer() => getSubstring(m_bufferLexemeStart, lexemeLength());
|
||||
|
||||
public string lexemeBuffer(SSLexMark q_mark) => getSubstring(m_bufferLexemeStart, lexemeLength(q_mark));
|
||||
|
||||
public void SetDocumentOffset(int line, int column)
|
||||
{
|
||||
m_docOriginLine = line;
|
||||
m_docOriginColumn = column;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexFinalState
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexFinalState
|
||||
{
|
||||
private const int m_flagContextStart = 1;
|
||||
private const int m_flagStartOfLine = 2;
|
||||
private const int m_flagPop = 8;
|
||||
private const int m_flagFinal = 16;
|
||||
private const int m_flagPush = 32;
|
||||
private const int m_flagIgnore = 64;
|
||||
private const int m_flagContextEnd = 128;
|
||||
private const int m_flagReduce = 256;
|
||||
private const int m_flagKeyword = 512;
|
||||
private const int m_flagParseToken = 1024;
|
||||
private int m_flags;
|
||||
private int m_token;
|
||||
private int m_pushIndex;
|
||||
|
||||
public SSLexFinalState(int[] q_final, int q_index)
|
||||
{
|
||||
m_token = q_final[q_index];
|
||||
m_pushIndex = q_final[q_index + 1];
|
||||
m_flags = q_final[q_index + 2];
|
||||
}
|
||||
|
||||
public int token() => m_token;
|
||||
|
||||
public int pushIndex() => m_pushIndex;
|
||||
|
||||
public bool isPop() => (m_flags & 8) != 0;
|
||||
|
||||
public bool isPush() => (m_flags & 32) != 0;
|
||||
|
||||
public bool isFinal() => (m_flags & 16) != 0;
|
||||
|
||||
public bool isIgnore() => (m_flags & 64) != 0;
|
||||
|
||||
public bool isReduce() => (m_flags & 256) != 0;
|
||||
|
||||
public bool isContextEnd() => (m_flags & 128) != 0;
|
||||
|
||||
public bool isStartOfLine() => (m_flags & 2) != 0;
|
||||
|
||||
public bool isContextStart() => (m_flags & 1) != 0;
|
||||
|
||||
public bool isKeyword() => (m_flags & 512) != 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexLexeme
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexLexeme
|
||||
{
|
||||
private const string c_TextForEOF = "eof";
|
||||
private int m_token;
|
||||
private int m_length;
|
||||
private int m_line;
|
||||
private int m_column;
|
||||
private int m_start;
|
||||
|
||||
private SSLexLexeme()
|
||||
{
|
||||
m_line = 0;
|
||||
m_token = 0;
|
||||
m_length = 0;
|
||||
m_column = 0;
|
||||
}
|
||||
|
||||
public SSLexLexeme(SSLexConsumer q_consumer)
|
||||
{
|
||||
m_token = 0;
|
||||
m_line = q_consumer.line();
|
||||
m_column = q_consumer.offset();
|
||||
m_length = q_consumer.lexemeLength();
|
||||
m_start = q_consumer.m_bufferLexemeStart;
|
||||
}
|
||||
|
||||
public SSLexLexeme(SSLexConsumer q_consumer, SSLexFinalState q_final, SSLexMark q_mark)
|
||||
{
|
||||
m_token = q_final.token();
|
||||
m_line = q_consumer.line();
|
||||
m_column = q_consumer.offset();
|
||||
m_length = q_consumer.lexemeLength(q_mark);
|
||||
m_start = q_consumer.m_bufferLexemeStart;
|
||||
}
|
||||
|
||||
public int line() => m_line;
|
||||
|
||||
public int token() => m_token;
|
||||
|
||||
public int offset() => m_column;
|
||||
|
||||
public int length() => m_length;
|
||||
|
||||
public string GetValue(SSLex lex) => m_token == -1 ? "eof" : lex.consumer().getSubstring(m_start, m_length);
|
||||
|
||||
public string GetTrimmedValue(SSLex lex, int trimLeft, int trimRight)
|
||||
{
|
||||
int start = m_start + trimLeft;
|
||||
int length = m_length - (trimLeft + trimRight);
|
||||
return lex.consumer().getSubstring(start, length);
|
||||
}
|
||||
|
||||
public static SSLexLexeme CreateEOFLexeme(SSLex lex) => new SSLexLexeme()
|
||||
{
|
||||
m_token = -1,
|
||||
m_line = lex.consumer().line(),
|
||||
m_column = lex.consumer().offset(),
|
||||
m_length = "eof".Length
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexMark
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal struct SSLexMark
|
||||
{
|
||||
public int m_line;
|
||||
public int m_index;
|
||||
public int m_offset;
|
||||
|
||||
public SSLexMark(int q_line, int q_offset, int q_index)
|
||||
{
|
||||
m_index = q_index;
|
||||
m_line = q_line;
|
||||
m_offset = q_offset;
|
||||
}
|
||||
|
||||
public int index() => m_index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexSubtable
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexSubtable
|
||||
{
|
||||
private const int SSLexStateInvalid = -1;
|
||||
private int m_size;
|
||||
private SSLexTableRow[] m_rows;
|
||||
private SSLexFinalState[] m_final;
|
||||
|
||||
public SSLexSubtable(int q_numRows, int[] q_rows, int[] q_final)
|
||||
{
|
||||
m_size = q_numRows;
|
||||
int q_index1 = 0;
|
||||
int q_index2 = 0;
|
||||
m_rows = new SSLexTableRow[m_size];
|
||||
m_final = new SSLexFinalState[m_size];
|
||||
for (int index = 0; index < m_size; ++index)
|
||||
{
|
||||
m_rows[index] = new SSLexTableRow(q_rows, q_index1);
|
||||
m_final[index] = new SSLexFinalState(q_final, q_index2);
|
||||
q_index2 += 3;
|
||||
q_index1 += q_rows[q_index1] * 3 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int lookup(int q_state, int q_next) => m_rows[q_state].lookup(q_next);
|
||||
|
||||
public SSLexFinalState lookupFinal(int q_state) => m_final[q_state];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexTable
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexTable
|
||||
{
|
||||
private const int SSLexTableHeaderSize = 36;
|
||||
private const int SSLexDfaTableHeaderSize = 40;
|
||||
private const int SSLexDfaKeywordTableHeaderSize = 40;
|
||||
private const int SSLexDfaClassTableHeaderSize = 12;
|
||||
private const int SSLexDfaClassTableEntryHeaderSize = 8;
|
||||
public const int SSLexStateInvalid = -1;
|
||||
private Stack m_stack;
|
||||
public SSLexSubtable[] m_subTables;
|
||||
|
||||
public SSLexTable()
|
||||
{
|
||||
m_stack = new Stack();
|
||||
m_subTables = null;
|
||||
}
|
||||
|
||||
public void findKeyword(SSLexLexeme z_lexeme) => throw new Exception("Code has been disabled.");
|
||||
|
||||
public void gotoSubtable(int q_index)
|
||||
{
|
||||
m_stack.Pop();
|
||||
m_stack.Push(m_subTables[q_index]);
|
||||
}
|
||||
|
||||
public void pushSubtable(int q_index) => m_stack.Push(m_subTables[q_index]);
|
||||
|
||||
public void popSubtable() => m_stack.Pop();
|
||||
|
||||
public int lookup(int q_state, int q_next) => ((SSLexSubtable)m_stack.Peek()).lookup(q_state, q_next);
|
||||
|
||||
public SSLexFinalState lookupFinal(int q_state) => ((SSLexSubtable)m_stack.Peek()).lookupFinal(q_state);
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_stack.Clear();
|
||||
pushSubtable(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexTableRow
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexTableRow
|
||||
{
|
||||
private int m_size;
|
||||
private SSLexTableRowEntry[] m_entries;
|
||||
|
||||
public SSLexTableRow(int[] q_row, int q_index)
|
||||
{
|
||||
m_size = q_row[q_index];
|
||||
if (m_size > 0)
|
||||
m_entries = new SSLexTableRowEntry[m_size];
|
||||
++q_index;
|
||||
for (int index = 0; index < m_size; ++index)
|
||||
{
|
||||
m_entries[index] = new SSLexTableRowEntry(q_row[q_index], q_row[q_index + 1], q_row[q_index + 2]);
|
||||
q_index += 3;
|
||||
}
|
||||
}
|
||||
|
||||
public int lookup(int q_code)
|
||||
{
|
||||
for (int index = 0; index < m_size; ++index)
|
||||
{
|
||||
SSLexTableRowEntry entry = m_entries[index];
|
||||
if (q_code < entry.start())
|
||||
return -1;
|
||||
if (q_code <= entry.end())
|
||||
return entry.state();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSLexTableRowEntry
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSLexTableRowEntry
|
||||
{
|
||||
private int m_end;
|
||||
private int m_start;
|
||||
private int m_state;
|
||||
|
||||
public SSLexTableRowEntry(int q_start, int q_end, int q_state)
|
||||
{
|
||||
m_end = q_end;
|
||||
m_start = q_start;
|
||||
m_state = q_state;
|
||||
}
|
||||
|
||||
public int end() => m_end;
|
||||
|
||||
public int start() => m_start;
|
||||
|
||||
public int state() => m_state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYacc
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.Session;
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYacc
|
||||
{
|
||||
private const int SSYaccActionShift = 0;
|
||||
private const int SSYaccActionError = 1;
|
||||
private const int SSYaccActionReduce = 2;
|
||||
private const int SSYaccActionAccept = 3;
|
||||
private const int SSYaccActionConflict = 4;
|
||||
public const int m_eofToken = -1;
|
||||
private const int m_errorToken = -2;
|
||||
private const int SSYaccLexemeCacheMax = -1;
|
||||
private int m_cache;
|
||||
private int m_state;
|
||||
protected SSLex m_lex;
|
||||
private int m_action;
|
||||
private int m_leftside;
|
||||
private bool m_error;
|
||||
private bool m_abort;
|
||||
private int m_production;
|
||||
private SSYaccStack m_stack;
|
||||
private SSYaccTable m_table;
|
||||
private int m_productionSize;
|
||||
private bool m_endOfInput;
|
||||
private SSLexLexeme m_endLexeme;
|
||||
private SSLexLexeme m_lookahead;
|
||||
private SSLexLexeme m_larLookahead;
|
||||
private SSLexSubtable m_lexSubtable;
|
||||
private SSYaccStackElement m_element;
|
||||
private SSYaccStackElement m_treeRoot;
|
||||
private SSYaccCache m_lexemeCache;
|
||||
private SourceMarkupLoader m_owner;
|
||||
private bool m_hasErrors;
|
||||
|
||||
public string FromTerminal(int position) => elementFromProduction(position).lexeme().GetValue(m_lex);
|
||||
|
||||
public string FromTerminalTrim(int position, int trimLeft, int trimRight) => elementFromProduction(position).lexeme().GetTrimmedValue(m_lex, trimLeft, trimRight);
|
||||
|
||||
public object FromProduction(int position) => elementFromProduction(position).Object;
|
||||
|
||||
public SSYaccStackElement ReturnObject(object value)
|
||||
{
|
||||
SSYaccStackElement yaccStackElement = stackElement();
|
||||
yaccStackElement.Object = value;
|
||||
return yaccStackElement;
|
||||
}
|
||||
|
||||
public int Line(int position) => elementFromProduction(position).lexeme().line();
|
||||
|
||||
public int Column(int position) => elementFromProduction(position).lexeme().offset();
|
||||
|
||||
public SSYacc(SSYaccTable q_table, SSLex q_lex)
|
||||
{
|
||||
m_lex = q_lex;
|
||||
m_table = q_table;
|
||||
m_stack = new SSYaccStack(5, 5);
|
||||
m_lexemeCache = new SSYaccCache();
|
||||
Reset(null);
|
||||
}
|
||||
|
||||
public void Reset(SourceMarkupLoader owner)
|
||||
{
|
||||
m_cache = 0;
|
||||
m_abort = false;
|
||||
m_error = false;
|
||||
m_endOfInput = false;
|
||||
m_owner = owner;
|
||||
m_action = 0;
|
||||
m_endOfInput = false;
|
||||
m_hasErrors = false;
|
||||
m_larLookahead = null;
|
||||
m_leftside = 0;
|
||||
m_lexSubtable = null;
|
||||
m_lookahead = null;
|
||||
m_production = 0;
|
||||
m_productionSize = 0;
|
||||
m_state = 0;
|
||||
m_endLexeme = null;
|
||||
m_element = new SSYaccStackElement();
|
||||
m_treeRoot = new SSYaccStackElement();
|
||||
m_stack.Clear();
|
||||
m_lexemeCache.Clear();
|
||||
if (owner == null)
|
||||
return;
|
||||
m_endLexeme = SSLexLexeme.CreateEOFLexeme(m_lex);
|
||||
m_element = stackElement();
|
||||
push();
|
||||
}
|
||||
|
||||
public virtual SSYaccStackElement reduce(int q_prod, int q_length) => stackElement();
|
||||
|
||||
public virtual SSLexLexeme nextLexeme() => m_lex.next();
|
||||
|
||||
public virtual SSYaccStackElement stackElement() => new SSYaccStackElement();
|
||||
|
||||
public virtual SSYaccStackElement shift(SSLexLexeme q_lexeme) => stackElement();
|
||||
|
||||
public bool larLookahead(SSLexLexeme q_lex) => false;
|
||||
|
||||
public virtual bool error(int q_state, SSLexLexeme q_look)
|
||||
{
|
||||
m_hasErrors = true;
|
||||
if (!m_lex.HasErrors)
|
||||
{
|
||||
string str = q_look.GetValue(m_lex);
|
||||
int line = q_look.line();
|
||||
int column = q_look.offset();
|
||||
string message = string.Format("Syntax Error: Unexpected character encountered: '{0}'", str);
|
||||
if (str == "eof")
|
||||
{
|
||||
message = string.Format("Unexpected end of script (script beginning at line {0}, column {1})", line, column);
|
||||
line = m_lex.consumer().line();
|
||||
column = m_lex.consumer().offset();
|
||||
}
|
||||
ErrorManager.ReportError(line, column, message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public SourceMarkupLoader Owner => m_owner;
|
||||
|
||||
public bool HasErrors => m_hasErrors;
|
||||
|
||||
public bool larError(int q_state, SSLexLexeme q_look, SSLexLexeme q_larLook) => error(q_state, q_look);
|
||||
|
||||
public bool parse()
|
||||
{
|
||||
if (doGetLexeme(true))
|
||||
return true;
|
||||
while (!m_abort)
|
||||
{
|
||||
switch (m_action)
|
||||
{
|
||||
case 0:
|
||||
if (doShift())
|
||||
return true;
|
||||
continue;
|
||||
case 1:
|
||||
if (doError())
|
||||
return true;
|
||||
continue;
|
||||
case 2:
|
||||
if (doReduce())
|
||||
return true;
|
||||
continue;
|
||||
case 3:
|
||||
m_treeRoot = m_element;
|
||||
return m_error;
|
||||
case 4:
|
||||
if (doConflict())
|
||||
return true;
|
||||
continue;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool doShift()
|
||||
{
|
||||
m_element = shift(m_lookahead);
|
||||
m_element.setLexeme(m_lookahead);
|
||||
m_element.setState(m_state);
|
||||
push();
|
||||
return doGetLexeme(true);
|
||||
}
|
||||
|
||||
public bool doReduce()
|
||||
{
|
||||
m_element = reduce(m_production, m_productionSize);
|
||||
pop(m_productionSize);
|
||||
return goTo(m_leftside);
|
||||
}
|
||||
|
||||
public bool doError()
|
||||
{
|
||||
m_error = true;
|
||||
return error(m_state, m_lookahead);
|
||||
}
|
||||
|
||||
public bool doLarError()
|
||||
{
|
||||
m_error = true;
|
||||
return larError(m_state, m_lookahead, m_larLookahead);
|
||||
}
|
||||
|
||||
public SSLexLexeme getLexemeCache()
|
||||
{
|
||||
SSLexLexeme ssLexLexeme = null;
|
||||
if (m_cache != -1 && m_lexemeCache.hasElements())
|
||||
ssLexLexeme = (SSLexLexeme)m_lexemeCache.Dequeue();
|
||||
if (ssLexLexeme == null)
|
||||
{
|
||||
m_cache = -1;
|
||||
ssLexLexeme = nextLexeme() ?? m_endLexeme;
|
||||
m_lexemeCache.Enqueue(ssLexLexeme);
|
||||
}
|
||||
return ssLexLexeme;
|
||||
}
|
||||
|
||||
public bool doConflict()
|
||||
{
|
||||
m_cache = 0;
|
||||
int q_state = m_lexSubtable.lookup(0, m_lookahead.token());
|
||||
while ((m_larLookahead = getLexemeCache()) != null)
|
||||
{
|
||||
q_state = m_lexSubtable.lookup(q_state, m_larLookahead.token());
|
||||
if (q_state != -1)
|
||||
{
|
||||
SSLexFinalState ssLexFinalState = m_lexSubtable.lookupFinal(q_state);
|
||||
if (ssLexFinalState.isFinal())
|
||||
{
|
||||
if (ssLexFinalState.isReduce())
|
||||
{
|
||||
m_production = ssLexFinalState.token();
|
||||
SSYaccTableProd ssYaccTableProd = m_table.lookupProd(m_production);
|
||||
m_leftside = ssYaccTableProd.leftside();
|
||||
m_productionSize = ssYaccTableProd.size();
|
||||
return doReduce();
|
||||
}
|
||||
m_state = ssLexFinalState.token();
|
||||
return doShift();
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return doLarError();
|
||||
}
|
||||
|
||||
public bool doGetLexeme(bool q_look)
|
||||
{
|
||||
if ((m_lookahead = m_lexemeCache.remove()) == null)
|
||||
return getLexeme(q_look);
|
||||
if (larLookahead(m_lookahead))
|
||||
return true;
|
||||
if (q_look)
|
||||
lookupAction(m_state, m_lookahead.token());
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool getLexeme(bool q_look)
|
||||
{
|
||||
if (m_endOfInput)
|
||||
return true;
|
||||
m_lookahead = nextLexeme();
|
||||
if (m_lookahead == null)
|
||||
{
|
||||
m_endOfInput = true;
|
||||
m_lookahead = m_endLexeme;
|
||||
}
|
||||
if (q_look)
|
||||
lookupAction(m_state, m_lookahead.token());
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool goTo(int q_goto)
|
||||
{
|
||||
if (lookupGoto(m_state, m_leftside))
|
||||
return true;
|
||||
m_element.setState(m_state);
|
||||
push();
|
||||
lookupAction(m_state, m_lookahead.token());
|
||||
return false;
|
||||
}
|
||||
|
||||
public void lookupAction(int q_state, int q_token)
|
||||
{
|
||||
SSYaccTableRowEntry yaccTableRowEntry = m_table.lookupRow(q_state).lookupAction(q_token);
|
||||
if (yaccTableRowEntry == null)
|
||||
{
|
||||
m_action = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_action = yaccTableRowEntry.action())
|
||||
{
|
||||
case 0:
|
||||
m_state = yaccTableRowEntry.entry();
|
||||
break;
|
||||
case 2:
|
||||
SSYaccTableProd ssYaccTableProd = m_table.lookupProd(yaccTableRowEntry.entry());
|
||||
m_production = yaccTableRowEntry.entry();
|
||||
m_leftside = ssYaccTableProd.leftside();
|
||||
m_productionSize = ssYaccTableProd.size();
|
||||
break;
|
||||
case 4:
|
||||
m_lexSubtable = m_table.larTable(yaccTableRowEntry.entry());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool lookupGoto(int q_state, int q_token)
|
||||
{
|
||||
SSYaccTableRowEntry yaccTableRowEntry = m_table.lookupRow(q_state).lookupGoto(q_token);
|
||||
if (yaccTableRowEntry == null)
|
||||
return true;
|
||||
m_state = yaccTableRowEntry.entry();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool push()
|
||||
{
|
||||
m_stack.push(m_element);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool pop(int q_pop)
|
||||
{
|
||||
for (int index = 0; index < q_pop; ++index)
|
||||
m_stack.pop();
|
||||
m_state = m_stack.peek().state();
|
||||
return false;
|
||||
}
|
||||
|
||||
public SSYaccStackElement elementFromProduction(int q_index) => m_stack.elementAt(m_stack.getSize() - m_productionSize + q_index);
|
||||
|
||||
public SSYaccStackElement treeRoot() => m_treeRoot;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccCache
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccCache : Queue
|
||||
{
|
||||
public bool hasElements() => Count != 0;
|
||||
|
||||
public SSLexLexeme remove()
|
||||
{
|
||||
SSLexLexeme ssLexLexeme = null;
|
||||
if (Count != 0)
|
||||
ssLexLexeme = (SSLexLexeme)Dequeue();
|
||||
return ssLexLexeme;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccStack
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccStack
|
||||
{
|
||||
private Vector<SSYaccStackElement> m_list = new Vector<SSYaccStackElement>();
|
||||
|
||||
public SSYaccStack(int q_size, int q_inc)
|
||||
{
|
||||
}
|
||||
|
||||
public void Clear() => m_list.Clear();
|
||||
|
||||
public void push(SSYaccStackElement q_ele) => m_list.Add(q_ele);
|
||||
|
||||
public void pop() => m_list.RemoveAt(m_list.Count - 1);
|
||||
|
||||
public SSYaccStackElement elementAt(int index) => m_list[index];
|
||||
|
||||
public int getSize() => m_list.Count;
|
||||
|
||||
public SSYaccStackElement peek() => elementAt(m_list.Count - 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccStackElement
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal struct SSYaccStackElement
|
||||
{
|
||||
private int m_state;
|
||||
private SSLexLexeme m_lexeme;
|
||||
private object m_object;
|
||||
|
||||
public int state() => m_state;
|
||||
|
||||
public SSLexLexeme lexeme() => m_lexeme;
|
||||
|
||||
public void setState(int q_state) => m_state = q_state;
|
||||
|
||||
public void setLexeme(SSLexLexeme q_lexeme) => m_lexeme = q_lexeme;
|
||||
|
||||
public object Object
|
||||
{
|
||||
get => m_object;
|
||||
set => m_object = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccTable
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccTable
|
||||
{
|
||||
private const int SSYaccTableHeaderSize = 20;
|
||||
private const int SSYaccTableEntrySize = 8;
|
||||
private const int SSYaccTableRowSize = 12;
|
||||
protected SSYaccTableRow[] m_rows;
|
||||
protected SSYaccTableProd[] m_prods;
|
||||
private SSLexSubtable[] m_lexSubtables;
|
||||
|
||||
public SSYaccTable() => m_lexSubtables = null;
|
||||
|
||||
public SSYaccTableRow lookupRow(int q_state) => m_rows[q_state];
|
||||
|
||||
public SSYaccTableProd lookupProd(int q_index) => m_prods[q_index];
|
||||
|
||||
public SSLexSubtable larTable(int q_entry) => m_lexSubtables[q_entry];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccTableProd
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccTableProd
|
||||
{
|
||||
private int m_size;
|
||||
private int m_leftside;
|
||||
|
||||
public SSYaccTableProd(int q_size, int q_leftside)
|
||||
{
|
||||
m_size = q_size;
|
||||
m_leftside = q_leftside;
|
||||
}
|
||||
|
||||
public int size() => m_size;
|
||||
|
||||
public int leftside() => m_leftside;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccTableRow
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccTableRow
|
||||
{
|
||||
private const int SSYaccTableEntrySize = 8;
|
||||
private const int SSYaccTableRowFlagSync = 1;
|
||||
private const int SSYaccTableRowFlagError = 2;
|
||||
private const int SSYaccTableRowFlagSyncAll = 4;
|
||||
private int m_goto;
|
||||
private int m_action;
|
||||
private bool m_sync;
|
||||
private bool m_error;
|
||||
private bool m_syncAll;
|
||||
private SSYaccTableRowEntry[] m_entries;
|
||||
|
||||
public SSYaccTableRow(int[] q_data, int q_index)
|
||||
{
|
||||
m_action = q_data[q_index];
|
||||
m_goto = q_data[q_index + 1];
|
||||
m_error = q_data[q_index + 2] != 0;
|
||||
m_syncAll = q_data[q_index + 3] != 0;
|
||||
m_sync = q_data[q_index + 4] != 0;
|
||||
m_entries = new SSYaccTableRowEntry[numEntries()];
|
||||
q_index += 5;
|
||||
for (int index = 0; index < numEntries(); ++index)
|
||||
{
|
||||
m_entries[index] = new SSYaccTableRowEntry(q_data[q_index], q_data[q_index + 1], q_data[q_index + 2], q_data[q_index + 3]);
|
||||
q_index += 4;
|
||||
}
|
||||
}
|
||||
|
||||
public SSYaccTableRowEntry lookupAction(int q_index)
|
||||
{
|
||||
for (int index = 0; index < m_action; ++index)
|
||||
{
|
||||
if (m_entries[index].token() == q_index)
|
||||
return m_entries[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SSYaccTableRowEntry lookupGoto(int q_index)
|
||||
{
|
||||
for (int action = m_action; action < m_action + m_goto; ++action)
|
||||
{
|
||||
if (m_entries[action].token() == q_index)
|
||||
return m_entries[action];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool hasError() => m_error;
|
||||
|
||||
public int numEntries() => m_goto + m_action + (hasError() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: SSVParseLib.SSYaccTableRowEntry
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace SSVParseLib
|
||||
{
|
||||
internal class SSYaccTableRowEntry
|
||||
{
|
||||
private const int SSYaccActionShift = 0;
|
||||
private const int SSYaccActionError = 1;
|
||||
private const int SSYaccActionReduce = 2;
|
||||
private const int SSYaccActionAccept = 3;
|
||||
private const int SSYaccActionConflict = 4;
|
||||
private const uint SSYaccTableEntryFlagSync = 2147483648;
|
||||
private const int SSYaccTableEntryFlagShift = 1073741824;
|
||||
private const int SSYaccTableEntryFlagReduce = 536870912;
|
||||
private const int SSYaccTableEntryFlagAccept = 268435456;
|
||||
private const int SSYaccTableEntryFlagConflict = 134217728;
|
||||
private const uint SSYaccTableEntryFlagMask = 4160749568;
|
||||
private int m_token;
|
||||
private int m_entry;
|
||||
private int m_action;
|
||||
private bool m_sync;
|
||||
|
||||
public SSYaccTableRowEntry(int q_token, int q_entry, int q_action, int q_sync)
|
||||
{
|
||||
m_token = q_token;
|
||||
m_entry = q_entry;
|
||||
m_action = q_action;
|
||||
m_sync = q_sync != 0;
|
||||
}
|
||||
|
||||
public int action() => m_action;
|
||||
|
||||
public int entry() => m_entry;
|
||||
|
||||
public int token() => m_token;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user