Commit bd30f7ee authored by Guy Nicholas's avatar Guy Nicholas

Moved fileParent into importFile per feedback

parent 523f2f3f
...@@ -33,14 +33,17 @@ case class Parser() { ...@@ -33,14 +33,17 @@ case class Parser() {
val visitedFiles = mutable.Set[File]() val visitedFiles = mutable.Set[File]()
val fileStack = mutable.Stack[File]() val fileStack = mutable.Stack[File]()
def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return ""
private object IdlParser extends RegexParsers { private object IdlParser extends RegexParsers {
override protected val whiteSpace = """[ \t\n\r]+""".r override protected val whiteSpace = """[ \t\n\r]+""".r
def idlFile(origin: String): Parser[IdlFile] = rep(importFile) ~ rep(typeDecl(origin)) ^^ { case imp~types => IdlFile(imp, types) } def idlFile(origin: String): Parser[IdlFile] = rep(importFile) ~ rep(typeDecl(origin)) ^^ { case imp~types => IdlFile(imp, types) }
def importFile: Parser[FileRef] = ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ { def importFile: Parser[FileRef] = {
def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return ""
("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ {
case "import" ~ x => case "import" ~ x =>
val newPath = fileParent + x val newPath = fileParent + x
new IdlFileRef(new File(newPath)) new IdlFileRef(new File(newPath))
...@@ -48,6 +51,7 @@ private object IdlParser extends RegexParsers { ...@@ -48,6 +51,7 @@ private object IdlParser extends RegexParsers {
val newPath = fileParent + x val newPath = fileParent + x
new ExternFileRef(new File(newPath)) new ExternFileRef(new File(newPath))
} }
}
def filePath = "[^\"]*".r def filePath = "[^\"]*".r
def directive = importDirective | externDirective def directive = importDirective | externDirective
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment