• Matthew Dempsky's avatar
    cmd/compile: refactor export data parsing · 7d3a4097
    Matthew Dempsky authored
    Merge push_parser and pop_parser into a single parse_import function
    and inline unimportfile. Shake out function boundaries a little bit so
    that the symmetry is readily visible.
    
    Move the import_package call into parse_import (and inline
    import_there into import_package).  This means importfile no longer
    needs to provide fake import data to be needlessly lexed/parsed every
    time it's called.
    
    Also, instead of indicating import success/failure by whether the next
    token is "package", import_spec can just check whether importpkg is
    non-nil.
    
    Tangentially, this somehow alters the diagnostics produced for
    test/fixedbugs/issue11610.go.  However, the new diagnostics are more
    consistent with those produced when the empty import statement is
    absent, which seems more desirable than maintaining the previous
    errors.
    
    Change-Id: I5cd1c22aa14da8a743ef569ff084711d137279d5
    Reviewed-on: https://go-review.googlesource.com/19650Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
    7d3a4097
lex.go 49.1 KB