Example #1
0
 public CallExpression(TextPosition tp, Element acs, TupleLiteral args)
     : base(tp)
 {
     Access = acs;
     Arguments = args;
     AppendChild(Access);
     AppendChild(Arguments);
 }
 public TemplateInstanceExpression(TextPosition tp, Element acs, TupleLiteral args)
     : base(tp)
 {
     Access = acs;
     DecParameters = args;
     AppendChild(Access);
     AppendChild(DecParameters);
 }
 public VariantDeclaration(TextPosition tp, VariantType type, string name, TupleLiteral attr, Element expli, Element def = null)
     : base(tp, type, def)
 {
     Name = name;
     AttributeAccess = attr;
     ExplicitType = expli;
     AppendChild(AttributeAccess);
     AppendChild(ExplicitType);
 }
 public EnumDeclaration(TextPosition tp, string name, TupleLiteral attr, TupleLiteral generic, Element expli, ProgramContext block)
     : base(tp, name, block)
 {
     AttributeAccess = attr;
     DecGenerics = generic;
     ExplicitBaseType = expli;
     AppendChild(AttributeAccess);
     AppendChild(DecGenerics);
     AppendChild(ExplicitBaseType);
 }
 public ClassDeclaration(TextPosition tp, string name, ClassType type, TupleLiteral attr, TupleLiteral generic, TupleLiteral inherit, ProgramContext block)
     : base(tp, name, type, block)
 {
     AttributeAccess = attr;
     DecGenerics = generic;
     InheritAccess = inherit;
     AppendChild(AttributeAccess);
     AppendChild(DecGenerics);
     AppendChild(InheritAccess);
 }
 public RoutineDeclaration(TextPosition tp, string name, RoutineType type, TokenType opType, TupleLiteral attr, TupleLiteral generic, TupleLiteral args, Element expli, ProgramContext block)
     : base(tp, name, type, opType, block)
 {
     AttributeAccess = attr;
     DecGenerics = generic;
     DecArguments = args;
     ExplicitType = expli;
     AppendChild(AttributeAccess);
     AppendChild(DecGenerics);
     AppendChild(DecArguments);
     AppendChild(ExplicitType);
 }
Example #7
0
 protected CallExpression(TextPosition tp, Element acs, Element arg)
     : base(tp)
 {
     Access = acs;
     if (arg is TupleLiteral)
     {
         Arguments = (TupleLiteral)arg;
     }
     else
     {
         Arguments = new TupleLiteral(arg.Position, arg);
     }
     AppendChild(Access);
     AppendChild(Arguments);
 }
 private static void ArgumentPart(SlimChainParser cp, out VariantType type, out string name, out TupleLiteral attr, out Element expli)
 {
     var ty = VariantType.Var;
     var n = string.Empty;
     TupleLiteral a = null;
     Element ex = null;
     cp.Transfer(e => a = e, AttributeList)
         .Opt.Any(
             icp => icp.Text("var").Self(() => ty = VariantType.Var),
             icp => icp.Text("let").Self(() => ty = VariantType.Let),
             icp => icp.Text("const").Self(() => ty = VariantType.Const)
         ).Lt()
         .Type(t => n = t.Text, TokenType.LetterStartString).Lt()
         .If(icp => icp.Type(TokenType.Pair).Lt())
         .Then(icp => icp.Transfer(e => ex = e, Prefix));
     type = ty;
     name = n;
     attr = a;
     expli = ex;
 }
 private static Element TemplateInstance(Element current, SlimChainParser cp)
 {
     TupleLiteral args = null;
     var ret = cp.Begin
         .Type(TokenType.Template)
         .Not.Transfer(null, RangeLiteral)
         .If(icp => icp.Type(TokenType.LeftParenthesis).Lt())
         .Then(icp =>
         {
             icp.Transfer(e => args = e, TupleLiteral)
             .Type(TokenType.RightParenthesis).Lt();
         })
         .ElseIf(icp => icp.Type(TokenType.LeftBracket).Lt())
         .Then(icp =>
         {
             icp.Transfer(e => args = e, TupleLiteral)
             .Type(TokenType.RightBracket).Lt();
         })
         .Else(icp => icp.Transfer(e => args = new TupleLiteral(e.Position, e), Identifier))
         .End(tp => new TemplateInstanceExpression(tp, current, args));
     return ret == null ? current : Postfix(ret, cp);
 }
Example #10
0
 public LambdaLiteral(TextPosition tp, string name, RoutineType type, TokenType op, TupleLiteral attr, TupleLiteral generic, TupleLiteral args, Element expli, ProgramContext block)
     : base(tp, name, type, op, attr, generic, args, expli, block)
 {
 }
 private static void EnumFieldPart(SlimChainParser cp, out string name, out TupleLiteral attr)
 {
     var n = string.Empty;
     TupleLiteral a = null;
     cp.Transfer(e => a = e, AttributeList)
         .Type(t => n = t.Text, TokenType.LetterStartString).Lt();
     name = n;
     attr = a;
 }
 private static ClassDeclaration ClassDeclaration(SlimChainParser cp)
 {
     var type = ClassType.Unknown;
     var name = string.Empty;
     TupleLiteral attr = null;
     TupleLiteral generic = null;
     TupleLiteral inherit = new TupleLiteral();
     ProgramContext block = null;
     return cp.Begin
         .Transfer(e => attr = e, AttributeList)
         .Any(
             icp => icp.Text("class").Self(() => type = ClassType.Class),
             icp => icp.Text("trait").Self(() => type = ClassType.Trait),
             icp => icp.Text("extend").Self(() => type = ClassType.Extend)
         ).Lt()
         .Type(t => name = t.Text, TokenType.LetterStartString).Lt()
         .Transfer(e => generic = e, GenericList)
         .If(icp => icp.Type(TokenType.Pair).Lt())
         .Then(icp => icp.Transfer(e => inherit = e, c => ParseTuple(c, Identifier)))
         .Transfer(e => block = e, InlineContext)
         .End(tp => new ClassDeclaration(tp, name, type, attr, generic, inherit, block));
 }