Stefan pushed to branch report/els-2017 at Stefan / Typer
Commits: e0136bf8 by Stefan Monnier at 2017-01-29T20:26:27-05:00 -
- - - - -
1 changed file:
- paper.tex
Changes:
===================================== paper.tex ===================================== --- a/paper.tex +++ b/paper.tex @@ -648,11 +648,19 @@ But these lexical rules pose a problem in our quest to have an ML-style syntax with a minimalist core: we want to be able to define a module system outside of the core language, and we also want to be able to use a syntax such as \texttt{String.concat} to refer to the \id{concat} function of the -\id{String} module. - -So after splitting tokens according to the above rules, each token is -\emph{parsed} using a grammar, even more limited than the OTG grammar -presented earlier, where \Char{.} can be given the status of infix +\id{String} module. Yet, we can't simply define \Char{.} to be +a \emph{single-char token} character and then define it as an infix +operator, because that would give us +\begin{displaymath} + \begin{array}{r@{\hspace{10pt}\equiv\hspace{10pt}}l} + \verb+String.concat a b+ & \verb+_._ String (concat a b)+ + \end{array} +\end{displaymath} +We could try to extend out OPG parser so as to allow infix operators to bind +more tightly than the ``space'', but instead we decided to do a two-level +tokenization: after splitting tokens according to the above rules, each +token is \emph{parsed} using a grammar, even more limited than the OPG +grammar presented earlier, where \Char{.} can be given the status of infix operator. We can again override this special handling of a given character by escaping it. So, the following equalities hold: \begin{displaymath} @@ -661,6 +669,10 @@ by escaping it. So, the following equalities hold: \texttt{a * M.b} & \verb+_*_ a (__.__ M b)+ \end{array} \end{displaymath} +One of the advantages of this two-level approach is that this allows us to +distinguish ``\verb+M.b+'' from ``\verb+M . b+''. Given the fact that +Typer, like Lisp, relies heavily on spaces as separators, we felt that +it was natural and important to be able to distinguish those two cases.
\section{Elaboration to core Typer} \label{sec:elaboration}
View it on GitLab: https://gitlab.com/monnier/typer/commit/e0136bf8413115f6cbac9f5d8d9bd3b22407...
Afficher les réponses par date