diff options
| author | jackkoenig | 2015-11-24 19:18:01 -0800 |
|---|---|---|
| committer | jackkoenig | 2015-11-24 19:18:01 -0800 |
| commit | 71f0319e8d27d1f175b4747c0367843a6ceab986 (patch) | |
| tree | acd1c96a30f4b04fcc6202cd9f9f59c9e9de432a /src/main/scala/firrtl/Translator.scala | |
| parent | 876c5e0a93c21a2108804eb972289f77c250e28b (diff) | |
In process of adding FAME-1 transformation, updated todos in grammar file, updated Makefile to play nicer when firrtl is a submodule, fixed bug in Translator for single line scopes, fixed firrtl-scala script to point to firrtl.Driver instead of old firrtl.Test
Diffstat (limited to 'src/main/scala/firrtl/Translator.scala')
| -rw-r--r-- | src/main/scala/firrtl/Translator.scala | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/main/scala/firrtl/Translator.scala b/src/main/scala/firrtl/Translator.scala index a16d89d7..152cd88e 100644 --- a/src/main/scala/firrtl/Translator.scala +++ b/src/main/scala/firrtl/Translator.scala @@ -51,29 +51,31 @@ object Translator val spaces = countSpaces(text) val l = if (text.length > spaces ) { // Check that line has text in it - if (newScope) { - scope.push(countSpaces(text)) - } else { - - // Check if change in current scope - if( spaces < scope.top ) { - while( spaces < scope.top ) { - // Close scopes (adding brackets as we go) - scope.pop() - ret.deleteCharAt(ret.lastIndexOf("\n")) // Put on previous line - ret ++= " }\n" - } - if( spaces != scope.top ) - throw new Exception("Spacing does not match scope on line : " + lineNum + " : " + scope.top) + if (newScope) { + if( spaces == scope.top ) scope.push(spaces+2) // Hack for one-line scopes + else scope.push(spaces) + } + + // Check if change in current scope + if( spaces < scope.top ) { + while( spaces < scope.top ) { + // Close scopes (adding brackets as we go) + scope.pop() + ret.deleteCharAt(ret.lastIndexOf("\n")) // Put on previous line + ret ++= " }\n" } - else if( spaces > scope.top ) - throw new Exception("Invalid increase in scope on line " + lineNum) + if( spaces != scope.top ) + throw new Exception("Spacing does not match scope on line : " + lineNum + " : " + scope.top) } + else if( spaces > scope.top ) + throw new Exception("Invalid increase in scope on line " + lineNum) + // Now match on legal scope increasers text match { case Scopers(keyword, _* ) => { newScope = true - text + " { " + //text + " { " + text.replaceFirst(":", ": {") } case _ => { newScope = false |
