diff options
| author | Jack | 2016-01-28 23:59:14 -0800 |
|---|---|---|
| committer | Jack | 2016-01-28 23:59:14 -0800 |
| commit | fec6fed92a116290c8944b34c3f9d720a1fa574d (patch) | |
| tree | c2adc92dcff7aec61668ed1be7dbfa39bb345974 /src | |
| parent | f9d329b91ba5a57dfaca7367fbe14d6f85de672f (diff) | |
Add support for single-line and multi-line scoping to Scala FIRRTL preprocessing step. Also added with as scoping keyword
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/Translator.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/Translator.scala b/src/main/scala/firrtl/Translator.scala index 9f90038c..7b88e0e0 100644 --- a/src/main/scala/firrtl/Translator.scala +++ b/src/main/scala/firrtl/Translator.scala @@ -23,7 +23,9 @@ object Translator def countSpaces(s: String): Int = s.prefixLength(_ == ' ') def stripComments(s: String): String = s takeWhile (!";".contains(_)) - val Scopers = """\s*(circuit|module|when|else|mem)(.*)""".r + val scopers = """(circuit|module|when|else|mem|with)""" + val MultiLineScope = ("""(.*""" + scopers + """)(.*:\s*)""").r + val OneLineScope = ("""(.*""" + scopers + """\s*:\s*)\((.*)\)\s*""").r // Function start val it = inputIt.zipWithIndex @@ -73,10 +75,14 @@ object Translator // Now match on legal scope increasers text match { - case Scopers(keyword, _* ) => { + case OneLineScope(head, keyword, body) => { + newScope = false + head + "{" + body + "}" + } + case MultiLineScope(head, keyword, tail) => { newScope = true - //text + " { " - text.replaceFirst(":", ": {") + //text.replaceFirst(":", ": {") + text + " { " } case _ => { newScope = false |
