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() {
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
def idlFile(origin: String): Parser[IdlFile] = rep(importFile) ~ rep(typeDecl(origin)) ^^ { case imp~types => IdlFile(imp, types) }
def importFile: Parser[FileRef] = ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ {
case "import" ~ x =>
val newPath = fileParent + x
new IdlFileRef(new File(newPath))
case "extern" ~ x =>
val newPath = fileParent + x
new ExternFileRef(new File(newPath))
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 = fileParent + x
new IdlFileRef(new File(newPath))
case "extern" ~ 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