本文整理汇总了C#中ScriptSharp.CodeModel.ParseNode类的典型用法代码示例。如果您正苦于以下问题:C# ParseNode类的具体用法?C# ParseNode怎么用?C# ParseNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseNode类属于ScriptSharp.CodeModel命名空间,在下文中一共展示了ParseNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoWhileNode
public DoWhileNode(Token token,
ParseNode body,
ParseNode condition)
: base(ParseNodeType.DoWhile, token) {
_body = GetParentedNode(body);
_condition = GetParentedNode(condition);
}
示例2: BinaryExpressionNode
public BinaryExpressionNode(ParseNode leftChild, TokenType operatorType, ParseNode rightChild)
: base(ParseNodeType.BinaryExpression, leftChild.token)
{
_leftChild = GetParentedNode(leftChild);
_operatorType = operatorType;
_rightChild = GetParentedNode(rightChild);
}
示例3: LockNode
public LockNode(Token token,
ParseNode monitor,
ParseNode body)
: base(ParseNodeType.Lock, token) {
this.monitor = GetParentedNode(monitor);
this.body = GetParentedNode(body);
}
示例4: BuildExpression
public Expression BuildExpression(ParseNode node) {
Expression expression = null;
switch (node.NodeType) {
case ParseNodeType.Literal:
expression = ProcessLiteralNode((LiteralNode)node);
break;
case ParseNodeType.Name:
case ParseNodeType.GenericName:
expression = ProcessNameNode((NameNode)node);
break;
case ParseNodeType.Typeof:
expression = ProcessTypeofNode((TypeofNode)node);
break;
case ParseNodeType.This:
expression = ProcessThisNode((ThisNode)node);
break;
case ParseNodeType.Base:
expression = ProcessBaseNode((BaseNode)node);
break;
case ParseNodeType.UnaryExpression:
expression = ProcessUnaryExpressionNode((UnaryExpressionNode)node);
break;
case ParseNodeType.BinaryExpression:
expression = ProcessBinaryExpressionNode((BinaryExpressionNode)node);
break;
case ParseNodeType.Conditional:
expression = ProcessConditionalNode((ConditionalNode)node);
break;
case ParseNodeType.New:
expression = ProcessNewNode((NewNode)node);
break;
case ParseNodeType.ArrayNew:
expression = ProcessArrayNewNode((ArrayNewNode)node);
break;
case ParseNodeType.ArrayInitializer:
expression = ProcessArrayInitializerNode((ArrayInitializerNode)node);
break;
case ParseNodeType.ArrayType:
expression = ProcessArrayTypeNode((ArrayTypeNode)node);
break;
case ParseNodeType.PredefinedType:
expression = ProcessIntrinsicType((IntrinsicTypeNode)node);
break;
case ParseNodeType.Cast:
expression = ProcessCastNode((CastNode)node);
break;
case ParseNodeType.AnonymousMethod:
expression = ProcessAnonymousMethodNode((AnonymousMethodNode)node);
break;
default:
Debug.Fail("Unhandled Expression Node: " + node.NodeType);
break;
}
if ((node is ExpressionNode) && ((ExpressionNode)node).Parenthesized) {
expression.AddParenthesisHint();
}
return expression;
}
示例5: UsingNode
public UsingNode(Token token,
ParseNode guard,
ParseNode body)
: base(ParseNodeType.Using, token) {
_guard = GetParentedNode(guard);
_body = GetParentedNode(body);
}
示例6: foreach
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler)
{
CompilationUnitNode compilationUnitNode = (CompilationUnitNode)node;
foreach (AttributeBlockNode attribBlock in compilationUnitNode.Attributes) {
AttributeNode scriptNamespaceNode = AttributeNode.FindAttribute(attribBlock.Attributes, "ScriptNamespace");
if (scriptNamespaceNode != null) {
string scriptNamespace = (string)((LiteralNode)scriptNamespaceNode.Arguments[0]).Value;
if (Utility.IsValidScriptNamespace(scriptNamespace) == false) {
errorHandler.ReportError("A script namespace must be a valid script identifier.",
scriptNamespaceNode.Token.Location);
}
}
}
foreach (ParseNode childNode in compilationUnitNode.Members) {
if (!(childNode is NamespaceNode)) {
errorHandler.ReportError("Non-namespaced types are not supported.",
childNode.Token.Location);
return false;
}
}
return true;
}
示例7: Visit
private void Visit(ParseNode node) {
bool recurse = ProcessNode(node);
if (recurse) {
StartChildren(String.Empty);
Type nodeType = node.GetType();
foreach (PropertyInfo propertyInfo in nodeType.GetProperties()) {
string propertyName = propertyInfo.Name;
if (propertyName.Equals("NodeType")) {
continue;
}
if (propertyName.Equals("Parent")) {
continue;
}
if (propertyName.Equals("Token")) {
continue;
}
Visit(node, propertyInfo);
}
EndChildren();
}
}
示例8: GetParentedNode
protected ParseNode GetParentedNode(ParseNode child)
{
if (child != null) {
child.SetParent(this);
}
return child;
}
示例9:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
NewNode newNode = (NewNode)node;
// TODO: This is somewhat hacky - it only looks for any type named Dictionary
// rather than resolving the type and checking if its actually
// System.Dictionary.
// This is because validators don't have a reference to the SymbolSet.
NameNode typeNode = newNode.TypeReference as NameNode;
if ((typeNode != null) && (typeNode.Name.Equals("Dictionary"))) {
if (newNode.Arguments != null) {
Debug.Assert(newNode.Arguments is ExpressionListNode);
ParseNodeList arguments = ((ExpressionListNode)newNode.Arguments).Expressions;
if (arguments.Count != 0) {
if (arguments.Count % 2 != 0) {
errorHandler.ReportError("Missing value parameter for the last name parameter in Dictionary instantiation.",
newNode.Token.Location);
}
for (int i = 0; i < arguments.Count; i += 2) {
ParseNode nameArgumentNode = arguments[i];
if ((nameArgumentNode.NodeType != ParseNodeType.Literal) ||
(((LiteralNode)nameArgumentNode).Literal.LiteralType != LiteralTokenType.String)) {
errorHandler.ReportError("Name parameters in Dictionary instantiation must be string literals.",
nameArgumentNode.Token.Location);
}
}
}
}
}
return true;
}
示例10: ConstantFieldDeclarationNode
public ConstantFieldDeclarationNode(Token token,
ParseNodeList attributes,
Modifiers modifiers,
ParseNode type,
ParseNodeList initializers)
: base(ParseNodeType.ConstFieldDeclaration, token, attributes, modifiers, type, initializers, false) {
}
示例11: SwitchNode
public SwitchNode(Token token,
ParseNode condition,
ParseNodeList cases)
: base(ParseNodeType.Switch, token) {
_condition = GetParentedNode(condition);
_cases = GetParentedNodeList(cases);
}
示例12: ConditionalNode
public ConditionalNode(ParseNode condition, ParseNode trueValue, ParseNode falseValue)
: base(ParseNodeType.Conditional, condition.token)
{
_condition = GetParentedNode(condition);
_trueValue = GetParentedNode(trueValue);
_falseValue = GetParentedNode(falseValue);
}
示例13: FixedNode
public FixedNode(Token token,
VariableDeclarationNode declaration,
ParseNode body)
: base(ParseNodeType.Fixed, token) {
_declaration = (VariableDeclarationNode)GetParentedNode(declaration);
_body = GetParentedNode(body);
}
示例14: Append
public void Append(ParseNode node)
{
if (node != null) {
EnsureListCreated();
_list.Add(node);
}
}
示例15: EnumerationFieldNode
public EnumerationFieldNode(ParseNodeList attributes, AtomicNameNode name,
ParseNode value)
: base(ParseNodeType.EnumerationFieldDeclaration, name.token) {
_attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
_name = (AtomicNameNode)GetParentedNode(name);
if (value is LiteralNode) {
LiteralNode literalNode = (LiteralNode)value;
_value = ((LiteralToken)literalNode.Token).LiteralValue;
}
else {
// TODO: Clearly we need something more general...
// C# allows expressions. Likely expressions to be used
// include negative values, binary OR'd values,
// expressions involving other enum members (esp. hard to deal with)
// For now, just adding support for negative numbers, as
// everything else can be worked around in source code.
UnaryExpressionNode expressionNode = value as UnaryExpressionNode;
if ((expressionNode != null) && (expressionNode.Operator == TokenType.Minus) &&
(expressionNode.Child is LiteralNode)) {
try {
LiteralToken literalToken =
(LiteralToken)((LiteralNode)expressionNode.Child).Token;
int numericValue = (int)Convert.ChangeType(literalToken.LiteralValue, typeof(int));
_value = -numericValue;
}
catch {
}
}
}
}