public ParamDef(string name, ParamDefKind kind, Optional <Expr> defaultValue = default(Optional <Expr>), Optional <Expr> type = default(Optional <Expr>)) { this.Name = name; this.Kind = kind; this.DefaultValue = defaultValue; this.Type = type; }
private ParamDef VisitParamDef(RobootGrammarParser.Fundef_argContext e) { int pos = 0; ParamDefKind kind = ParamDefKind.positional; Optional <Expr> type = Optional <Expr> .None(); Optional <Expr> defaultValue = Optional <Expr> .None(); string name; if (e.children[0].GetText() == "~") { pos++; kind = ParamDefKind.named; } if (e.children[0].GetText() == "~~") { pos++; kind = ParamDefKind.implicit_; } if (e.children[pos].GetText() == "(") { name = e.children[pos + 1].GetText(); pos += 2; if (e.children[pos].GetText() == ":") { type = Optional <Expr> .Some(Visit(e.children[pos + 1])); pos += 2; } if (e.children[pos].GetText() == "=") { defaultValue = Optional <Expr> .Some(Visit(e.children[pos + 1])); pos += 2; } } else { name = e.children[pos].GetText(); } return(new ParamDef(name, kind, defaultValue, type)); }