Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
roccojiang committed Jun 17, 2024
1 parent 0107258 commit a87acf4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
Binary file modified src/background/parsers.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/background/parsers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ \subsection{The \texttt{parsley} Library}
\langle \mathit{atom} \rangle &::= \text{`\texttt{(}'} \; \langle \mathit{expr} \rangle \; \text{`\texttt{)}'} \enspace | \enspace
\langle \mathit{number} \rangle
\end{align*}
\caption{The grammar in \textsc{ebnf}.}
\caption{The grammar in e\textsc{bnf}.}
\label{fig:simple-grammar-ebnf}
\end{subfigure}
\hfill
Expand Down
Binary file modified src/evaluation/evaluation.pdf
Binary file not shown.
5 changes: 3 additions & 2 deletions src/evaluation/evaluation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ \section{Removing Left-Recursion}\label{sec:eval-leftrec}
\item How clear was the output? How does it compare to an idiomatic, manually fixed version?
\item Does the output compile?
\end{itemize}
% Given the nature of the transformation, it is difficult to provide quantitative metrics for evaluation, so the focus will be on qualitative aspects.
% Given the lack of a direct competitor, the evaluation will be based on the author's experience with the tool and the quality of the output produced.
%
The following examples assume the existence of a \scala{number} parser, defined the same way as earlier in \cref{sec:background-parsers}:
\begin{minted}{scala}
Expand Down Expand Up @@ -241,6 +239,9 @@ \subsection*{Summary}
\end{itemize}
% TODO: library ergonomics - see ethan's thesis
% e.g. Introduce implicit conversions rule -- stunted because no in-editor support
% want to be able to preview changes in editor, and also apply auto-fixes one by one
% TODO: benchmarks here?
% A large corpus of student WACC parsers is available to evaluate the real-world applicability of \texttt{parsley-garnish}.
Expand Down
Binary file modified src/introduction/introduction.pdf
Binary file not shown.
9 changes: 8 additions & 1 deletion src/introduction/introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
A linter with knowledge of the \texttt{parsley} library could help users by providing \emph{relevant} suggestions at the \emph{precise} location of the issue:
\begin{minted}{scala}
lazy val expr: Parsley[Float] = (expr, char('+') ~> term).zipped(_ + _)
\end{minted}
\vspace{-4ex}
\begin{minted}[baselinestretch=1]{scala}
// ^^^^^^^^^^^^^^^^^^^^
// Warning: This parser is left-recursive, which will cause an infinite loop when parsing.
// Suggestion: Refactor using chain combinators from the parsley.expr module,
Expand All @@ -77,6 +80,9 @@
Thus, a linter could also aid users in learning about \texttt{parsley} idioms and best practices:
\begin{minted}{scala}
lazy val atom: Parsley[Float] = char('(') ~> expr <~ char(')') | number
\end{minted}
\vspace{-4ex}
\begin{minted}[baselinestretch=1]{scala}
// ^^^^^^^^^ ^^^^^^^^^
// Info: Explicit usage of the 'char' combinator may not be necessary.
// Suggestion [auto-fix available]: Use implicit conversions:
Expand All @@ -88,6 +94,7 @@
// ─┬─ ─┬─
// Remove char combinators ────┴──────────────┘
\end{minted}
% ^ why do the box chars not connect vertically??
%
The aim of \texttt{parsley-garnish} is to provide relevant linting rules, like the above, to guide users towards writing improved \texttt{parsley} code.
With useful hints and automatic fixes, our hypothetical user can be steered towards a correct and idiomatic parser:
Expand All @@ -102,7 +109,7 @@
\end{minted}
%
With this definition of \scala{expr}, the parser is able to parse left-associative expressions without left-recursion, and the syntactic noise of the \scala{char} combinators has been removed.
Executing \scala{expr.parse("1+2*3/4")} now correctly evaluates to \scala{2.5}!
Executing \scala{expr.parse("1+2*3/4")} now evaluates to \scala{2.5}, as expected!

% Introduces domain-specific lint rules for Parsec-style parser combinator libraries
% Implementation of these rules for Parsley Scala
Expand Down

0 comments on commit a87acf4

Please sign in to comment.