// Translation public void AddTranslation(NameValueCollection languageDictionary, string originalName) { string translation = languageDictionary[originalName]; if (string.IsNullOrWhiteSpace(translation)) { // Преводът не е предвиден за тази функция. return; } if (translation.IndexOfAny((" \t\r\n").ToCharArray()) >= 0) { throw new ArgumentException("Превод на [" + translation + "] съдържа бели полета"); } ParserFunction originalFunction = ParserFunction.GetFunction(originalName); ParserFunction.AddGlobal(translation, originalFunction); // Ако списъкът с функции, след които може да има интервал (освен скоби) // съдържа оригиналната функция, също добавете превод към списъка. if (Constants.FUNCT_WITH_SPACE.Contains(originalName)) { Constants.FUNCT_WITH_SPACE.Add(translation); } }
public void Init() { ParserFunction.AddGlobal(Constants.IF, new IfStatement(this)); ParserFunction.AddGlobal(Constants.WHILE, new WhileStatement(this)); ParserFunction.AddGlobal(Constants.BREAK, new BreakStatement()); ParserFunction.AddGlobal(Constants.CONTINUE, new ContinueStatement()); ParserFunction.AddGlobal(Constants.RETURN, new ReturnStatement()); ParserFunction.AddGlobal(Constants.FUNCTION, new FunctionCreator(this)); ParserFunction.AddGlobal(Constants.INCLUDE, new IncludeFile()); ParserFunction.AddGlobal(Constants.SIZE, new SizeFunction()); ParserFunction.AddGlobal(Constants.WRITE, new PrintFunction(this, false)); ParserFunction.AddGlobal(Constants.WRITELN, new PrintFunction(this, true)); ParserFunction.AddAction(Constants.ASSIGNMENT, new AssignFunction()); ParserFunction.AddAction(Constants.INCREMENT, new IncrementDecrementFunction()); ParserFunction.AddAction(Constants.DECREMENT, new IncrementDecrementFunction()); for (int i = 0; i < Constants.OPER_ACTIONS.Length; i++) { ParserFunction.AddAction(Constants.OPER_ACTIONS[i], new OperatorAssignFunction()); } Constants.ELSE_LIST.Add(Constants.ELSE); Constants.ELSE_IF_LIST.Add(Constants.ELSE_IF); ReadConfig(); }
public void Init() { if (m_bHasBeenInitialized) { return; } m_bHasBeenInitialized = true; // making sure the init gets call only once RegisterFunctions(); RegisterEnums(); RegisterActions(); ParserFunction.AddGlobal(Constants.THIS, new GetVarFunction(new Variable(Variable.VarType.ARRAY))); InitStandalone(); CompiledClass.Init(); }
protected override Variable Evaluate(string data, ref int from) { string funcName = Utils.GetToken(data, ref from, Constants.TOKEN_SEPARATION); _interpreter.AppendOutput("Registering function " + funcName + "()"); string[] args = Utils.GetFunctionSignature(data, ref from); if (args.Length == 1 && string.IsNullOrWhiteSpace(args[0])) { args = new string[0]; } Utils.MoveForwardIf(data, ref from, Constants.START_GROUP, Constants.SPACE); string body = Utils.GetBodyBetween(data, ref from, Constants.START_GROUP, Constants.END_GROUP); CustomFunction customFunc = new CustomFunction(funcName, body, args); ParserFunction.AddGlobal(funcName, customFunc); return(new Variable(funcName)); }