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,13 +39,18 @@ private object IdlParser extends RegexParsers { ...@@ -39,13 +39,18 @@ private object IdlParser extends RegexParsers {
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] = {
case "import" ~ x =>
val newPath = fileStack.top.getParent() + "/" + x def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return ""
new IdlFileRef(new File(newPath))
case "extern" ~ x => ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ {
val newPath = fileStack.top.getParent() + "/" + x case "import" ~ x =>
new ExternFileRef(new File(newPath)) val newPath = fileParent + x
new IdlFileRef(new File(newPath))
case "extern" ~ x =>
val newPath = fileParent + x
new ExternFileRef(new File(newPath))
}
} }
def filePath = "[^\"]*".r 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