Commit f2e35572 authored by Andrew Twyman's avatar Andrew Twyman

Merge pull request #190 from guycnicholas/root_djinni_file_error

Fix imports for files in the root directory
parents 1a25dbb4 bd30f7ee
......@@ -39,14 +39,19 @@ private object IdlParser extends RegexParsers {
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 =>
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
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