Ejemplo n.º 1
0
        private static AstNode ParseArgumentList(TokenStream stream)
        {
            ArgumentList argList = new ArgumentList (stream.Location);
            stream.Expect (TokenClass.OpenParan);
            KeywordArgumentList kwargs = null;
            while (!stream.Match (TokenClass.CloseParan)) {
                if (stream.Accept (TokenClass.Operator, "*")) {
                    argList.Packed = true;
                    argList.Add (ParseExpression (stream));
                    break;
                }
                AstNode arg = ParseExpression (stream);
                if (stream.Accept (TokenClass.Colon)) {
                    if (kwargs == null) {
                        kwargs = new KeywordArgumentList (arg.Location);
                    }
                    NameExpression ident = arg as NameExpression;
                    AstNode val = ParseExpression (stream);
                    if (ident == null) {
                        stream.ErrorLog.AddError (ErrorType.ParserError, arg.Location,
                            "Keyword must be a valid identifier");
                    } else {
                        kwargs.Add (ident.Value, val);
                    }
                } else
                    argList.Add (arg);
                if (!stream.Accept (TokenClass.Comma)) {
                    break;
                }

            }
            if (kwargs != null) {
                argList.Add (kwargs);
            }
            stream.Expect (TokenClass.CloseParan);
            return argList;
        }
Ejemplo n.º 2
0
		public override void Accept (KeywordArgumentList kwargs)
		{
			for (int i = 0; i < kwargs.Keywords.Count; i++) {
				string kw = kwargs.Keywords [i];
				AstNode val = kwargs.Children [i];
				methodBuilder.EmitInstruction (kwargs.Location, Opcode.LoadConst, methodBuilder.Module.DefineConstant (
					new IodineString (kw)));
				val.Visit (this);
				methodBuilder.EmitInstruction (kwargs.Location, Opcode.BuildTuple, 2);
			}
			methodBuilder.EmitInstruction (kwargs.Location, Opcode.BuildList, kwargs.Keywords.Count);
			methodBuilder.EmitInstruction (kwargs.Location, Opcode.LoadGlobal, methodBuilder.Module.DefineConstant (
				new IodineName ("HashMap")));
			methodBuilder.EmitInstruction (kwargs.Location, Opcode.Invoke, 1);
		}
Ejemplo n.º 3
0
 public void Accept(KeywordArgumentList kwargs)
 {
     kwargs.Visit (functionCompiler);
 }
Ejemplo n.º 4
0
		public override void Accept (KeywordArgumentList kwargs)
		{
			kwargs.Visit (parentVisitor);
		}
Ejemplo n.º 5
0
 public virtual void Accept(KeywordArgumentList kwargs)
 {
 }
Ejemplo n.º 6
0
 public void Accept(KeywordArgumentList kwargs)
 {
     kwargs.VisitChildren (this);
 }