AssignNode MakeDictAssign(DictGetNode n, ExprNode n1, Lexer.TokenType op, Lexer.Position pos) { if (op == Lexer.TokenType.TOK_ASSIGN) { return(new AsgDictNode(n.Left, n.Right, n1, pos)); } switch (op) { case Lexer.TokenType.TOK_PLUS: case Lexer.TokenType.TOK_MINUS: case Lexer.TokenType.TOK_MUL: case Lexer.TokenType.TOK_DIV: case Lexer.TokenType.TOK_MOD: case Lexer.TokenType.TOK_SHL: case Lexer.TokenType.TOK_SHR: //case Lexer.TokenType.TOK_NOTAR: case Lexer.TokenType.TOK_AND: case Lexer.TokenType.TOK_OR: case Lexer.TokenType.TOK_XOR: case Lexer.TokenType.TOK_PLUSPLUS: case Lexer.TokenType.TOK_MINUSMINUS: case Lexer.TokenType.FTOK_PLUSPLUS_PREF: case Lexer.TokenType.FTOK_MINUSMINUS_PREF: return(new AsgArifmDictNode(n.Left, n.Right, n1, op, pos)); } throw new ParserException("Can't assign to " + n.OpType, pos); }
ExprNode Expr_P() { var n = Term(); while (Lexer.Token == Lexer.TokenType.TOK_LSB || Lexer.Token == Lexer.TokenType.TOK_LPAR || Lexer.Token == Lexer.TokenType.TOK_DOT) { var pos = Lexer.Describe(); if (Lexer.Token == Lexer.TokenType.TOK_LSB) { Lexer.NextToken(); var n1 = Expr(); if (Lexer.Token != Lexer.TokenType.TOK_RSB) { throw new ParserException("] expected", Lexer.Describe()); } n = new DictGetNode(n, n1, pos); Lexer.NextToken(); } else if (Lexer.Token == Lexer.TokenType.TOK_DOT) { var pos2 = Lexer.Describe(); Lexer.NextToken(); if (Lexer.Token != Lexer.TokenType.TOK_ID) { throw new ParserException("Identifier expected", Lexer.Describe()); } var field = Lexer.Ident.ToString(); n = new DictGetNode(n, new StringNode(field, pos2), pos); Lexer.NextToken(); } else { var n1 = ParenExpr(); n = new CallNode(n, n1, pos); } } return(n); }