]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/parser.cpp
Emit source file markers in compiled files
[libs/datafile.git] / source / parser.cpp
index 06e5a8c33745e78e3855a32f4148e939e93e390f..ade1dd98e40904412e842a91666b6670e6a124aa 100644 (file)
@@ -4,8 +4,7 @@ This file is part of libmspdatafile
 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
-#include <cctype>
-#include <sstream>
+#include <msp/strings/formatter.h>
 #include "binaryparser.h"
 #include "parser.h"
 #include "statement.h"
@@ -18,6 +17,7 @@ namespace DataFile {
 
 Parser::Parser(IO::Base &i, const string &s):
        in(i),
+       main_src(s),
        src(s),
        good(true),
        mode(new TextParser(in, src))
@@ -48,6 +48,14 @@ Statement Parser::parse()
                                delete mode;
                                mode=new TextParser(in, src);
                        }
+                       else if(st.keyword=="__src")
+                       {
+                               string s=st.args[0].get<string>();
+                               if(s.empty())
+                                       src=main_src;
+                               else
+                                       src=format("%s[%s]", main_src, s);
+                       }
                        else
                                return st;
                }