本文整理汇总了C#中IAstNode类的典型用法代码示例。如果您正苦于以下问题:C# IAstNode类的具体用法?C# IAstNode怎么用?C# IAstNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAstNode类属于命名空间,在下文中一共展示了IAstNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareNodes
public static void CompareNodes(EditorTree editorTree, IAstNode node1, IAstNode node2)
{
#if ___DEBUG
Debug.Assert(node1 is RootNode || editorTree.ParseTree.ContainsElement(node1.Key));
if (!node1.ChildrenInvalidated)
Debug.Assert(node1.Children.Count == node2.Children.Count);
Debug.Assert(TextRange.AreEqual(node1.NameRange, node2.NameRange));
Debug.Assert(node1.Attributes.Count == node2.Attributes.Count);
Debug.Assert(TextRange.AreEqual(node1.OuterRange, node2.OuterRange));
Debug.Assert(TextRange.AreEqual(node1.InnerRange, node2.InnerRange));
Debug.Assert(node1.Start == node2.Start);
Debug.Assert(node1.End == node2.End);
if (!node1.ChildrenInvalidated)
{
if (node1.Children.Count == node2.Children.Count)
{
for (int i = 0; i < node1.Children.Count; i++)
{
CompareNodes(editorTree, node1.Children[i], node2.Children[i]);
}
}
}
#endif
}
示例2: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
TokenStream<RToken> tokens = context.Tokens;
if (tokens.CurrentToken.IsVariableKind()) {
var v = new Variable();
v.Parse(context, this);
// Variables don't set parent since during complex
// exression parsing parent is determined by the
// expression parser based on precedence and grouping.
v.Parent = this;
this.Variable = v;
if (tokens.CurrentToken.IsKeywordText(context.TextProvider, "in")) {
this.InOperator = new TokenNode();
this.InOperator.Parse(context, this);
this.Expression = new Expression(inGroup: true);
if (this.Expression.Parse(context, this)) {
return base.Parse(context, parent);
}
} else {
context.AddError(new MissingItemParseError(ParseErrorType.InKeywordExpected, tokens.CurrentToken));
}
} else {
context.AddError(new MissingItemParseError(ParseErrorType.IndentifierExpected, tokens.PreviousToken));
}
return false;
}
示例3: BuildAddIndexNode
private void BuildAddIndexNode(IIndexDefinition index, IAstNode parent)
{
IAddIndexNode addIndexNode = new AddIndexNode(parent, index.Name);
parent.ChildNodes.Add(addIndexNode);
SemanticModelUtil.Copy(index, addIndexNode);
}
示例4: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
TokenStream<RToken> tokens = context.Tokens;
Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Identifier ||
context.Tokens.CurrentToken.TokenType == RTokenType.String);
this.Identifier = RParser.ParseToken(context, this);
this.EqualsSign = RParser.ParseToken(context, this);
if (context.Tokens.CurrentToken.TokenType != RTokenType.Comma && context.Tokens.CurrentToken.TokenType != RTokenType.CloseBrace) {
Expression exp = new Expression(inGroup: true);
if (exp.Parse(context, this)) {
this.DefaultValue = exp;
}
} else {
this.DefaultValue = new NullExpression();
if (context.Tokens.IsEndOfStream()) {
context.AddError(new ParseError(ParseErrorType.ExpressionExpected, ErrorLocation.Token, context.Tokens.CurrentToken));
} else {
context.AddError(new ParseError(ParseErrorType.ExpressionExpected, ErrorLocation.Token, EqualsSign));
}
}
return base.Parse(context, parent);
}
示例5: CreateItem
protected override CommaSeparatedItem CreateItem(IAstNode parent, ParseContext context) {
RToken currentToken = context.Tokens.CurrentToken;
RToken nextToken = context.Tokens.NextToken;
switch (currentToken.TokenType) {
case RTokenType.Ellipsis:
return new EllipsisArgument();
case RTokenType.Comma:
return new MissingArgument();
case RTokenType.Identifier:
case RTokenType.String:
case RTokenType.Logical:
case RTokenType.Complex:
case RTokenType.NaN:
case RTokenType.Null:
case RTokenType.Number:
case RTokenType.Infinity:
if (nextToken.TokenType == RTokenType.Operator && context.TextProvider.GetText(nextToken) == "=") {
return new NamedArgument();
}
break;
case RTokenType.CloseBrace:
return null; // no arguments supplied
}
return new ExpressionArgument();
}
示例6: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
if (context.Tokens.CurrentToken.TokenType == RTokenType.Comma) {
this.Comma = RParser.ParseToken(context, this);
}
return base.Parse(context, parent);
}
示例7: ParseToken
public static TokenNode ParseToken(ParseContext context, IAstNode parent) {
TokenStream<RToken> tokens = context.Tokens;
TokenNode node = new TokenNode();
node.Parse(context, parent);
return node;
}
示例8: DefaultVisit
protected override void DefaultVisit(IAstNode node)
{
foreach (var child in node.Children)
{
child.Accept(this);
}
}
示例9: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
if (context.Tokens.CurrentToken.TokenType == RTokenType.OpenBrace) {
context.AddError(new ParseError(ParseErrorType.UnexpectedToken, ErrorLocation.Token, context.Tokens.CurrentToken));
}
return false;
}
示例10: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
TokenStream<RToken> tokens = context.Tokens;
Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.Keyword);
this.Keyword = RParser.ParseKeyword(context, this);
this.Text = context.TextProvider.GetText(this.Keyword);
if (tokens.CurrentToken.TokenType == RTokenType.OpenBrace) {
this.OpenBrace = RParser.ParseToken(context, this);
this.Arguments = new ArgumentList(RTokenType.CloseBrace);
this.Arguments.Parse(context, this);
if (tokens.CurrentToken.TokenType == RTokenType.CloseBrace) {
this.CloseBrace = RParser.ParseToken(context, this);
this.Scope = RParser.ParseScope(context, this, allowsSimpleScope: true, terminatingKeyword: null);
if (this.Scope != null) {
return base.Parse(context, parent);
} else {
context.AddError(new ParseError(ParseErrorType.FunctionBodyExpected, ErrorLocation.Token, tokens.PreviousToken));
}
} else {
context.AddError(new ParseError(ParseErrorType.CloseBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
}
} else {
context.AddError(new ParseError(ParseErrorType.OpenBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
}
return false;
}
示例11: Parse
public override bool Parse(ParseContext context, IAstNode parent) {
if (ParseExpression(context) && this.Children.Count > 0) {
return base.Parse(context, parent);
}
return false;
}
示例12: StatementIndent
public StatementIndent(IAstNode node)
{
BeforeNode = node.BeforeNode;
AfterNode = node;
node.BeforeNode = this;
ParentNode = (Statement)node.ParentNode;
}
示例13: CreateIAstNode
public IAstNode CreateIAstNode(IAstNode beforeNode, string token)
{
if ((token[0] == '@' || token[0] == ':') && token.Length > 1)
{
// If the variable name is quoted
if (token[1] == '"' || token[1] == '\'')
{
//_regex r2 = new _regex(@"^(((""[^""\\]*(?:\\.[^""\\]*)*(""|$))+)|(('[^'\\]*(?:\\.[^'\\]*)*('|$))+))\s");
//TODO Valiable Node
//return new ASTNode( TokenType.VARIABLE
// , token[0] + r2.Match(token.Substring(1)).OriginalValue);
}
else
{
Match match = _regex.Match(token);
if (match.Success)
{
//TODO ValiableNode
//return new ASTNode( TokenType.VARIABLE
// , m3.OriginalValue
// );
}
}
}
return null;
}
示例14: Create
/// <summary>
/// Abstract factory creating statements depending on current
/// token and the following token sequence
/// </summary>
/// <returns></returns>
public static IStatement Create(ParseContext context, IAstNode parent, string terminatingKeyword) {
TokenStream<RToken> tokens = context.Tokens;
RToken currentToken = tokens.CurrentToken;
IStatement statement = null;
switch (currentToken.TokenType) {
case RTokenType.Keyword:
// If statement starts with a keyword, it is not an assignment
// hence we should always try keyword based statements first.
// Some of the statements may be R-values like typeof() but
// in case of the statement appearing on its own return value
// will be simply ignored. IDE may choose to show a warning.
if (currentToken.SubType == RTokenSubType.BuiltinFunction && tokens.NextToken.TokenType != RTokenType.OpenBrace) {
// 'return <- x + y' is allowed
statement = new ExpressionStatement(terminatingKeyword);
} else {
statement = KeywordStatement.CreateStatement(context, parent);
}
break;
case RTokenType.Semicolon:
statement = new EmptyStatement();
break;
default:
// Possible L-value in a left-hand assignment,
// a function call or R-value in a right hand assignment.
statement = new ExpressionStatement(terminatingKeyword);
break;
}
return statement;
}
示例15: RemoveChildren
public void RemoveChildren(int start, int count) {
if (count == 0)
return;
if (start < 0 || start >= Children.Count)
throw new ArgumentOutOfRangeException("start");
if (count < 0 || count > Children.Count || start + count > Children.Count)
throw new ArgumentOutOfRangeException("count");
if (Children.Count == count) {
_children = new TextRangeCollection<IAstNode>();
} else {
var newChildren = new IAstNode[Children.Count - count];
int j = 0;
for (int i = 0; i < start; i++, j++)
newChildren[j] = Children[i];
for (int i = start; i < start + count; i++)
Children[i].Parent = null;
for (int i = start + count; i < Children.Count; i++, j++)
newChildren[j] = Children[i];
_children = new TextRangeCollection<IAstNode>(newChildren);
}
}