7 \frametitle{\textsc{SPL
}}
8 \begin{block
}{Features
}
10 \item Implementation language:
11 Clean (
{\tiny\url{http://clean.cs.ru.nl
}})
15 \item Higher order functions
17 \item Using parser combinator library
\textsc{Yard
}
20 \item Positional data available for easy locating of errors.
22 \item Standardized parser errors. This means you can set it as
23 \texttt{buildprg
} in
\texttt{vim
} and you can then use the
29 \begin{frame
}[fragile
]
30 \frametitle{\textsc{YARD
}}
31 \framesubtitle{A minimal home grown monadic parser combinator library
}
33 \item Inspired by
\textsc{parsec
}: $
1pc=
3.375\cdot10^
{16}yd$~
\footnote{
34 A yard is exactly $
36$ inch and an inch is exactly the length
38 :: Error = PositionalError Int Int String | Error String
39 :: Parser a b = Parser (
[a
] -> (Either Error b,
[a
]))
42 \item Matches longest left-most parser
44 \item Stops immediately on error
\pause\\
49 \begin{frame
}[fragile
]
50 \frametitle{\textsc{YARD
} Combinators
}
52 instance Functor (Parser a)
53 instance Applicative (Parser a)
54 instance Monad (Parser a)
55 instance Alternative (Parser a)
57 runParser :: (Parser a b)
[a
] -> (Either Error b,
[a
])
58 (<?>) :: (Parser a b) Error -> Parser a b
62 satisfy :: (a -> Bool) -> Parser a a
63 check :: (a -> Bool) -> Parser a a
64 (until) infix
2 :: (Parser a b) (Parser a c) -> Parser a
[b
]
65 item :: a -> Parser a a | Eq a
66 list ::
[a
] -> Parser a
[a
] | Eq a
71 \section{Design choices
}
73 \frametitle{Adapting the grammar
}
75 \item Remove left recursion
76 \item Fixing associativity
77 \item Added small features such as escape characters
\texttt{
78 \textbackslash n
\textbackslash b
}
80 \item Show grammar now
\ldots
85 \frametitle{Two-phase design
}
86 \framesubtitle{Lexing
}
87 Also done with
\textsc{YARD
} because
89 \item Multiline comments
95 \begin{frame
}[fragile
]
96 \frametitle{Two-phase design
}
97 \framesubtitle{Parsing
}
98 Read from stdin, write to stdout\\
99 Added some handy primitives
101 parseBlock :: Parser Token
[Stmt
]
103 parseOpR :: (Parser Token Op2) (Parser Token Expr) -> Parser Token Expr
104 parseOpL :: (Parser Token Op2) (Parser Token Expr) -> Parser Token Expr
106 trans2 :: TokenValue (TokenValue -> a) -> Parser Token a
107 trans1 :: TokenValue a -> Parser Token a
109 peekPos :: Parser Token Pos
113 \begin{frame
}[fragile
]
114 \frametitle{Statistics
}
115 \framesubtitle{Lines of code
}
116 \lstinputlisting{|"wc -l ../../*.
[di
]cl"
}
119 \emph{``Measuring programming progress by lines of code is like
120 measuring aircraft building progress by weight.''
}\\
126 \frametitle{Statistics
}
127 \framesubtitle{Hours of work
}
128 We have no clue how much time we have worked on it
\ldots
131 \emph{``Choose a job you love, and you will never have to work a day in
139 \frametitle{Weird inputs
}
141 \item \pause Heap full
142 \pause\ldots Increase heap\\
143 \texttt{\$ ./spl -h
2000M
}
144 \item \pause Stack full
145 \pause\ldots Increase stack\\
146 \texttt{\$ ./spl -s
200M
}
147 \item \pause Segmentation fault
148 \pause\ldots Enable memory overcommitting\\
149 \texttt{\# echo
1 > /proc/sys/vm/overcommit
\_memory}
150 \item \pause Still segmentation fault
151 \pause\ldots Buy more
\textsc{RAM
}
152 \item \pause Still segmentation fault?
153 \pause\ldots Divide into modules and parse separatly~
\footnote{To be
155 \item \pause Thus, we are only limited by hardware
\ldots
160 \frametitle{Learned lessons
}
162 \item \pause Parser combinators are elegant!
163 \item \pause Positional errors are a must!