mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-10 08:48:49 +00:00
Memoized CPS parser combinators, monadic version
This commit is contained in:
parent
fb9f6f4509
commit
f1f3c8aff0
2 changed files with 8 additions and 7 deletions
|
|
@ -72,11 +72,12 @@
|
||||||
\renewcommand{\emptyset}{\varnothing}
|
\renewcommand{\emptyset}{\varnothing}
|
||||||
\newcommand{\dom}[1]{\mathtt{dom}\;{#1}}
|
\newcommand{\dom}[1]{\mathtt{dom}\;{#1}}
|
||||||
\newcommand{\primi}[2]{\mathbf{#1}\;{#2}}
|
\newcommand{\primi}[2]{\mathbf{#1}\;{#2}}
|
||||||
\newcommand{\sial}{S\textit{\lower -.5ex\hbox{I}\kern -.1667em\lower .5ex\hbox {A}}\kern -.125emL\@\xspace}
|
\newcommand{\lama}{$\lambda\mbox{\textsc{Algol}}$\xspace}
|
||||||
|
%\newcommand{\sial}{S\textit{\lower -.5ex\hbox{I}\kern -.1667em\lower .5ex\hbox {A}}\kern -.125emL\@\xspace}
|
||||||
\definecolor{light-gray}{gray}{0.90}
|
\definecolor{light-gray}{gray}{0.90}
|
||||||
\newcommand{\graybox}[1]{\colorbox{light-gray}{#1}}
|
\newcommand{\graybox}[1]{\colorbox{light-gray}{#1}}
|
||||||
|
|
||||||
\lstdefinelanguage{sial}{
|
\lstdefinelanguage{lama}{
|
||||||
keywords={fun, case, esac, do, od, if, then, else, elif, fi, skip, repeat, until, for, local},
|
keywords={fun, case, esac, do, od, if, then, else, elif, fi, skip, repeat, until, for, local},
|
||||||
sensitive=true,
|
sensitive=true,
|
||||||
%basicstyle=\small,
|
%basicstyle=\small,
|
||||||
|
|
@ -99,12 +100,12 @@ commentstyle=\scriptsize\rmfamily,
|
||||||
basewidth={0.5em,0.5em},
|
basewidth={0.5em,0.5em},
|
||||||
fontadjust=true,
|
fontadjust=true,
|
||||||
escapechar=!,
|
escapechar=!,
|
||||||
language=sial
|
language=lama
|
||||||
}
|
}
|
||||||
|
|
||||||
\sloppy
|
\sloppy
|
||||||
|
|
||||||
\title{\sial Language Definition}
|
\title{\lama Language Definition}
|
||||||
|
|
||||||
\author{Dmitry Boulytchev}
|
\author{Dmitry Boulytchev}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ fun seq (a, b) {
|
||||||
--infixr |> after | (a, b) {seq (a, b)}
|
--infixr |> after | (a, b) {seq (a, b)}
|
||||||
|
|
||||||
infixr || before !! (a, b) {alt_k (a, b)}
|
infixr || before !! (a, b) {alt_k (a, b)}
|
||||||
infixr ||> after || (a, b) {seq_nm (a, b)}
|
infixr ||> after || (a, b) {seq_k (a, b)}
|
||||||
|
|
||||||
infix @ at * (a, f) {
|
infix @ at * (a, f) {
|
||||||
fun (k) {
|
fun (k) {
|
||||||
|
|
@ -171,8 +171,8 @@ local a = token_k ("a");
|
||||||
|
|
||||||
local as = memo (
|
local as = memo (
|
||||||
fun (k) {
|
fun (k) {
|
||||||
(empty_k || (as ||> a)) (k)
|
(empty_k @ fun (x) {""} || as ||> fun(as) {a @ fun (a) {as ++ a}}) $ k
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
as (print) ({"a", "a"})
|
(as ||> fun (as) {eof_k @ lift (as)}) (print) ({"a", "a"})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue