EP Symbolization 重构line-word-index
This commit is contained in:
@@ -17,10 +17,15 @@ namespace Convention.Symbolization
|
||||
private readonly SymbolizationContext ParentContext;
|
||||
public readonly Internal.Namespace CurrentNamespace;
|
||||
|
||||
private void Compile(Internal.SymbolizationReader reader)
|
||||
{
|
||||
reader.CompleteScopeWord(this);
|
||||
}
|
||||
|
||||
public void Compile(Dictionary<int, Dictionary<int, Internal.Variable>> scriptWords)
|
||||
{
|
||||
new Internal.SymbolizationReader() { ScriptWords = scriptWords }.CompleteScopeWord(this);
|
||||
// Turn the script words into scope words
|
||||
Compile(new Internal.SymbolizationReader() { ScriptWords = scriptWords });
|
||||
}
|
||||
|
||||
public void Compile(string allText)
|
||||
@@ -29,9 +34,8 @@ namespace Convention.Symbolization
|
||||
Internal.SymbolizationReader reader = new();
|
||||
foreach (char ch in allText)
|
||||
reader.ReadChar(ch);
|
||||
var scriptWords = reader.ScriptWords;
|
||||
// Turn the script words into scope words
|
||||
reader.CompleteScopeWord(this);
|
||||
Compile(reader);
|
||||
}
|
||||
|
||||
public void Compile(ToolFile file)
|
||||
|
@@ -106,7 +106,7 @@ namespace Convention.Symbolization.Internal
|
||||
|
||||
#region Read Scope Words
|
||||
|
||||
private class KeywordEntry
|
||||
public class KeywordEntry
|
||||
{
|
||||
public int line = 1;
|
||||
public int wordIndex = 1;
|
||||
@@ -118,10 +118,9 @@ namespace Convention.Symbolization.Internal
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<Keyword, KeywordEntry> ScopeWords = new();
|
||||
|
||||
public void CompleteScopeWord(SymbolizationContext rootContext)
|
||||
{
|
||||
Dictionary<Keyword, KeywordEntry> ScopeWords = new();
|
||||
Keyword currentKey = null;
|
||||
bool isNextKeyword = true;
|
||||
foreach(var line in ScriptWords)
|
||||
@@ -139,7 +138,7 @@ namespace Convention.Symbolization.Internal
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidGrammarException($"Line {line.Key}, word {wordCounter}: Expected a keyword, but got {word.Value}");
|
||||
throw new InvalidGrammarException($"Line {line.Key}, Word {wordCounter}: Expected a keyword, but got {word.Value}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user