Exemple #1
0
        public PatternUst VisitVarOrFieldDeclarationExpression(DslParser.VarOrFieldDeclarationExpressionContext context)
        {
            bool       localVariable          = context.Field() == null;
            PatternUst typeLiteralOrPatternId = VisitLiteralOrPatternId(context.type);
            PatternUst type = typeLiteralOrPatternId is PatternIdRegexToken ?
                              typeLiteralOrPatternId :
                              new PatternIdToken(typeLiteralOrPatternId.ToString(), typeLiteralOrPatternId.TextSpan);
            PatternUst name = VisitVariableName(context.variableName());
            IEnumerable <PatternUst> modifiers = ProcessLiteralsOrPatternIds(context._modifiers);
            var assignment = new PatternAssignmentExpression(name, null, name.TextSpan);
            var result     = new PatternVarOrFieldDeclaration(localVariable, modifiers, type, assignment, context.GetTextSpan());

            return(result);
        }
Exemple #2
0
        public PatternUst VisitAssignmentExpression(DslParser.AssignmentExpressionContext context)
        {
            PatternUst result;
            PatternUst left  = VisitExpression(context.expression(0));
            PatternUst right = VisitExpression(context.expression(1));

            if (left is PatternVarOrFieldDeclaration declaration)
            {
                declaration.Assignment.Right = right;
                result = declaration;
            }
            else
            {
                result = new PatternAssignmentExpression(left, right, context.GetTextSpan());
            }
            return(result);
        }
Exemple #3
0
 public virtual T Visit(PatternAssignmentExpression patternAssignmentExpression)
 {
     return(VisitChildren(patternAssignmentExpression));
 }