diff --git a/Parser.Tests/MParserShould.cs b/Parser.Tests/MParserShould.cs index 64502b1..b591791 100644 --- a/Parser.Tests/MParserShould.cs +++ b/Parser.Tests/MParserShould.cs @@ -465,5 +465,18 @@ namespace Parser.Tests Assert.IsInstanceOf(actual); Assert.AreEqual(text, actual.FullText); } + + [Test] + public void ParseBaseClassInvokation() + { + var text = "a@b.c.d(e, f)"; + var sut = CreateParser(text); + var actual = sut.ParseExpression(); + Assert.IsInstanceOf(actual); + var e = (BaseClassInvokationNode) actual; + Assert.AreEqual("a", e.MethodName.Token.PureToken.LiteralText); + Assert.IsInstanceOf(e.BaseClassNameAndArguments); + Assert.AreEqual(text, actual.FullText); + } } } \ No newline at end of file diff --git a/Parser/MParser.cs b/Parser/MParser.cs index ed225ae..f5bc167 100644 --- a/Parser/MParser.cs +++ b/Parser/MParser.cs @@ -360,7 +360,19 @@ namespace Parser } else { - throw new ParsingException($"Unexpected token \"{CurrentToken.PureToken.LiteralText}\" during parsing expression \"{expression.FullText}\" at {CurrentToken.PureToken.Position}."); + throw new ParsingException($"Unexpected token \"{CurrentToken.PureToken.LiteralText}\" while parsing expression \"{expression.FullText}\" at {CurrentToken.PureToken.Position}."); + } + case TokenKind.At: + if (expression is IdentifierNameNode idNameNode2 + && !expression.TrailingTrivia.Any()) + { + var atToken = Factory.Token(EatToken()); + var baseClassNameWithArguments = ParseExpression(); + return Factory.BaseClassInvokation(idNameNode2, atToken, baseClassNameWithArguments); + } + else + { + throw new ParsingException($"Unexpected token \"{CurrentToken.PureToken.LiteralText}\" at {CurrentToken.PureToken.Position}."); } default: return expression; diff --git a/Parser/SyntaxFactory.cs b/Parser/SyntaxFactory.cs index c3cbf8f..1957dd1 100644 --- a/Parser/SyntaxFactory.cs +++ b/Parser/SyntaxFactory.cs @@ -679,5 +679,25 @@ namespace Parser SetParent(result); return result; } + + public BaseClassInvokationNode BaseClassInvokation( + IdentifierNameNode methodName, + TokenNode atToken, + ExpressionNode baseClassNameAndArguments) + { + var children = new List + { + methodName, + atToken, + baseClassNameAndArguments + }; + var result = new BaseClassInvokationNode( + children, + methodName, + atToken, + baseClassNameAndArguments); + SetParent(result); + return result; + } } } \ No newline at end of file diff --git a/Parser/SyntaxNode.cs b/Parser/SyntaxNode.cs index 1be5789..84de2d3 100644 --- a/Parser/SyntaxNode.cs +++ b/Parser/SyntaxNode.cs @@ -720,4 +720,23 @@ namespace Parser Arguments = arguments; } } + + public class BaseClassInvokationNode : ExpressionNode + { + public IdentifierNameNode MethodName { get; } + public TokenNode AtToken { get; } + public ExpressionNode BaseClassNameAndArguments { get; } + + public BaseClassInvokationNode( + List children, + IdentifierNameNode methodName, + TokenNode atToken, + ExpressionNode baseClassNameAndArguments + ) : base(children) + { + MethodName = methodName; + AtToken = atToken; + BaseClassNameAndArguments = baseClassNameAndArguments; + } + } } \ No newline at end of file