Let $\mathcal{L_0}$ be the smallest set $L$ of finite sequences of $\textit{logical symbols}= \{(\enspace)\enspace\neg\}$ and $\textit{propositional symbols}=\{A_n|n\in\mathbb{N}\}$ for $n \in \mathbb{N}$ satisfying the following properties:
(1) For each propositional symbol $A_n$ with $n\in\mathbb{N}$, \begin{multline} A_n \in L. \end{multline}
(2) For each pair of finite sequences $s$ and $t$, if $s$ and $t$ belong to $L$, then \begin{multline} (\neg s) \in L \end{multline} and \begin{multline} (s \to t) \in L. \end{multline}
Problem: Give an algorithm (pseudocode) to determine whether a given finite sequence belongs to $\mathcal{L_0}$.
I was thinking something involving opening vs. closing parenthesis first, if they don't match in count. Or perhaps you could check if the sequence begins with a negation or an implication - that would automatically rule them out. This would be sort of a filter prior to the meat of the algorithm.
If you consult the book Introduction to Metamathematics by S. C. Kleene, you can find an algorithm for a distinct infix language which might give you some ideas here.
In Polish notation there exist several known algorithms. One of them is the following...
Then we sum those numbers left to right. For example
A string will end up as a formula in Polish notation if the numbers assigned to the symbols start and end with -1, or if those numbers start with 0 or 1, has -1 correspond to the last symbol, and only has -1 corresponding to the last symbol.