From fd026d1d37841698f30068bbe1006578fce1fd94 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 6 Apr 2020 13:45:25 +0100 Subject: [PATCH] skip blank lines between cases --- libreriscv | 2 +- src/soc/decoder/pseudo/lexer.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libreriscv b/libreriscv index 18043345..3fbac829 160000 --- a/libreriscv +++ b/libreriscv @@ -1 +1 @@ -Subproject commit 1804334535fcfbe92a0f8abf5fb5399963032cf1 +Subproject commit 3fbac829bfc2e1c629a31f0edc9976271adc8569 diff --git a/src/soc/decoder/pseudo/lexer.py b/src/soc/decoder/pseudo/lexer.py index c6461063..3e96a3a0 100644 --- a/src/soc/decoder/pseudo/lexer.py +++ b/src/soc/decoder/pseudo/lexer.py @@ -140,6 +140,8 @@ def annoying_case_hack_filter(code): as a "small expression". it can then be spotted and used to indicate "fall through" to the next case (in the parser) + also skips blank lines + bugs: any function that starts with the letters "case" or "default" will be detected erroneously. fixing that involves doing a token lexer which spots the fact that "case" and "default" are words, @@ -152,6 +154,8 @@ def annoying_case_hack_filter(code): for l in code.split("\n"): spc_count = count_spaces(l) nwhite = l[spc_count:] + if len(nwhite) == 0: # skip blank lines + continue if nwhite.startswith("case") or nwhite.startswith("default"): #print ("case/default", nwhite, spc_count, prev_spc_count) if (prev_spc_count is not None and @@ -473,9 +477,11 @@ switch (n) case(1): x <- 5 case(3): x <- 2 case(2): + case(4): x <- 3 case(9): + default: x <- 9 print (5) -- 2.30.2