ScriptStack 1.0.0
A .NET scripting language
Lade ...
Suche ...
Keine Treffer
ScriptStack.Runtime.Script Klassenreferenz

Internal representation of a text file (source code) which can be passed to the Interpreter to execute it. Mehr ...

Öffentliche Methoden

 Script (Manager manager, string scriptName)
 
bool EntryPoint ()
 

Propertys

Manager Manager [get]
 
string Name [get]
 
ReadOnlyCollection< String > SourceLines [get]
 
string Source [get]
 
Executable Executable [get]
 
Memory ScriptMemory [get]
 
ScriptStack.Collections.ReadOnlyDictionary< String, FunctionFunctions [get]
 
Function MainFunction [get]
 

Private Methoden

void Scan (string scriptName)
 

Private Attribute

Manager manager
 
String scriptName
 
List< String > sourceCode
 
Executable executable
 

Ausführliche Beschreibung

Internal representation of a text file (source code) which can be passed to the Interpreter to execute it.

Beschreibung der Konstruktoren und Destruktoren

◆ Script()

ScriptStack.Runtime.Script.Script ( Manager manager,
string scriptName )
102 {
103
104 this.manager = manager;
105
106 this.scriptName = scriptName;
107
108 try
109 {
110
112
114
115 List<Token> tokenStream = lexer.GetTokens();
116
117 Parser parser = new Parser(this, tokenStream);
118
119 parser.DebugMode = this.manager.Debug;
120
121 executable = parser.Parse();
122
123
124 if (this.manager.Optimize)
125 {
126
127 Optimizer optimizer = new Optimizer(executable);
128
129 optimizer.OptimizerInfo = false;
130
131 optimizer.Optimize();
132
133 }
134
135
136 }
137 catch (Exception exception)
138 {
139 throw new ScriptStackException("Fehler in '" + scriptName + "'.", exception);
140 }
141
142 }
Definition ReadOnlyDictionary.cs:19
The lexical analyzer (Lexer) breaks code (written in sentences) into a series of known Token and pass...
Definition Lexer.cs:21
The parser builds an ScriptStack.Runtime.Executable out of the Token stream returned from the ScriptS...
Definition Parser.cs:22
Executable Parse()
Parse the token stream into an executable.
Definition Parser.cs:3092
bool Optimize
Definition Manager.cs:256
bool Debug
Definition Manager.cs:250
List< String > sourceCode
Definition Script.cs:23
void Scan(string scriptName)
Definition Script.cs:30
Manager manager
Definition Script.cs:21
Executable executable
Definition Script.cs:24
String scriptName
Definition Script.cs:22
Definition ScriptStackException.cs:9

Benutzt ScriptStack.Manager.Debug, ScriptStack.Runtime.Script.executable, ScriptStack.Runtime.Script.manager, ScriptStack.Manager.Optimize, ScriptStack.Runtime.Script.Scan(), ScriptStack.Runtime.Script.scriptName und ScriptStack.Runtime.Script.sourceCode.

Dokumentation der Elementfunktionen

◆ EntryPoint()

bool ScriptStack.Runtime.Script.EntryPoint ( )
145 {
146 return executable.FunctionExists("main");
147 }
bool FunctionExists(string function)
Definition Executable.cs:115

Benutzt ScriptStack.Runtime.Script.executable und ScriptStack.Runtime.Executable.FunctionExists().

◆ Scan()

void ScriptStack.Runtime.Script.Scan ( string scriptName)
private
31 {
32
33 Scanner scanner = manager.Scanner;
34 sourceCode = scanner.Scan(scriptName);
35 sourceCode.Add(" ");
36
38
39 for (int i = 0; i < sourceCode.Count; i++)
40 {
41
42 string line = sourceCode[i];
43
44 Lexer lexer = new Lexer(new List<string> { line });
45
46 List<Token> tokenStream = null;
47
48 try
49 {
50 tokenStream = lexer.GetTokens();
51 }
52 catch (Exception)
53 {
54 continue;
55 }
56
57 if (tokenStream.Count == 0)
58 continue;
59
60 if (tokenStream[0].Type != TokenType.Include)
61 continue;
62
63 if (tokenStream.Count < 2)
64 throw new ParserException("Include Statement ohne Pfadangabe.");
65
66 if (tokenStream[1].Type != TokenType.String)
67 throw new ParserException("Nach einem 'include' Befehl wird ein String (Pfad) erwartet.");
68
69 if (tokenStream.Count < 3)
70 throw new ParserException("Semicolon ';' am Ende eines 'include' Statement erwartet.");
71
72 if (tokenStream[2].Type != TokenType.SemiColon)
73 throw new ParserException("Semicolon ';' am Ende eines 'include' Statement erwartet.");
74
75 if (tokenStream.Count > 3)
76 throw new ParserException("Es wird nichts nach dem Semicolon ';' am Ende eines 'include' Statement erwartet.");
77
78 string include = (string)tokenStream[1].Lexeme;
79
80 sourceCode.RemoveAt(i);
81
83 continue;
84
85 /* and place the source where the original include statement was.. */
86 sourceCode.InsertRange(i, scanner.Scan(include));
87
88 /* set the current script as already included */
89 included[include] = true;
90
91 --i;
92
93 }
94
95 }
int Count
Definition ReadOnlyDictionary.cs:155
void Add(TKey key, TValue value)
Definition ReadOnlyDictionary.cs:66
bool ContainsKey(TKey key)
Definition ReadOnlyDictionary.cs:69
Definition ParserException.cs:11
Scanner Scanner
A Scanner reference.
Definition Manager.cs:232
An interface to modify the default process of reading text files into Script's.
Definition Scanner.cs:116
List< String > Scan(String strResourceName)
TokenType
Known types of Token.
Definition Token.cs:12

Benutzt ScriptStack.Collections.ReadOnlyDictionary< TKey, TValue >.Add(), ScriptStack.Collections.ReadOnlyDictionary< TKey, TValue >.ContainsKey(), ScriptStack.Collections.ReadOnlyDictionary< TKey, TValue >.Count, ScriptStack.Runtime.Script.manager, ScriptStack.Compiler.Scanner.Scan(), ScriptStack.Manager.Scanner, ScriptStack.Runtime.Script.scriptName und ScriptStack.Runtime.Script.sourceCode.

Wird benutzt von ScriptStack.Runtime.Script.Script().

Dokumentation der Datenelemente

◆ executable

Executable ScriptStack.Runtime.Script.executable
private

◆ manager

Manager ScriptStack.Runtime.Script.manager
private

◆ scriptName

String ScriptStack.Runtime.Script.scriptName
private

◆ sourceCode

List<String> ScriptStack.Runtime.Script.sourceCode
private

Dokumentation der Propertys

◆ Executable

Executable ScriptStack.Runtime.Script.Executable
get
183 {
184 get { return executable; }
185 }

Wird benutzt von ScriptStack.Runtime.Interpreter.Interpreter().

◆ Functions

ScriptStack.Collections.ReadOnlyDictionary<String, Function> ScriptStack.Runtime.Script.Functions
get
193 {
194 get
195 {
197 }
198 }
Dictionary< String, Function > Functions
Definition Executable.cs:137
A function, forward declared in a script.
Definition Function.cs:15
Definition ReadOnlyDictionary.cs:8
Definition ReadOnlyDictionary.cs:8

◆ MainFunction

Function ScriptStack.Runtime.Script.MainFunction
get
201 {
202 get { return executable.MainFunction; }
203 }
Function MainFunction
Definition Executable.cs:142

◆ Manager

◆ Name

string ScriptStack.Runtime.Script.Name
get
159 {
160 get { return scriptName; }
161 }

◆ ScriptMemory

Memory ScriptStack.Runtime.Script.ScriptMemory
get
188 {
189 get { return executable.ScriptMemory; }
190 }
Memory ScriptMemory
Definition Executable.cs:157

◆ Source

string ScriptStack.Runtime.Script.Source
get
169 {
170 get
171 {
173 foreach (string line in sourceCode)
174 {
175 sb.Append(line);
176 sb.Append("\r\n");
177 }
178 return sb.ToString();
179 }
180 }

◆ SourceLines

ReadOnlyCollection<String> ScriptStack.Runtime.Script.SourceLines
get
164 {
165 get { return sourceCode.AsReadOnly(); }
166 }
static ReadOnlyDictionary< TKey, TValue > AsReadOnly(IDictionary< TKey, TValue > dictionaryToWrap)
Definition ReadOnlyDictionary.cs:62

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: