public FreshScript(string fileName, IScriptReader parent) { this.parent = parent; lines = new List<string>(); functions = new List<FreshScriptFunction>(); localVariables = new VariableLibrary(caseSensitive); activeVariableLibrary = localVariables; //test code string testLine = "var tezt = \"Game 1 (testing)\" && (yeah && test);"; string variableName, operation, valueString; if (ParseVariableLineForFirstOperation(testLine, out variableName, out operation, out valueString)) { } //int x =0; //int y = 1; //y+ +; //end test code lines = LoadFile(fileName, 0); OutputLinesForDebug(fileName + ".txt"); ProcessBaseLines(); }
public FreshScriptFunction(string name, int paramaterCount, int start, int end, bool caseSensitiveVaraibles) : base(start, end) { this.name = name; this.paramaterCount = paramaterCount; variables = new VariableLibrary(caseSensitiveVaraibles); }
private void ProcessVariableDefinition(string line, VariableLibrary variableLibrary) { string variableName, operation, value; if (ParseVariableLineForFirstOperation(line, out variableName, out operation, out value)) { if (operation == "=") { //create variable - this also checks for existing variable by same name Variable v = variableLibrary.CreateVariable(variableName); if (operation == "=") { Variable calculatedValue = CalculateValue(value); //set value variableLibrary.SetValue(variableName, calculatedValue.GetValueSaveString()); } } } }
private void ProcessCodeBlock(FreshScriptCodeBlock codeBlock) { VariableLibrary preVariables = activeVariableLibrary; //set current variable library to the function's library if (codeBlock is FreshScriptFunction) { //activeVariableLibrary = ((FreshScriptFunction)codeBlock).Variables; //XXX add variable library stack so code can acces variable defined it 1 up scope //TODO optomize this - should have a variable librabry pool - and variable pool activeVariableLibrary = new VariableLibrary(caseSensitive); } for (int lineNo = codeBlock.StartLine; lineNo <= codeBlock.EndLine; lineNo++) { string line = lines[lineNo]; ProcessLine(line); } activeVariableLibrary = preVariables; }
public void LoadSettings(VariableLibrary vars) { //collectables //vars.GetVariable("scorePerRing", ref scorePerRing, true); }
public VariablesFile(IScriptReader parent, bool caseSensetiveVaraibleNames) { this.parent = parent; lines = new List<ScriptLine>(); variables = new VariableLibrary(caseSensetiveVaraibleNames); }