%\input luaotfload.sty
%\font\pt = file:pala.ttf at 14pt
\documentclass[12pt]{article}
\usepackage{fontspec}\setmainfont{Palatino Linotype}
\newwrite\luadebug
\immediate\openout\luadebug luadebug.lua
\AtEndDocument{\immediate\closeout\luadebug}
\def\directluadebug{\immediate\write\luadebug}

\directlua{dofile("lgr2utf.lua")}

%\newcommand{\greektilde}{\char126}
\newcommand{\cbgreek}[1]{%
%\def\cbgreek#1{%
 \bgroup
%   \let~\greektilde
%  \scantokens{%
%  #1
%  }%
  \leavevmode{\scantokens{%
  \catcode`<=11\catcode`>=11\catcode`~=11%
    \directlua{lgr2utf("\luatexluaescapestring{#1}")}%
%    \directlua{lgr2utf(#1)}%
}}% scantokens
%  \scantokens{\directlua{lgr2utf(#1)}}%
 \egroup
  }

\begin{document}
%\pt

Aristotle begins the {\it Topics} saying: \cbgreek{<H m`en pr'ojesic t~hc pragmate'iac m'ejodon 
e<ure~in >af'' >~hc dunhs'omeja sullog'izesjai per`i pant`oc to~u protej'entoc probl'hmatoc >ex >end'oxwn}.%
\footnote%*
{By contrast, the {\it Analytics} begins stating: \cbgreek{Pr~wton e>ipe~in per`i t'i ka`i t'inoc >est`in <h sk'evic, <'oti per`i >ap'odeixin ka`i >epist'hmhc >apodeiktik~hc}.}

\end{document}
%\bye
