diff options
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 |
