Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: bugzilla-daemon@libre-riscv.org
To: libre-riscv-dev@lists.libre-riscv.org
Subject: [libre-riscv-dev] [Bug 280] POWER spec parser needs to support fall-through cases
Date: Sun, 05 Apr 2020 22:32:32 +0000
Message-ID: <bug-280-13-y6qJi1RzRp@http.bugs.libre-riscv.org/> (raw)
In-Reply-To: <bug-280-13@http.bugs.libre-riscv.org/>

http://bugs.libre-riscv.org/show_bug.cgi?id=280

--- Comment #6 from Jacob Lifshay <programmerjake@gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #5)
> (In reply to Jacob Lifshay from comment #4)
> > The following algorithm should work to translate lines:
> > 
> > def lexer(lines):
> >     """ lines is a iterator that returns each line
> >         of text without the trailing newline """
> 
> unfortunately, stripping the newlines removes vital information,
> particularly when discerning small statements after a colon from "suites".
> 
> a suite is defined as the following tokens
> 
> NEWLINE INDENT stmts DEDENT
> 
> where the algorithm you wrote (minus NEWLINE stripping) identifies indent
> and dedent
> 
> oh... er, 1 sec...
> 
> >         yield from tokenize(line)
> >         yield NL
> 
> ah interesting.  so the NL *isn't* removed?

No, NL tokens are retained, however duplicate NL tokens coming from empty
lines/comment lines are stripped. The idea is that it should never produce two
NL tokens right after each other.

However, the way I wrote it you can't do the following:

if True:
    # just a comment here, no actual statements;

    # python has a `pass` statement for this case
next_statement

since it will produce "if" "True" COLON NL next_statement
rather than "if" "True" COLON NL INDENT NL DEDENT next_statement

However, the following will work:

if True:
              # empty line with comment

    pass
next_statement

it will produce "if" "True" COLON NL INDENT "pass" NL DEDENT next_statement

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev

  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-05 15:57 [libre-riscv-dev] [Bug 280] New: " bugzilla-daemon
2020-04-05 15:58 ` [libre-riscv-dev] [Bug 280] " bugzilla-daemon
2020-04-05 17:01 ` bugzilla-daemon
2020-04-05 20:37 ` bugzilla-daemon
2020-04-05 21:43 ` bugzilla-daemon
2020-04-05 22:12 ` bugzilla-daemon
2020-04-05 22:32 ` bugzilla-daemon [this message]
2020-04-06 12:33 ` bugzilla-daemon
2020-04-06 12:45 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-280-13-y6qJi1RzRp@http.bugs.libre-riscv.org/ \
    --to=bugzilla-daemon@libre-riscv.org \
    --cc=libre-riscv-dev@lists.libre-riscv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Libre RISC-V Mailing list Archives (accessible via public-inbox)

Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git