newExpr2() 공개 메소드

public newExpr2 ( Context ctx, IList tls, int s, int e ) : KonohaExpr
ctx Context
tls IList
s int
e int
리턴 KonohaExpr
예제 #1
0
 // static KMETHOD ParseExpr_Parenthesis(CTX, ksfp_t *sfp _RIX)
 private static KonohaExpr ParseExpr_Parenthesis(Context ctx, Syntax syn, KStatement stmt, IList<Token> tls, int s, int c, int e)
 {
     Token tk = tls[c];
     if(s == c) {
         KonohaExpr expr = stmt.newExpr2(ctx, tk.Sub, 0, tk.Sub.Count);
         return KModSugar.Expr_rightJoin(ctx, expr, stmt, tls, s + 1, c + 1, e);
     }
     else {
         KonohaExpr lexpr = stmt.newExpr2(ctx, tls, s, c);
         if(lexpr == null) {
             return null;
         }
         if (lexpr.syn == null)
         {
             lexpr.syn = stmt.ks.GetSyntax(lexpr.tk.Keyword);
         }
         if(lexpr.syn.KeyWord == KeywordType.DOT) {
             lexpr.syn = stmt.ks.GetSyntax(KeywordType.ExprMethodCall); // CALL
         }
         else if(lexpr.syn.KeyWord != KeywordType.ExprMethodCall) {
             Console.WriteLine("function calls  .. ");
             syn = stmt.ks.GetSyntax(KeywordType.Parenthesis);    // (f null ())
             lexpr  = new ConsExpr(ctx, syn, lexpr, null);
         }
         stmt.addExprParams(ctx, lexpr, tk.Sub, 0, tk.Sub.Count, true/*allowEmpty*/);
         return KModSugar.Expr_rightJoin(ctx, lexpr, stmt, tls, s + 1, c + 1, e);
     }
 }
예제 #2
0
 public static int ParseStmt_Expr(Context ctx, KStatement stmt, Syntax syn, Symbol name, IList<Token> tls, int s, int e)
 {
     int r = -1;
     var expr = stmt.newExpr2(ctx, tls, s, e);
     if (expr != null)
     {
         //dumpExpr(_ctx, 0, 0, expr);
         //kObject_setObject(stmt, name, expr);
         stmt.map.Add(name, expr);
         r = e;
     }
     return r;
 }
예제 #3
0
 private static KonohaExpr ParseExpr_Dot(Context ctx, Syntax syn, KStatement stmt, IList<Token> tls, int s, int c, int e)
 {
     Console.WriteLine("s={0}, c={1}", s, c);
     Debug.Assert(s < c);
     if (isFieldName(tls, c, e))
     {
         KonohaExpr expr = stmt.newExpr2(ctx, tls, s, c);
         expr = new ConsExpr(ctx, syn, tls[c + 1], expr);
         return KModSugar.Expr_rightJoin(ctx, expr, stmt, tls, c + 2, c + 2, e);
     }
     if (c + 1 < e) c++;
     return new ConsExpr(ctx, syn, tls[c], ReportLevel.ERR, "expected field name: not " + tls[c].Text);
 }
예제 #4
0
파일: Context.cs 프로젝트: tetsurom/ikonoha
 // static KMETHOD ParseExpr_Op(CTX, ksfp_t *sfp _RIX)
 public static KonohaExpr ParseExpr_Op(Context ctx, Syntax syn, KStatement stmt, IList<Token> tls, int s, int c, int e)
 {
     Token tk = tls[c];
     KonohaExpr expr = null;
     KonohaExpr rexpr = stmt.newExpr2(ctx, tls, c + 1, e);
     KMethod mn = (s == c) ? syn.Op1 : syn.Op2;
     if (mn != null && syn.ExprTyCheck == ctx.kmodsugar.UndefinedExprTyCheck)
     {
         //kToken_setmn(tk, mn, (s == c) ? MNTYPE_unary: MNTYPE_binary);
         syn = stmt.ks.GetSyntax(KeywordType.ExprMethodCall);  // switch type checker
     }
     if (s == c)
     { // unary operator
         expr = new ConsExpr(ctx, syn, tk, rexpr);
     }
     else
     {   // binary operator
         KonohaExpr lexpr = stmt.newExpr2(ctx, tls, s, c);
         expr = new ConsExpr(ctx, syn, tk, lexpr, rexpr);
     }
     return expr;
 }