本文整理汇总了C#中Microsoft.PythonTools.Parsing.Ast.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于Microsoft.PythonTools.Parsing.Ast命名空间,在下文中一共展示了Expression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DefineExpr
private void DefineExpr(Expression lhs) {
if (lhs is NameExpression) {
lhs.Walk(Define);
} else {
// fob.oar = 42, fob[oar] = 42, we don't actually define any variables
lhs.Walk(this);
}
}
开发者ID:jsschultz,项目名称:PTVS,代码行数:8,代码来源:AssignmentWalker.cs
示例2: BinaryExpression
public BinaryExpression(PythonOperator op, Expression left, Expression right) {
Contract.Assert(left != null);
Contract.Assert(right != null);
if (op == PythonOperator.None) throw new ArgumentException("bad operator");
_op = op;
_left = left;
_right = right;
StartIndex = left.StartIndex;
EndIndex = right.EndIndex;
}
开发者ID:RussBaz,项目名称:PTVS,代码行数:11,代码来源:BinaryExpression.cs
示例3: AppendCodeString
internal void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, string start, string end, Expression item) {
if (!String.IsNullOrEmpty(start)) {
format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
res.Append(start);
}
item.AppendCodeString(res, ast, format);
for (int i = 0; i < Iterators.Count; i++) {
Iterators[i].AppendCodeString(res, ast, format);
}
if (!String.IsNullOrEmpty(end)) {
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(end);
}
}
开发者ID:omnimark,项目名称:PTVS,代码行数:17,代码来源:Comprehension.cs
示例4: GetValueFromExpression
private IMember GetValueFromExpression(Expression expr, Dictionary<string, IMember> scope) {
var ne = expr as NameExpression;
if (ne != null) {
IMember existing = null;
if (scope != null && scope.TryGetValue(ne.Name, out existing) && existing != null) {
return existing;
}
if (_members != null && _members.TryGetValue(ne.Name, out existing) && existing != null) {
return existing;
}
}
var type = GetTypeFromExpression(expr);
if (type != null) {
return new AstPythonConstant(type, GetLoc(expr));
}
return null;
}
开发者ID:jsschultz,项目名称:PTVS,代码行数:19,代码来源:AstAnalysisWalker.cs
示例5: GetFirstNameExpression
private static NameExpression GetFirstNameExpression(Expression expr) {
NameExpression nameExpr;
CallExpression callExpr;
MemberExpression membExpr;
if ((nameExpr = expr as NameExpression) != null) {
return nameExpr;
}
if ((callExpr = expr as CallExpression) != null) {
return GetFirstNameExpression(callExpr.Target);
}
if ((membExpr = expr as MemberExpression) != null) {
return GetFirstNameExpression(membExpr.Target);
}
return null;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:17,代码来源:ProjectAnalyzer.cs
示例6: AssertStatement
public AssertStatement(Expression test, Expression message) {
_test = test;
_message = message;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:4,代码来源:AssertStatement.cs
示例7: ForceExplicitSign
private static Expression ForceExplicitSign(Expression expr, out int sign) {
var constExpr = expr as ConstantExpression;
if (constExpr != null && (constExpr.Value is int || constExpr.Value is double || constExpr.Value is BigInteger || constExpr.Value is Complex)) {
sign = 1;
return new UnaryExpression(PythonOperator.Pos, constExpr);
}
var unaryExpr = expr as UnaryExpression;
if (unaryExpr != null) {
switch (unaryExpr.Op) {
case PythonOperator.Pos:
sign = 1;
return unaryExpr;
case PythonOperator.Negate:
sign = -1;
return unaryExpr;
}
}
sign = 0;
return expr;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:22,代码来源:ExpressionEvaluator.cs
示例8: IfStatementTest
public IfStatementTest(Expression test, Statement body) {
_test = test;
_body = body;
}
开发者ID:wenh123,项目名称:PTVS,代码行数:4,代码来源:IfStatementTest.cs
示例9: WalkCollection
private bool WalkCollection(Expression node, IEnumerable<Expression> items) {
CanComplete = HasCaret(node);
int count = 0;
Expression last = null;
foreach (var e in items) {
count += 1;
last = e;
}
if (count == 0) {
CommitByDefault = false;
} else if (count == 1) {
last.Walk(this);
CommitByDefault = false;
} else {
CommitByDefault = true;
last.Walk(this);
}
return false;
}
开发者ID:smallwave,项目名称:PTVS,代码行数:19,代码来源:IntellisenseController.cs
示例10: FinishSetComp
// comp_iter '}'
private SetComprehension FinishSetComp(Expression item, out bool ateTerminator) {
ComprehensionIterator[] iters = ParseCompIter();
ateTerminator = Eat(TokenKind.RightBrace);
return new SetComprehension(item, iters);
}
开发者ID:omnimark,项目名称:PTVS,代码行数:6,代码来源:Parser.cs
示例11: ParseGeneratorExpression
// genexpr_for ::= "for" target_list "in" or_test [comp_iter]
//
// "for" has NOT been eaten before entering this method
private Expression ParseGeneratorExpression(Expression expr, string rightParenWhiteSpace = null) {
ComprehensionIterator[] iters = ParseCompIter();
GeneratorExpression ret = new GeneratorExpression(expr, iters);
ret.SetLoc(expr.StartIndex, GetEnd());
return ret;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:11,代码来源:Parser.cs
示例12: FinishExpressionListAsExpr
private Expression FinishExpressionListAsExpr(Expression expr) {
var start = GetStart();
bool trailingComma = true;
List<Expression> l = new List<Expression>();
List<string> itemWhiteSpace = MakeWhiteSpaceList();
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
l.Add(expr);
while (true) {
if (NeverTestToken(PeekToken())) break;
expr = ParseExpression();
l.Add(expr);
if (!MaybeEat(TokenKind.Comma)) {
trailingComma = false;
break;
}
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
trailingComma = true;
}
Expression ret = MakeTupleOrExpr(l, itemWhiteSpace, trailingComma);
ret.SetLoc(start, GetEnd());
return ret;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:28,代码来源:Parser.cs
示例13: ParseTestListAsExpr
private List<Expression> ParseTestListAsExpr(Expression expr, out List<string> itemWhiteSpace, out bool trailingComma) {
var l = new List<Expression>();
itemWhiteSpace = MakeWhiteSpaceList();
if (expr != null) {
l.Add(expr);
if (itemWhiteSpace != null) {
Debug.Assert(_token.Token.Kind == TokenKind.Comma);
itemWhiteSpace.Add(_tokenWhiteSpace);
}
}
trailingComma = true;
while (true) {
if (NeverTestToken(PeekToken())) break;
l.Add(ParseExpression());
if (!MaybeEat(TokenKind.Comma)) {
trailingComma = false;
break;
}
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
}
return l;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:26,代码来源:Parser.cs
示例14: DecoratorStatement
public DecoratorStatement(Expression[] decorators) {
_decorators = decorators;
}
开发者ID:RussBaz,项目名称:PTVS,代码行数:3,代码来源:DecoratorStatement.cs
示例15: IsActualExpression
private static bool IsActualExpression(Expression node) {
return node != null && !(node is ErrorExpression);
}
开发者ID:smallwave,项目名称:PTVS,代码行数:3,代码来源:IntellisenseController.cs
示例16: FinishListComp
// list_iter ']'
private ListComprehension FinishListComp(Expression item, out bool ateRightBracket) {
ComprehensionIterator[] iters = ParseListCompIter();
ateRightBracket = Eat(TokenKind.RightBracket);
return new ListComprehension(item, iters);
}
开发者ID:omnimark,项目名称:PTVS,代码行数:6,代码来源:Parser.cs
示例17: AugmentedAssignStatement
public AugmentedAssignStatement(PythonOperator op, Expression left, Expression right) {
_op = op;
_left = left;
_right = right;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:5,代码来源:AugmentedAssignStatement.cs
示例18: FinishCallExpr
private CallExpression FinishCallExpr(Expression target, params Arg[] args) {
bool hasArgsTuple = false;
bool hasKeywordDict = false;
int keywordCount = 0;
int extraArgs = 0;
foreach (Arg arg in args) {
if (arg.Name == null) {
if (hasArgsTuple || hasKeywordDict || keywordCount > 0) {
ReportSyntaxError(arg.StartIndex, arg.EndIndex, "non-keyword arg after keyword arg");
}
} else if (arg.Name == "*") {
if (hasArgsTuple || hasKeywordDict) {
ReportSyntaxError(arg.StartIndex, arg.EndIndex, "only one * allowed");
}
hasArgsTuple = true; extraArgs++;
} else if (arg.Name == "**") {
if (hasKeywordDict) {
ReportSyntaxError(arg.StartIndex, arg.EndIndex, "only one ** allowed");
}
hasKeywordDict = true; extraArgs++;
} else {
if (hasKeywordDict) {
ReportSyntaxError(arg.StartIndex, arg.EndIndex, "keywords must come before ** args");
}
keywordCount++;
}
}
return new CallExpression(target, args);
}
开发者ID:omnimark,项目名称:PTVS,代码行数:31,代码来源:Parser.cs
示例19: ToDottedNameString
private static string ToDottedNameString(Expression expr, PythonAst ast) {
NameExpression name;
MemberExpression member;
ParenthesisExpression paren;
if ((name = expr as NameExpression) != null) {
return name.Name;
} else if ((member = expr as MemberExpression) != null) {
while (member.Target is MemberExpression) {
member = (MemberExpression)member.Target;
}
if (member.Target is NameExpression) {
return expr.ToCodeString(ast);
}
} else if ((paren = expr as ParenthesisExpression) != null) {
return ToDottedNameString(paren.Expression, ast);
}
return null;
}
开发者ID:KevinH-MS,项目名称:PTVS,代码行数:18,代码来源:PythonProcess.cs
示例20: FinishAssignments
private Statement FinishAssignments(Expression right) {
List<Expression> left = null;
List<string> assignWhiteSpace = MakeWhiteSpaceList();
Expression singleLeft = null;
while (MaybeEat(TokenKind.Assign)) {
if (assignWhiteSpace != null) {
assignWhiteSpace.Add(_tokenWhiteSpace);
}
string assignError = right.CheckAssign();
if (assignError != null) {
ReportSyntaxError(right.StartIndex, right.EndIndex, assignError, ErrorCodes.SyntaxError | ErrorCodes.NoCaret);
}
if (singleLeft == null) {
singleLeft = right;
} else {
if (left == null) {
left = new List<Expression>();
left.Add(singleLeft);
}
left.Add(right);
}
if (_langVersion >= PythonLanguageVersion.V25 && PeekToken(TokenKind.KeywordYield)) {
if (!AllowYieldSyntax && AllowAsyncAwaitSyntax) {
ReportSyntaxError("'yield' inside async function");
}
Eat(TokenKind.KeywordYield);
right = ParseYieldExpression();
} else {
right = ParseTestListAsExpr();
}
}
AssignmentStatement assign;
if (left != null) {
Debug.Assert(left.Count > 0);
assign = new AssignmentStatement(left.ToArray(), right);
assign.SetLoc(left[0].StartIndex, right.EndIndex);
} else {
Debug.Assert(singleLeft != null);
assign = new AssignmentStatement(new[] { singleLeft }, right);
assign.SetLoc(singleLeft.StartIndex, right.EndIndex);
}
if (assignWhiteSpace != null) {
AddListWhiteSpace(assign, assignWhiteSpace.ToArray());
}
return assign;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:52,代码来源:Parser.cs
注:本文中的Microsoft.PythonTools.Parsing.Ast.Expression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论