Validation in Dijkstra's shunting yard algorithm | Linux Today

Validation in Dijkstra’s shunting yard algorithm

Written By
Web Webster
Web Webster
Nov 1, 2010

[ Thanks to Erik for
this link. ]

“In a previous blog post, I argued that it is perfectly
possible to extend Dijkstra’s shunting yard algorithm to parse
function calls and object-oriented expressions. It actually does
not take that much effort to extend the algorithm to do so. This
means that you could happily build an entire compiler or scripting
engine with the algorithm, that would be able to accept typical
modern programming language source code, such as C, Javascript,
Php, Perl, Java, and so on. Dijkstra’s algorithm simplifies
compiler construction by doing away with AST trees. In this
approach they become obsolete. Dijkstra’s algorithm immediately
generates intermediate language, that can easily be translated into
executable bytecode or CPU-specific machine language.

“Unfortunately, the algorithm will still happily parse invalid
source code. In my impression, it would be wrong to burden
Dijkstra’s algorithm with attempts to validate the source code. It
would complicate the algorithm to no end, while it would be quite
hard to implement complete validation of the source code.
Therefore, I believe that we should rather use a validator program
that precedes Dijkstra’s algorithm, and that fails when the source
code supplied is invalid. From there, Dijkstra’s algorithm would be
guaranteed to parse only valid source code, and does no longer need
to perform validations by itself.”


Complete Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.