Programming Language Concepts (Undergraduate Topics in Computer Science)
Format: PDF / Kindle (mobi) / ePub
Programming Language Concepts uses a functional programming language (F#) as the metalanguage in which to present all concepts and examples, and thus has an operational flavour, enabling practical experiments and exercises. It includes basic concepts such as abstract syntax, interpretation, stack machines, compilation, type checking, and garbage collection techniques, as well as the more advanced topics on polymorphic types, type inference using unification, co- and contravariant types, continuations, and backwards code generation with on-the-fly peephole optimization.
Programming Language Concepts covers practical construction of lexers and parsers, but not regular expressions, automata and grammars, which are well covered elsewhere. It throws light on the design and technology of Java and C# to strengthen students’ understanding of these widely used languages.
The examples present several interpreters and compilers for toy languages, including a compiler for a small but usable subset of C, several abstract machines, a garbage collector, and ML-style polymorphic type inference. Each chapter has exercises based on such examples.
of a let-bound variable can be removed once the entire let-expression has been evaluated. Thus we define a stack machine seval that uses a unified stack both for storing intermediate results and bound variables. We write a new version scomp of tcomp to compile every use of a variable into an offset from the stack top. The offset depends not only on the variable declarations, but also the number of intermediate results currently on the stack. Hence the same variable may be referred to by
JavaCC generates top-down or LL parsers, and these cannot handle grammar rules N ::= N ... in which the left-hand nonterminal appears as the first symbol in the right-hand side. Such rules are called left-recursive grammar rules; see for example the last three rules of the original Expr grammar: Secondly, in JavaCC one cannot specify the precedence of operators, so the grammar above is highly ambiguous. For these reasons, one must transform the grammar to avoid the left-recursion and to express
call the mergep method to merge two arrays of Strings. Class String implements Comparable
hardware, such as the AJ-80 and AJ-100 Java processors from aJile Systems . The Common Language Infrastructure is an abstract machine and a set of standard libraries developed by Microsoft since 1999, with very much the same goals as Sun’s JVM. The platform has been standardized by Ecma International  and ISO. Microsoft’s implementation of CLI is known as the Common Language Runtime (CLR) and is part of .NET, a large set of languages, tools, libraries and technologies. The first version
collector discovers that the object is dead and collects it. The purpose of a finalizer typically is to release some resource held by the object, such as a file handle or database handle. However, if little garbage is created, a long time may pass from the last use of an object till the garbage collector actually removes it and calls its finalizer. For this and other reasons, finalizers should generally be avoided; see Bloch [3, Item 7]. 10.6.3 Calling the Garbage Collector Most systems include