• griesemer's avatar
    cmd/compile/internal/syntax: cleanups around parser tracing · 4b7325c7
    griesemer authored
    These changes affect the parser only when the internal trace
    constant is set.
    
    - factored our printing code used for tracing
    - streamlined advance function and added trace output
    
    The parser's trace output now more clearly prints what tokens
    are skipped and which is the next token in case of an error.
    
    Example trace:
    
        4: . . . . . . . . . . call (
        4: . . . . . . . . . . . expr (
        4: . . . . . . . . . . . . unaryExpr (
        4: . . . . . . . . . . . . . pexpr (
        4: . . . . . . . . . . . . . . operand name (
        4: . . . . . . . . . . . . . . )
        4: . . . . . . . . . . . . . . call (
        4: . . . . . . . . . . . . . . )
        4: . . . . . . . . . . . . . )
        4: . . . . . . . . . . . . )
        4: . . . . . . . . . . . )
        4: . . . . . . . . . . . syntax error: expecting comma or )
        4: . . . . . . . . . . . skip ;
        6: . . . . . . . . . . . skip name
        6: . . . . . . . . . . . skip :=
        6: . . . . . . . . . . . skip literal
        6: . . . . . . . . . . . skip ;
        7: . . . . . . . . . . . skip }
        7: . . . . . . . . . . . skip ;
        9: . . . . . . . . . . . skip func
        9: . . . . . . . . . . . skip name
        9: . . . . . . . . . . . skip (
        9: . . . . . . . . . . . next )
        9: . . . . . . . . . . )
    
    For #22164.
    
    Change-Id: I4a233696b1f989ee3287472172afaf92cf424565
    Reviewed-on: https://go-review.googlesource.com/70490Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    4b7325c7
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...