 (Larger Image)
|
Building Parsers With Java(TM)
by Steven John Metsker
Product Group: Book
Publisher: Addison-Wesley Professional (2001-04-05)
ISBN: 0201719622
EAN: 9780201719628
UPC: 785342719628
Dewey Decimal #: 005.133
Paperback: 400 pages
SKU: 110508000167
Condition: Fine
Comments: 0201719622 New, never read, may have minor wear on cover.
|
Editorial Reviews
|
Product Description
(Pearson Education) An in-depth explanation of how to create parsers that recognize custom programming languages. The CD-ROM contains all of the examples from the text, the parser toolkit, and other helpful materials. System requirements not listed. Softcover. DLC: Java (Computer program language).
|
Customer Reviews
|
caution - ignore bad reviews
Rating (5)
Date: 2008-04-11
1 out of 1 customers found this reveiw helpful
this review is intended to help potential customers better decide for themselves ; i was nearly dissuaded from purchasing a copy due to the reviews by inexperienced ( and apparently lazy ) programmers
the provided code, and related concepts, are examined fully in the text. the code is so OOP-trivial ( this is a good Java design rather than rehashed procedural code clumsily ported to the OO-Language du-jour ) that anyone familiar with the basics of Java, C++ or C# should be able to compose their own library in a short period of time. in the preface the author suggests the reader be familiar with Design Patterns and UML, but he has included sections which address the minimal use he makes of UML. most 'somewhat experienced' programmers will be able to see through the scant UML diagrams to the underlying concepts they address, but he explains the notation anyway. as for Patterns, they are mentioned in passing but are not examined in any way which might hinder the uninitiated
one reviewer laments that ''... the author's explanation of his code library is virtually non-existent -- you're going to have to figure out what he's talking about all on your own'' - this was not the same book i read. in addition to including comprehensive javadoc ( Java documentation in HTML format is provided on the CD as well as his web site, if you're buying a used copy ) to help guide readers interested in ''digging into his code'', the author walks the reader through the concepts presented in this book in an incremental and rather intuitive way. starting from ''the ground-up'' is not always a good idea, and i'm glad this author followed his instincts rather than the herd
the code supplied is working code ( a feat almost unheard of today ), the examination of which helps to illustrate function better than any equivalent volume of text could. in fact the code is so well decomposed in terms of OOP that the text cannot fail to assist even entry-level programmers in the creation of their own parsers using the concepts presented. as for the difficulty of making oneself independent of 'his toolkit', i can only say that more than 95% of the class methods are under ten lines of code ( most are under six ), so it seems that anyone willing to apply themselves should be able to succeed in doing so ; especially considering the fact that his included code covers far more ground than a more sharply focused ( 'real world' ) implementation would ( meaning that, in terms of volume, you would only need to write or implement a tiny fraction of what is included with the book to satisfy any specific implementation )
some reviewers have unambiguously reported putting the concepts presented in this book to work - and quickly - which says a great deal given the perceived complexity of the subject. indeed, creating a parser for a macro assembler for a particular embedded processor was so trivial ( thanks to the concepts in this book ) that i am confident modifying it for other targets will be trivial, as it was modeled after the author's OOP examples. having said that, the OOP perspective this author has provided seems the principal way in which this book is differentiated, making space for itself in an already crowded marketplace
ignorance of the subject matter can be blamed for many of these negative reviews ; some reviewers are so unfamiliar with the subject matter as to call all compiler related concepts 'black-box'. each of the compiler books on my shelf examines a recursive descent parser, but in a far less practical way, and typically in pseudo-code ( including a prominent example claiming to use Java, but instead presenting what i consider to be nothing more than procedural C pseudo-code fragments ). BPWJ follows a preferable route, and anyone who has inordinate difficulty might better fail with a more abstract text on the subject before blaming this author for their own inadequacies
one reviewer complains about the onus of being expected to participate in order to gain comprehension by stating ''To compound it, that code can be a bit perplexing when 95% of his variables have one-letter names -- it just isn't very readable if you're not already familiar with his ideas and approach'', which mystifies me, given that well over 95% of the class methods are under ten lines of code ( most are under six ) ... what kind of neurological damage would account for an inability to retain the type of an identifier within the span of six lines ?
for example :
Token t = new Token();
Assembly a = new Assembly();
String s = "some string given the highly problematic identifier s''
should the time a programmer saves by using OOP be squandered on thinking up unnecessary, lengthy names whose lifespan is less than ten lines ? especially considering that peripheral vision will nearly always encompass the code in question, a scant few lines above ? now ... what was 't' again ???
to round-out his list of disappointments, this same reviewer states ''The good news is that you'll be up and running and writing simple grammars and parsers in very little time. The bad news is that if you're working on anything [...] find yourself forced to peer into the black box to figure what the heck [his code] actually IS doing'', with which i agree - the code included is not geared to any specific project you may have in mind ; rather it is nearly exhaustive so that a working example for you to study is always at hand. warning : you will need to participate if you wish to make use of what you can learn by studying this book. if you are willing to do that, success can be yours ... passively being granted mastery in any area of programming ? i'll take the Vegas odds on that !
another reviewer makes several complaints ... in order : ''(1) ... everything is so dependent on the included framework makes it difficult to learn from. (2) I think the best programming books teach you how to build step-by-step from the ground up. (3) Instead, this book expects you to immerse yourself in the code first''
(1) the code, and related concepts, are examined fully in the text. the code is well designed OOP, rather than a ham-fisted port of procedural code, meaning that anyone with minimal experience in any OO language should be able to write their own, rapidly turning his ''fascinating ideas'' into a coded reality all their own
(2) as for ''learning from the ground up'', the text progresses slowly, beginning with a general overview ( to help readers get their bearings within the overarching conceptual framework being presented ) and moving into actual, albeit initially trivial, examples ( as any good programming book should ) and progresses from that point with chapters focusing on discrete aspects of the subject, as well as considering various implementation domains
(3) good code ( especially *working* code ) helps to illustrate function better than any equivalent volume of text could. having said that, the author forces no one to immerse themselves in code. naturally code is presented - this is a programming book after all, and not a purely theoretical one. the presented code is so well decomposed ( into OO Java ) that the text cannot fail to guide a programmer in the creation of his own parsers using the concepts presented ... so making oneself independent of his 'framework' seems trivial enough, given, again, a minimal competency in nearly any relatively modern OO language. as already indicated, the code is slowly examined initially, and given the brevity of procedures ( mentioned above ) it seems reasonable that anyone willing to apply themselves should be able to master the concepts presented in this book
i cannot abide an above average programming text being trashed by the inexperienced, who might have anticipated possessing ''mad 3l33t haxor skilz'' after flipping through the pages - reviewers reporting having used the material presented in this book tell us more than any failure ever could
warning : anyone who considers studying clear Java code difficult, or is unwilling to expend the effort needed to succeed in learning a new task, should avoid this book and every other book on the subject. perhaps IDG should be made aware of the sales they could expect for a new 'Dummies' title. then these unhappy campers could enjoy cartoons ( ''to spice things up'' ) and be given strained examples, twisted for the sole purpose of setting-up some moronic joke
one note about the code : it was written under an early version of Java ( the book was published in 2001, remember ) and to bring it up to current standards will require hitting the files over the head with a compiler. NetBeans quickly directed me to add annotations, mostly @pragma, which took a few minutes. not a big deal, but now you know
OK, now it's up to you to choose
|
|
Great Book for Building a Compiler
Rating (5)
Date: 2007-12-10
Before reading the book I was unsure of where to start. We had a large language, similar to Java which we wanted to parse, and we wanted to do it without using a compiler-compiler. By changing the author's design slightly so that the parsers were singletons and only a single assembly was ever created, we were able to parse large and complex files very quickly. More importantly, the design is such that making changes to your language is a snap. This was a must for us since our language is still in flux. If you have any kind of language you need to parse, Java is your implementation language, and for whatever reason you cannot use a compiler-compiler, then this is the book for you. The author's code included with the book will get you on your feet and running quickly. If Java is not your implementation language then keep in mind that the patterns taught in this book will work in any Object-Oriented language. Thanks to this book we now have an a new programming language which we have open sourced. Five-stars, thanks so much for the great book!
|
|
Good practical book on building parsers
Rating (5)
Date: 2006-08-12
4 out of 4 customers found this reveiw helpful
This book does not assume that you understand compilers or programming language theory. However, the beauty and eloquence of what the book is trying to teach you will be far clearer if you do understand these disciplines. This book teaches you how to build nondeterministic recursive-descent parsers. If you are interested in other kinds of parsers, then you need to consult another source. The classic source on these other kinds of parsers is "Compilers: Principles, Techniques, and Tools" by Aho, also known as "The Dragon Book".
This book explains how to write parsers for new computer languages that you create. Each chapter focuses on either background, techniques, or applications. A chart at the beginning of chapter one shows you which chapter focuses on each topic. Each chapter builds on the material presented in preceding chapters, so you should probably proceed through this book linearly. I review this book in the context of the table of contents:
1. Introduction - Just performs an overview of the book.
2. The Elements of a Parser - Explains what a parser is, introduces the building blocks of applied parsers, and shows how to compose new parsers from existing ones.
3. Building a Parser - Explains the steps in designing and coding a parser.
4. Testing a Parser - How to test a new language's features and also how to use random testing to detect ambiguity and other problems.
5. Parsing Data Languages - Shows how to create a parser that reads the elements of a data language. A data language is a set of strings that describe objects following a local convention.
6. Transforming a Grammar - How to ensure the correct behavior of operators in a language and how to avoid looping in a parser, which can follow from loops in a grammar.
7. Parsing Arithmetic - This chapter develops an arithmetic parser. Arithmetic usually appears as part of a larger language.
8. Parsing Regular Expressions - develops a regular expression parser. A regular expression is a string that uses symbols to describe a pattern of characters.
9. Advanced Tokenizing - Describes the tokenizers that are part of the Java programming language as well as the customizable tokenizer of this particular book. Tokenizing a string means breaking the string into logical nuggets so that you can define your parser in terms of these nuggets rather than individual characters.
10. Matching Mechanics - Explains how the fundamental types of parsers in this book match text.
11. Extending the Parser Toolkit - How to extend a parser toolkit which includes introducing new types of terminals or completely different parser types.
12. Engines - Introduces a logic engine, which is a piece of software that is able to return objects and groups of objects in response to a logical query.
13. Logic Programming - Shows how to program with facts and rules.
14. Parsing a Logic Language - How to construct a parser for a logic language. It shows how to build a parser for the Logikus programming language that was introduced in the previous chapter.
15. Parsing a Query Language - Constructs a parser for a query language. A query language parser translates textual queries into calls to an engine. The engine proves the query against a source of rules and data and returns successful proofs as the result of the query.
16. Parsing an Imperative Language - Shows how to create a parser for imperative languages. An imperative language parser translates a textual script into a composition of commands that direct a sequence of actions.
17. Directions - Points out areas for further reading and programming.
I used this book to create a parser for a visual language, and I found the instructions in this book very complete and helpful. I would recommend the following books if you are interested in getting deeper into the theory behind this book - "Programming Language Pragmatics" and also "Introduction to the Theory of Computation" by Sipser.
|
|
A superb book that will let you write your own language parsers in just a few days
Rating (5)
Date: 2005-12-21
3 out of 3 customers found this reveiw helpful
One of the best programming related books I have found. It certainly is one of the most original and most enjoyable reading materials I have found. And having read a lot, that says something :)
Steven provides the reader a strong Java framework for building your own language parsers, and contrary to some reviews I've found, he's right to do so, since he introduces a very complex issue simplifying it to the point that in just a couple of days you can write your own parsers.
This book is a member of a very few select of books that should be considered "Must Have". It's one of those purchases you will not regret.
|
|
Nice if you want to write your own scripting language/input
Rating (3)
Date: 2005-10-22
8 out of 10 customers found this reveiw helpful
I own arround 80 books about compiler/language design, and this is what I have to say about this book.
It's a FIVE star, if you are looking for a easy cookbook to deal with simple free text input in your application (e.g. a command line to enter commands in your application, or write your own scripting language).
However it's a ONE star, if you want to learn or write your own compiler or want to deal with very complex free format text input (e.g. a real programming language). This book doesn't really cover the theory behind parsing and scanning although there are some chapters about Logic programming.
Everyone can read this book. It doesn't rely on 'higher math'. It is not a dry text. With this book everyone can write a descent text processor.
The problem with this book (which is a advantage for novice people, and a disadvantage for people who want to learn something about compiling), is that this book rely on a parsing/scanning/interpreter framework/library of the author. This framework is not described in this book. You only learn how to use this framework. This is nice for people who only want to build a parser based on this framework, but a disadvantage for people who want to learn something about the theory or the algorithms (used in this framework or in parsers/scanners in general).
|
|
|