[Lazarus] How to write an eficient lexical scanner/parser?
leledumbo
leledumbo_cool at yahoo.co.id
Wed Mar 11 10:38:50 CET 2015
> However, I have a question: is there any article about 'how to write
lexical parsers' using Object Pascal?
First, you need to differentiate them correctly. Lexical scanner (or simply
lexer) and parser, not lexical parser :)
I've written some simple languages, generating GraphViz, LLVM or C code,
using both self learning reference from the almighty Prof. Niklaus Wirth's
articles, Jack Crenshaw's, the legendary dragon book and many others plus my
compiler course in college.
I really really suggest Prof. Niklaus Wirth's one
(http://www.inf.ethz.ch/personal/wirth/, click the Compiler Construction
link) as it's concise, simple, doesn't use stupid generator (i.e.: easy to
implement by hand) while covering most important parts of the subject. While
he didn't use or stress or even discourage the usage of abstract syntax
tree, he did explain it that's good enough to understand.
Here's what I've written in the past and is publicly available:
- https://bitbucket.org/leledumbo/erd-maker (generates GraphViz code for ERD
visualization)
- https://bitbucket.org/leledumbo/linguc (generates LLVM code that can be
compiled as a library for a mathematically provable language focusing in
database driven application)
I don't use the direct code generation approach anymore as I found the
abstract syntax tree to be usable for more than just code generation.
--
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-How-to-write-an-eficient-lexical-scanner-parser-tp4041002p4041083.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.
More information about the Lazarus
mailing list