// PrintStatement
 public override bool Walk(PrintStatement node) { return false; }
Example #2
0
 public void VisitPrint(PrintStatement p)
 {
     w.Write("print");
     var sep = " ";
     if (p.outputStream != null)
     {
         w.Write(" >> ");
         p.outputStream.Write(writer);
         sep = ", ";
     }
     foreach (var a in p.args)
     {
         w.Write(sep);
         sep = ", ";
         a.Write(writer);
     }
     if (p.trailingComma)
         w.Write(",");
 }
 // PrintStatement
 public virtual bool Walk(PrintStatement node) { return true; }
Example #4
0
 // PrintStatement
 public override bool Walk(PrintStatement node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
Example #5
0
 public override void Visit(PrintStatement node) { this.action(node); }
 // PrintStatement
 public override bool Walk(PrintStatement node)
 {
     return(false);
 }
 // PrintStatement
 public override bool Walk(PrintStatement node)
 {
     return(Contains(node));
 }
 public virtual void PostWalk(PrintStatement node)
 {
 }
Example #9
0
 public SymbolTable VisitPrint(PrintStatement p)
 {
     throw new NotImplementedException();
 }
Example #10
0
 // PrintStatement
 public override bool Walk(PrintStatement node)
 {
     return(Location >= node.StartIndex && Location <= node.EndIndex);
 }
Example #11
0
 public override bool Walk(PrintStatement node)
 {
     writer.WriteLine("PrintStatement");
     return(base.Walk(node));
 }
Example #12
0
        public void SetUp(List <string> args)
        {
            if (verbose)
            {
                Console.WriteLine("import path:");

                foreach (string directory in pathResolver.Directories)
                {
                    Console.WriteLine("  " + directory);
                }
            }

            AppDomain domain = Thread.GetDomain();

            rootModule = new Module(null, null);

            foreach (Assembly assembly in domain.GetAssemblies())
            {
                AssemblyLoaded(assembly);
            }

            domain.AssemblyLoad += OnDomainAssemblyLoad;

            rootModule.SetName("null", null);
            rootModule.SetName("true", true);
            rootModule.SetName("false", false);
            rootModule.SetName("args", args);

            DefaultWhitespace.SetUp(rootModule, grammar);
            LineComment.SetUp(rootModule, grammar);
            BlockComment.SetUp(rootModule, grammar);
            Whitespace.SetUp(rootModule, grammar);
            Name.SetUp(rootModule, grammar);
            Name.SetUp(rootModule, grammar);
            Number.SetUp(rootModule, grammar);
            Base.String.SetUp(rootModule, grammar);

            Expression.SetUp(rootModule, grammar);
            ValueExpression.SetUp(rootModule, grammar);
            NameExpression.SetUp(rootModule, grammar);
            ParenExpression.SetUp(rootModule, grammar);
            MemberExpression.SetUp(rootModule, grammar);
            CallExpression.SetUp(rootModule, grammar);
            CallInParentScopeExpression.SetUp(rootModule, grammar);
            NewExpression.SetUp(rootModule, grammar);
            TypeExpression.SetUp(rootModule, grammar);
            IsExpression.SetUp(rootModule, grammar);
            AsExpression.SetUp(rootModule, grammar);
            UnaryExpression.SetUp(rootModule, grammar);
            NotExpression.SetUp(rootModule, grammar);
            MultiplicativeExpression.SetUp(rootModule, grammar);
            MultiplyExpression.SetUp(rootModule, grammar);
            DivideExpression.SetUp(rootModule, grammar);
            AdditiveExpression.SetUp(rootModule, grammar);
            AddExpression.SetUp(rootModule, grammar);
            SubtractExpression.SetUp(rootModule, grammar);
            ComparisonExpression.SetUp(rootModule, grammar);
            LessExpression.SetUp(rootModule, grammar);
            LessOrEqualExpression.SetUp(rootModule, grammar);
            EqualityExpression.SetUp(rootModule, grammar);
            InequalityExpression.SetUp(rootModule, grammar);
            GreaterExpression.SetUp(rootModule, grammar);
            GreaterOrEqualExpression.SetUp(rootModule, grammar);
            JunctionExpression.SetUp(rootModule, grammar);
            AndExpression.SetUp(rootModule, grammar);
            AssignmentExpression.SetUp(rootModule, grammar);
            AssignExpression.SetUp(rootModule, grammar);

            /*
             *  NameExpression = ValueExpression
             * ParenExpression = ValueExpression
             *
             * CallExpression < ValueExpression
             * CallInParentScopeExpression = CallExpression
             * MemberExpression = CallExpression
             *
             * NewExpression < CallExpression
             * TypeExpression < NewExpression
             * UnaryExpression < TypeExpression
             * MultiplicativeExpression < UnaryExpression
             * AdditiveExpression < MultiplicativeExpression
             * ComparisonExpression < AdditiveExpression
             * JunctionExpression < ComparisonExpression
             * AssignmentExpression < JunctionExpression
             */

            Precedence.SetPrecedence(NameExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(ParenExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(CallExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(CallInParentScopeExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(MemberExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(NewExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(TypeExpression.pattern.Precedence,
                                     NewExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(UnaryExpression.pattern.Precedence,
                                     TypeExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(MultiplicativeExpression.pattern.Precedence,
                                     UnaryExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AdditiveExpression.pattern.Precedence,
                                     MultiplicativeExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(ComparisonExpression.pattern.Precedence,
                                     AdditiveExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(JunctionExpression.pattern.Precedence,
                                     ComparisonExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AssignmentExpression.pattern.Precedence,
                                     JunctionExpression.pattern.Precedence, Relation.Lower);

            Grammar.PatternChanged(ValueExpression.pattern,
                                   NameExpression.pattern,
                                   ParenExpression.pattern,
                                   MemberExpression.pattern,
                                   CallExpression.pattern,
                                   NewExpression.pattern,
                                   TypeExpression.pattern,
                                   UnaryExpression.pattern,
                                   MultiplicativeExpression.pattern,
                                   AdditiveExpression.pattern,
                                   ComparisonExpression.pattern,
                                   JunctionExpression.pattern,
                                   AssignmentExpression.pattern);

            PatternExpression.SetUp(rootModule, grammar);
            ReferencePatternExpression.SetUp(rootModule, grammar);
            AnyPatternExpression.SetUp(rootModule, grammar);
            TextPatternExpression.SetUp(rootModule, grammar);
            Option.SetUp(rootModule, grammar);
            BlockPatternExpression.SetUp(rootModule, grammar);
            ParenPatternExpression.SetUp(rootModule, grammar);
            TokenPatternExpression.SetUp(rootModule, grammar);
            RangePatternExpression.SetUp(rootModule, grammar);
            RepeatPatternExpression.SetUp(rootModule, grammar);
            AndPatternExpression.SetUp(rootModule, grammar);
            NotPatternExpression.SetUp(rootModule, grammar);
            LabelPatternExpression.SetUp(rootModule, grammar);
            SequencePatternExpression.SetUp(rootModule, grammar);
            AltPatternExpression.SetUp(rootModule, grammar);

            /*
             *  EndPatternExpression = ReferencePatternExpression
             * AnyPatternExpression = ReferencePatternExpression
             *  TextPatternExpression = ReferencePatternExpression
             *  BlockPatternExpression = ReferencePatternExpression
             *  ParenPatternExpression = ReferencePatternExpression
             *  TokenPatternExpression = ReferencePatternExpression
             *
             *  RangePatternExpression < ReferencePatternExpression
             *
             *  AndPatternExpression < RangePatternExpression
             *  NotPatternExpression = AndPatternExpression
             *  RepeatPatternExpression = AndPatternExpression
             *
             *  LabelPatternExpression < AndPatternExpression
             *  SequencePatternExpression < LabelPatternExpression
             *  AltPatternExpression < SequencePatternExpression
             */

            Precedence.SetPrecedence(AnyPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(TextPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(BlockPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(ParenPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(TokenPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(RangePatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AndPatternExpression.pattern.Precedence,
                                     RangePatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(NotPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(RepeatPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(LabelPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(SequencePatternExpression.pattern.Precedence,
                                     LabelPatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AltPatternExpression.pattern.Precedence,
                                     SequencePatternExpression.pattern.Precedence, Relation.Lower);

            Grammar.PatternChanged(ReferencePatternExpression.pattern,
                                   AnyPatternExpression.pattern,
                                   TextPatternExpression.pattern,
                                   BlockPatternExpression.pattern,
                                   ParenPatternExpression.pattern,
                                   TokenPatternExpression.pattern,
                                   RangePatternExpression.pattern,
                                   RepeatPatternExpression.pattern,
                                   AndPatternExpression.pattern,
                                   NotPatternExpression.pattern,
                                   LabelPatternExpression.pattern,
                                   SequencePatternExpression.pattern,
                                   AltPatternExpression.pattern);

            Statement.SetUp(rootModule, grammar);
            ExpressionStatement.SetUp(rootModule, grammar);
            CompoundStatement.SetUp(rootModule, grammar);
            PrintStatement.SetUp(rootModule, grammar);
            IfStatement.SetUp(rootModule, grammar);
            WhileStatement.SetUp(rootModule, grammar);
            ReturnStatement.SetUp(rootModule, grammar);
            ThrowStatement.SetUp(rootModule, grammar);
            TryStatement.SetUp(rootModule, grammar);
            ModuleStatement.SetUp(rootModule, grammar);
            FunctionStatement.SetUp(rootModule, grammar);
            Member.SetUp(rootModule, grammar);
            PatternMember.SetUp(rootModule, grammar);
            FieldMember.SetUp(rootModule, grammar);
            ConstructorMember.SetUp(rootModule, grammar);
            MethodMember.SetUp(rootModule, grammar);
            ClassStatement.SetUp(rootModule, grammar);
            SetPrecedenceStatement.SetUp(rootModule, grammar);
            UsingStatement.SetUp(rootModule, grammar);
            ImportStatement.SetUp(rootModule, grammar);
            TopLevelStatement.SetUp(rootModule, grammar);
            Program.SetUp(rootModule, grammar);

            Grammar.PatternChanged(Member.pattern, Statement.pattern);

            grammar.RootPattern = Program.pattern;

            hasBeenSetUp = true;
        }
 public override void VisitPrint(PrintStatement printStatement)
 {
     Write(printStatement.NewLine ? "println(" : "print(");
     Visit(printStatement.Expression);
     Write(");");
 }
Example #14
0
 public string VisitPrintStatement(PrintStatement statement)
 {
     return(Parenthesize("print", statement.Expression));
 }
Example #15
0
        /** Parses the many variants of \c let statements. */
        private Statement ParseLetStatement()
        {
            Token start = _matcher.Match(TokenKind.Keyword_Let);
            _matcher.Match(TokenKind.Space);
            Expression first = ParseExpression();
            _matcher.Match(TokenKind.Space);
            Token assignment = _matcher.Read();
            _matcher.Match(TokenKind.Space);
            Expression other = ParseExpression();
            _matcher.Match(TokenKind.EndOfLine);

            switch (assignment.Kind)
            {
                case TokenKind.Assign_Add:
                case TokenKind.Assign_Bitwise_And:
                case TokenKind.Assign_Bitwise_Ior:
                case TokenKind.Assign_Bitwise_Xor:
                case TokenKind.Assign_Default:
                case TokenKind.Assign_Divide:
                case TokenKind.Assign_Identity:
                case TokenKind.Assign_Modulus:
                case TokenKind.Assign_Multiply:
                case TokenKind.Assign_Subtract:
                    break;

            #if false
                case TokenKind.Parse:
                    result = new ParseStatement(assignment.Cursor, first, other);
                    break;

                case TokenKind.Print:
                    result = new PrintStatement(assignment.Cursor, first, other);
                    break;
            #endif

                default:
                    throw new ParserError(assignment.Cursor, "Expected assignment operator");
            }

            return new LetStatement(assignment.Cursor, TokenKindToAssignmentKind(assignment.Kind), first, other);
        }
Example #16
0
        public override bool Walk(PrintStatement node)
        {
            UpdateLineInfo(node);

            return(base.Walk(node));
        }
Example #17
0
 public override bool Walk(PrintStatement node)
 {
     UpdateChildRanges(node);
     return(base.Walk(node));
 }
 private List <Inferred> InferPrintStatement(PrintStatement node, Scope scope)
 {
     Debug.Print("Not implemented: InferPrintStatementIn");
     return(null);
 }
 public override void PostWalk(PrintStatement node)
 {
 }
Example #20
0
 public override bool Walk(PrintStatement node)
 {
     CanComplete     = IsActualExpression(node.Expressions);
     CommitByDefault = true;
     return(base.Walk(node));
 }
 // PrintStatement
 public virtual bool Walk(PrintStatement node)
 {
     return(true);
 }
Example #22
0
 public override bool Walk(PrintStatement node) => Save(node, base.Walk(node), "print");
 public override void ExplicitVisit(PrintStatement fragment)
 {
     _fragments.Add(fragment);
 }
Example #24
0
 public override void Visit(PrintStatement node)
 {
     errorCallback(RULE_NAME, RULE_TEXT, node.StartLine, node.StartColumn);
 }
Example #25
0
 void PrintStatement(out Statement stat)
 {
     PrintStatement ps = new PrintStatement(GetPragma(la)); ps.message = new FunctionExpression(GetPragma(la), GetFunction("SMOOSH")); stat = ps; Expression e;
     if (la.kind == 43) {
     Get();
     } else if (la.kind == 44) {
     Get();
     ps.stderr = true;
     } else SynErr(66);
     while (StartOf(2)) {
     Expression(out e);
     (ps.message as FunctionExpression).arguments.Add(e);
     }
     if (la.kind == 45) {
     Get();
     ps.newline = false;
     }
     Expect(5);
     SetEndPragma(stat);
 }
Example #26
0
 public virtual void Visit(PrintStatement node)
 {
 }
Example #27
0
 public void VisitPrint(PrintStatement p)
 {
     CodeExpression e= null;
     if (p.outputStream != null)
     {
         e = p.outputStream.Accept(xlat);
     }
     else
     {
         e = new CodeTypeReferenceExpression("Console");
     }
     e = new CodeMethodReferenceExpression(
         e, "WriteLine");
     gen.SideEffect(
         gen.Appl(
             e,
             p.args.Select(a => xlat.VisitArgument(a)).ToArray()));
 }
Example #28
0
 // PrintStatement
 public override bool Walk(PrintStatement node)
 {
     return(ShouldWalkWorker(node));
 }
 public virtual void PostWalk(PrintStatement node) { }
Example #30
0
 public override void PostWalk(PrintStatement node)
 {
     PostWalkWorker(node);
 }
 public override void PostWalk(PrintStatement node) { }
Example #32
0
 private void SemanticCheck(PrintStatement ast, CompilerContext context)
 {
     WhileType val = expressionTyper.TypeExpression(ast.Value, context);
 }