预计阅读本页时间:-
Chapter�Minilanguages
Finding a Notation That Sings
Table of Contents
广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元
Understanding the Taxonomy of Languages
Case Study: sng
Case Study: Regular Expressions
Case Study: Glade
Case Study: m4
Case Study: XSLT
Case Study: The Documenter's Workbench Tools
Case Study: fetchmail Run-Control Syntax
Case Study: awk
Case Study: PostScript
Case Study: bc and dc
Case Study: Emacs Lisp
Case Study: JavaScript
Choosing the Right Complexity Level
Extending and Embedding Languages
Writing a Custom Grammar
Macros — Beware!
Language or Application Protocol?
One of the most consistent results from large-scale studies of error patterns in software is that programmer error rates in defects per hundreds of lines are largely independent of the language in which the programmers are coding.[78] Higher-level languages, which allow you to get more done in fewer lines, mean fewer bugs as well.
Unix has a long tradition of hosting little languages specialized for a particular application domain, languages that can enable you to drastically reduce the line count of your programs. Domain-specific language examples include the numerous Unix typesetting languages (troff, eqn, tbl, pic, grap), shell utilities (awk, sed, dc, bc), and software development tools (make, yacc, lex). There is a fuzzy boundary between domain-specific languages and the more flexible sort of application run-control file (sendmail, BIND, X); another with data-file formats; and another with scripting languages (which we'll survey in Chapter�/a>).
All sufficiently complicated specification files aspire to the condition of minilanguages. Therefore, it will often be the case that your only defense against designing a bad minilanguage is knowing how to design a good one. This need not be a huge step or involve knowing a lot of formal language theory; with modern tools, learning a few relatively simple techniques and bearing good examples in mind as you design should be sufficient.
In this chapter we'll examine all the kinds of minilanguages normally supported under Unix, and try to identify the kinds of situation in which each of them represents an effective design solution. This chapter is not meant to be an exhaustive catalog of Unix languages, but rather to bring out the design principles involved in structuring an application around a minilanguage. We'll have much more to say about languages for general-purpose programming in Chapter�/a>.
We'll need to start by doing a little taxonomy, so we'll know what we're talking about later on.
[78] Les Hatton reports by email on the analysis in his book in preparation, Software Failure: “Provided you use executable line counts for the density measure, the injected defect densities vary less between languages than they do between engineers by about a factor of 10”.
Process Partitioning at the Design Level Home 燯nderstanding the Taxonomy of Languages