本文整理汇总了C#中LNode.PlusAttr方法的典型用法代码示例。如果您正苦于以下问题:C# LNode.PlusAttr方法的具体用法?C# LNode.PlusAttr怎么用?C# LNode.PlusAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LNode
的用法示例。
在下文中一共展示了LNode.PlusAttr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateWordAttr
static LNode TranslateWordAttr(LNode node, IMacroContext ctx, Symbol attr)
{
if (node.ArgCount == 0) {
if (node.IsId && ctx.IsAttribute)
return node.WithName(attr);
return null;
} else {
if (node.ArgCount == 1)
return node.Args[0].PlusAttrs(node.Attrs.Add(F.Id(attr)));
else // designed for LESv1; this branch is not very useful in LESv2
return node.PlusAttr(F.Id(attr)).With(node.Args[0], node.Args.RemoveAt(0));
}
}
示例2: MethodArgListAndBody
LNode MethodArgListAndBody(int startIndex, RVList<LNode> attrs, Symbol kind, LNode type, LNode name)
{
TokenType la0;
var lp = Match((int) TT.LParen);
var rp = Match((int) TT.RParen);
WhereClausesOpt(ref name);
#line 1279 "EcsParserGrammar.les"
LNode r, baseCall = null;
#line default
// Line 1280: (TT.Colon (@`.`(TT, noMacro(@base))|@`.`(TT, noMacro(@this))) TT.LParen TT.RParen)?
la0 = LA0;
if (la0 == TT.Colon) {
Skip();
var target = Match((int) [email protected], (int) [email protected]);
var baselp = Match((int) TT.LParen);
var baserp = Match((int) TT.RParen);
#line 1282 "EcsParserGrammar.les"
baseCall = F.Call((Symbol) target.Value, ExprListInside(baselp), target.StartIndex, baserp.EndIndex);
if ((kind != S.Cons)) {
Error(baseCall, "This is not a constructor declaration, so there should be no ':' clause.");
}
#line default
}
#line 1289 "EcsParserGrammar.les"
for (int i = 0; i < attrs.Count; i++) {
var attr = attrs[i];
if (IsNamedArg(attr) && attr.Args[0].IsIdNamed(S.Return)) {
type = type.PlusAttr(attr.Args[1]);
attrs.RemoveAt(i);
i--;
}
}
#line default
// Line 1298: (default TT.Semicolon | MethodBodyOrForward)
do {
switch (LA0) {
case TT.Semicolon:
goto match1;
case TT.At:
case TT.Forward:
case TT.LambdaArrow:
case TT.LBrace:
{
var body = MethodBodyOrForward();
#line 1310 "EcsParserGrammar.les"
if (kind == S.Delegate) {
Error("A 'delegate' is not expected to have a method body.");
}
if (baseCall != null) {
body = body.WithArgs(body.Args.Insert(0, baseCall)).WithRange(baseCall.Range.StartIndex, body.Range.EndIndex);
}
#line 1314 "EcsParserGrammar.les"
var parts = new RVList<LNode> {
type, name, ArgList(lp, rp), body
};
r = F.Call(kind, parts, startIndex, body.Range.EndIndex);
#line default
}
break;
default:
goto match1;
}
break;
match1:
{
var end = Match((int) TT.Semicolon);
#line 1300 "EcsParserGrammar.les"
if (kind == S.Cons && baseCall != null) {
Error(baseCall, "A method body is required.");
var parts = new RVList<LNode> {
type, name, ArgList(lp, rp), LNode.Call(S.Braces, new RVList<LNode>(baseCall), baseCall.Range)
};
return F.Call(kind, parts, startIndex, baseCall.Range.EndIndex);
}
#line 1306 "EcsParserGrammar.les"
r = F.Call(kind, type, name, ArgList(lp, rp), startIndex, end.EndIndex);
#line default
}
} while (false);
#line 1318 "EcsParserGrammar.les"
return r.PlusAttrs(attrs);
#line default
}
示例3: MethodArgListAndBody
LNode MethodArgListAndBody(int startIndex, int targetIndex, VList<LNode> attrs, Symbol kind, LNode type, LNode name)
{
TokenType la0;
Token lit_colon = default(Token);
var lp = Match((int) TT.LParen);
var rp = Match((int) TT.RParen);
WhereClausesOpt(ref name);
// line 1686
LNode r, _, baseCall = null;
// line 1686
int consCallIndex = -1;
// Line 1687: (TT.Colon (TT.Base|TT.This) TT.LParen TT.RParen)?
la0 = LA0;
if (la0 == TT.Colon) {
lit_colon = MatchAny();
var target = Match((int) TT.Base, (int) TT.This);
var baselp = Match((int) TT.LParen);
var baserp = Match((int) TT.RParen);
// line 1689
baseCall = F.Call((Symbol) target.Value, ExprListInside(baselp), target.StartIndex, baserp.EndIndex, target.StartIndex, target.EndIndex);
if ((kind != S.Constructor)) {
Error(baseCall, "This is not a constructor declaration, so there should be no ':' clause.");
}
consCallIndex = lit_colon.StartIndex;
}
// line 1697
for (int i = 0; i < attrs.Count; i++) {
var attr = attrs[i];
if (IsNamedArg(attr) && attr.Args[0].IsIdNamed(S.Return)) {
type = type.PlusAttr(attr.Args[1]);
attrs.RemoveAt(i);
i--;
}
}
// Line 1706: (default TT.Semicolon | MethodBodyOrForward)
do {
switch (LA0) {
case TT.Semicolon:
goto match1;
case TT.At: case TT.Forward: case TT.LambdaArrow: case TT.LBrace:
{
var body = MethodBodyOrForward(false, out _, false, consCallIndex);
// line 1720
if (kind == S.Delegate) {
Error("A 'delegate' is not expected to have a method body.");
}
if (baseCall != null) {
if ((!body.Calls(S.Braces))) {
body = F.Braces(LNode.List(body), startIndex, body.Range.EndIndex);
}
body = body.WithArgs(body.Args.Insert(0, baseCall));
}
var parts = new VList<LNode> {
type, name, ArgList(lp, rp), body
};
r = F.Call(kind, parts, startIndex, body.Range.EndIndex, targetIndex, targetIndex);
}
break;
default:
goto match1;
}
break;
match1:
{
var end = Match((int) TT.Semicolon);
// line 1708
if (kind == S.Constructor && baseCall != null) {
Error(baseCall, "A method body is required.");
var parts = LNode.List(type, name, ArgList(lp, rp), LNode.Call(S.Braces, new VList<LNode>(baseCall), baseCall.Range));
r = F.Call(kind, parts, startIndex, baseCall.Range.EndIndex, targetIndex, targetIndex);
} else {
var parts = LNode.List(type, name, ArgList(lp, rp));
r = F.Call(kind, parts, startIndex, end.EndIndex, targetIndex, targetIndex);
}
}
} while (false);
// line 1731
return r.PlusAttrs(attrs);
}
示例4: Attr
public LNode Attr(LNode attr, LNode node)
{
return node.PlusAttr(attr);
}
示例5: InParens
public LNode InParens(LNode inner, int startIndex = -1, int endIndex = -1)
{
if (endIndex < startIndex) endIndex = startIndex;
_inParens = _inParens ?? Id(S.TriviaInParens);
inner = inner.PlusAttr(_inParens);
if (startIndex != -1 && endIndex != -1)
return inner.WithRange(startIndex, endIndex);
else
return inner;
}
示例6: ConvertVarDeclToRunSequence
LNode ConvertVarDeclToRunSequence(VList<LNode> attrs, LNode varType, LNode varName, LNode initValue)
{
initValue = BubbleUpBlocks(initValue);
varType = varType ?? F.Missing;
LNode @ref;
attrs = attrs.WithoutNodeNamed(S.Ref, out @ref);
var varName_apos = varName.PlusAttr(_trivia_isTmpVar);
if (@ref != null)
varName_apos = varName_apos.PlusAttr(@ref);
{
LNode resultValue;
VList<LNode> stmts;
if (initValue.CallsMin((Symbol) "#runSequence", 1) && (resultValue = initValue.Args[initValue.Args.Count - 1]) != null) {
stmts = initValue.Args.WithoutLast(1);
var newVarDecl = LNode.Call(LNode.List(attrs), CodeSymbols.Var, LNode.List(varType, LNode.Call(CodeSymbols.Assign, LNode.List(varName, resultValue))));
return initValue.WithArgs(stmts.Add(newVarDecl).Add(varName_apos));
} else {
var newVarDecl = LNode.Call(LNode.List(attrs), CodeSymbols.Var, LNode.List(varType, LNode.Call(CodeSymbols.Assign, LNode.List(varName, initValue))));
return LNode.Call((Symbol) "#runSequence", LNode.List(newVarDecl, varName_apos));
}
}
}
示例7: TranslateWordAttr
static LNode TranslateWordAttr(LNode node, IMessageSink sink, Symbol attr)
{
//LNode result = TranslateId(node, attr);
//if (result == null && node.ArgCount >= 1) {
if (node.ArgCount < 1)
return null;
else {
if (node.ArgCount > 1)
return node.PlusAttr(F.Id(attr)).With(node.Args[0], node.Args.RemoveAt(0));
else
return node.Args[0].PlusAttr(F.Id(attr));
}
}