Parses the specified module, checking function and variable references at the end. @param pth input path @param uri base URI of module @param info input info @throws QueryException query exception
(final String pth, final String uri, final InputInfo info)
| 802 | * @throws QueryException query exception |
| 803 | */ |
| 804 | public final void module(final String pth, final String uri, final InputInfo info) |
| 805 | throws QueryException { |
| 806 | |
| 807 | // get absolute path |
| 808 | final IO io = sc.resolve(pth, uri); |
| 809 | final byte[] tPath = token(io.path()); |
| 810 | |
| 811 | // check if module has already been parsed |
| 812 | final byte[] tUri = token(uri), pUri = qc.modParsed.get(tPath); |
| 813 | if(pUri != null) { |
| 814 | if(!eq(tUri, pUri)) throw error(WRONGMODULE_X_X_X, info, io.name(), uri, pUri); |
| 815 | } |
| 816 | else { |
| 817 | qc.modParsed.put(tPath, tUri); |
| 818 | |
| 819 | // read module |
| 820 | final String query; |
| 821 | try { |
| 822 | query = io.readString(); |
| 823 | } catch(final IOException expr) { |
| 824 | Util.debug(expr); |
| 825 | throw error(WHICHMODFILE_X, info, io); |
| 826 | } |
| 827 | |
| 828 | qc.modStack.push(tPath); |
| 829 | final QueryParser qp = new QueryParser(query, io.path(), qc, null); |
| 830 | qp.sc.resolver = sc.resolver; |
| 831 | |
| 832 | // check if import and declaration URI match |
| 833 | final LibraryModule lib = qp.parseLibrary(false); |
| 834 | qc.libs.put(tPath, lib); |
| 835 | final byte[] muri = lib.sc.module.uri(); |
| 836 | if(!uri.equals(string(muri))) throw error(WRONGMODULE_X_X_X, info, io.name(), uri, muri); |
| 837 | qc.modStack.pop(); |
| 838 | } |
| 839 | |
| 840 | // import the module's public types |
| 841 | final LibraryModule lib = qc.libs.get(tPath); |
| 842 | if(lib != null) { |
| 843 | for(final QNm qn : lib.types) { |
| 844 | if(declaredTypes.contains(qn)) throw error(DUPLTYPE_X, qn.string()); |
| 845 | declaredTypes.put(qn, lib.types.get(qn)); |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | /** |
| 851 | * Parses the "ContextValueDecl" rule. |