Commit bd30f7ee authored by Guy Nicholas's avatar Guy Nicholas

Moved fileParent into importFile per feedback

parent 523f2f3f
...@@ -33,20 +33,24 @@ case class Parser() { ...@@ -33,20 +33,24 @@ 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] = {
case "import" ~ x =>
val newPath = fileParent + 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 = fileParent + 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