Changeset d48e529 for src/Common


Ignore:
Timestamp:
Sep 19, 2017, 1:22:51 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
a9a4771
Parents:
4e8949f
Message:

Begin to introduce support for yylloc in the parser and extend CodeLocation? to include start column and end column/line number information

Location:
src/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/CodeLocation.h

    r4e8949f rd48e529  
    2020
    2121struct CodeLocation {
    22         int linenumber;
    23         std::string filename;
     22        int first_line = -1, first_column = -1, last_line = -1, last_column = -1;
     23        std::string filename = "";
    2424
    2525        /// Create a new unset CodeLocation.
    26                 CodeLocation()
    27                 : linenumber( -1 )
    28                 , filename("")
    29         {}
     26        CodeLocation() = default;
    3027
    3128        /// Create a new CodeLocation with the given values.
    3229        CodeLocation( const char* filename, int lineno )
    33                 : linenumber( lineno )
     30                : first_line( lineno )
    3431                , filename(filename ? filename : "")
    3532        {}
     
    3835
    3936        bool isSet () const {
    40                 return -1 != linenumber;
     37                return -1 != first_line;
    4138        }
    4239
     
    4643
    4744        bool followedBy( CodeLocation const & other, int seperation ) {
    48                 return (linenumber + seperation == other.linenumber &&
     45                return (first_line + seperation == other.first_line &&
    4946                        filename == other.filename);
    5047        }
     
    6158inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
    6259        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
    63         return location.isSet() ? out << location.filename << ":" << location.linenumber << ":1 " : out;
     60        return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out;
    6461}
  • src/Common/SemanticError.h

    r4e8949f rd48e529  
    3232
    3333        void maybeSet( const CodeLocation & location ) {
    34                 if( this->location.linenumber < 0 ) {
     34                if( this->location.isUnset() ) {
    3535                        this->location = location;
    3636                }
Note: See TracChangeset for help on using the changeset viewer.