/// <summary> /// スクリプトを実行します。 /// (再帰用) /// </summary> internal object Eval(string script) { var ana = new TextAnalyzer(script, "script eval"); ana.Analyze(); TokenUtility.Check(ana.Tokens); var rpn = TokenUtility.ToRPN(ana.Tokens); var ret = Ride(rpn); if (ret is ReturnedObject) { ret = (ret as ReturnedObject).Value; } return(ret); }
//関数定義内解析 private List <Token> _ANA_Function_ReadBlock(string subBlockName) { var ana = new TextAnalyzer(src, subBlockName, position, 1); var subs = new List <Token>(); while (true) { Token t = ana.Next(); if (t == null) { throw new KarinException("ブロックが閉じられていません。"); } if (t.Type == TokenType.Other && t.Text == "}") { break; } subs.Add(t); } position = ana.position; line += ana.line - 1; return(subs); }
//関数引数解析 private List <Token>[] _ANA_Function_ReadArgs() { var args = new List <List <Token> >(); while (true) { var ana = new TextAnalyzer(src, BlockName, position, line); var arg = new List <Token>(); Token t; while (true) { t = ana.Next(); if (t == null) { throw new KarinException("引数が閉じられていません。"); } if (t.Type == TokenType.Other && (t.Text == "," || t.Text == "]")) { break; } arg.Add(t); } position = ana.position; //line += ana.line-1; line = ana.line; args.Add(arg); if (t.Text == "]") { break; } } return(args.ToArray()); }