Commit 523f2f3f authored by Guy Nicholas's avatar Guy Nicholas

If djinni files were at the root level of the project and one file imported...

If djinni files were at the root level of the project and one file imported another it would fail with a "null/<filename>" not found.  This fix makes the fileParent a function that tests for nullness and just returns the empty string if necessary.
parent 1a25dbb4
......@@ -33,6 +33,7 @@ case class Parser() {
val visitedFiles = mutable.Set[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 {
override protected val whiteSpace = """[ \t\n\r]+""".r
......@@ -41,10 +42,10 @@ private object IdlParser extends RegexParsers {
def importFile: Parser[FileRef] = ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ {
case "import" ~ x =>
val newPath = fileStack.top.getParent() + "/" + x
val newPath = fileParent + x
new IdlFileRef(new File(newPath))
case "extern" ~ x =>
val newPath = fileStack.top.getParent() + "/" + x
val newPath = fileParent + x
new ExternFileRef(new File(newPath))
}
def filePath = "[^\"]*".r
......
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