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; }
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); }
public void Accept(KeywordArgumentList kwargs) { kwargs.Visit (functionCompiler); }
public override void Accept (KeywordArgumentList kwargs) { kwargs.Visit (parentVisitor); }
public virtual void Accept(KeywordArgumentList kwargs) { }
public void Accept(KeywordArgumentList kwargs) { kwargs.VisitChildren (this); }