Changeset be5aa1b for src/SynTree


Ignore:
Timestamp:
May 27, 2015, 4:40:05 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
46cbfe1, 52ac3b4
Parents:
6aa5ec0f
Message:

error if continue statement targets a location that is not an enclosing loop, better error messages for branch statements with labels, formatting, refactoring

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    r6aa5ec0f rbe5aa1b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 10:55:19 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed May 27 15:41:13 2015
     13// Update Count     : 8
    1414//
    1515
     
    4646
    4747BranchStmt::BranchStmt( std::list<Label> labels, Label _target, Type _type ) throw ( SemanticError ) :
    48         Statement( labels ), target(_target ), type(_type ) {
     48        Statement( labels ), originalTarget(_target ), target(_target ), type(_type ) {
    4949        //actually this is a syntactic error signaled by the parser
    5050        if ( type == BranchStmt::Goto && target.size() == 0 )
     
    200200
    201201void ForStmt::print( std::ostream &os, int indent ) {
     202        os << "\r" << string( indent, ' ') << "Labels: {";
     203        for (std::list<Label>::iterator it = get_labels().begin(); it != get_labels().end(); ++it) {
     204                os << *it << ",";
     205        }
     206        os << "}" << endl;
     207
    202208        os << "\r" << string( indent, ' ') << "For Statement" << endl ;
    203209
  • src/SynTree/Statement.h

    r6aa5ec0f rbe5aa1b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 10:57:40 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed May 27 15:40:43 2015
     13// Update Count     : 5
    1414//
    1515
     
    227227        virtual ~BranchStmt() {}
    228228
     229        Label get_originalTarget() { return originalTarget; }
    229230        Label get_target() { return target; }
    230231        void set_target( Label newValue ) { target = newValue; }
     
    242243  private:
    243244        static const char *brType[];
     245        Label originalTarget;  // can give better error messages if we remember the label name that the user entered
    244246        Label target;
    245247        Expression *computedTarget;
Note: See TracChangeset for help on using the changeset viewer.