summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/interpreter/interpreter.tex
blob: 3f58083dd7214440953197f756effd1bb6f47b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
% This is the main TeX file for the Interpreter package.
% Further information in interpreter-doc.pdf or interpreter-doc.txt.
%
% Paul Isambert - zappathustra AT free DOT fr - December 2011
%
\csname Oh no, Interpreter won't be loaded twice!\endcsname
\expandafter\let\csname Oh no, Interpreter won't be loaded twice!\endcsname\endinput
\directlua{require("interpreter.lua")}
\def\interpretergobble#1{}
\unless\ifdefined\interpreterinput
  \let\interpreterinput\input
\fi
\def\interpretfile#1#2{%
  \directlua{%
    local f = kpse.find_file("i-#1.lua")
    if f then
      interpreter.reset()
      dofile(f)
      if interpreter.type"register" == 0 then
        if luatexbase and luatexbase.add_to_callback then
          function interpreter.register (f)
            luatexbase.add_to_callback("open_read_file", f, "interpreter")
          end
        else
          function interpreter.register (f)
            callback.register("open_read_file", f)
          end
        end
      end
      interpreter.register(interpreter.core.reader.input)
      tex.print([[\noexpand\interpreterinput]])
    else
      tex.error("I can't find file `i-#1.lua'. I won't input file `#2'")
      tex.print([[\noexpand\interpretergobble]])
    end
    }{#2}%
  }