click below
click below
Normal Size Small Size show me how
PL Quiz 2
Question | Answer |
---|---|
Syntax meaning | The form or structure of the expressions, statements, and program units. |
Semantics | The meaning of the expressions, statements, and program units |
Language definition | The syntax and semantics of a language |
Language definition users | Initial evaluators, implementers, programmers |
Compilation phases | Lexical analysis, syntax analysis, semantics analysis, code generation |
Lexical analysis | lexical analyzer splits source code into tokens |
Token | The syntactic category that forms a class of lexemes |
lexeme | A sequence of characters that matches the pattern for a token |
Meta-language | A language used to define other languages |
grammar | a meta-language used to define the syntax of a language |
Recognizer | Reads input strings and gives yes or no on whether the input strings belong to the language. Is a part of syntax analysis |
Generator | Generates a random valid sentence of a language |
How do recognizers and generators work together | Generators create sentences that are then used to create a recognizer |
Context-free grammars | 4 classes of generative devices or grammars that define four classes of languages |
BNF | A natural notation for describing syntax. It's equivalent to context-free grammars |
BNF fundamentals | Start symbol, finite set of production rules, finite set of terminal symbols, and a finite set of non-terminal symbols |
Terminals | Lexemes or tokens. They are the most basic syntactic units |
Non-terminals | Abstractions used to represent classes or syntactic structures. Often enclosed in angle brackets |
Production rules | Left-hand side or right-hand side |
Static type binding | Binding that occur before run time and remain unchanged throughout program execution |
Dynamic binding | Binding that first occur during execution or can change during execution of the program |
static binding types | Explicit declaration and implicit declaration |
Dynamic type binding pros and cons | It's flexible and can create generic programs. But it's high cost and does run time checking |
Middle ground binding | Type hinting which is dynamic, and type inference which is static |
Storage binding | Allocation, getting a cell and deallocation, putting a cell back into pool |
lifetime | Time that a variable is bound to a memory cell |
Static variable | bound to memory cell before and during execution |
Static variable advantages | Efficient, globally accessible, and history sensitive subprogram support |
Static variable disadvantages | Lack of flexibility, no recursion, no shared storage |
Stack dynamic | Storage binding are created for variables when this declaration statements are elaborated |
Stack dynamic advantages | Allows recursion, conserves storage |
Stack dynamic disadvantages | Overhead of allocation and deallocation, subprograms not history sensitive, inefficient references |
explicit heap dynamic | Allocated and deallocated b explicit directives during execution. Dynamic objects. |
explicit heap dynamic disadvantages | inefficient, unreliable, complex storage management |
implicit heap-dynamic variables | allocation and deallocation caused by assignment statements |
implicit heap-dynamic variables advantages and disadvantages | flexibility, but also inefficient |
types of scope | static scope and dynamic scope |
static scope access | Can call alongside and above but can only see itself and above |
static scoping advantages | Works well in most situations, programs are easy to reason about |
static scoping disadvantages | Too much access is possible sometimes, variables can be accessed when not needed, subprograms gravitate towards becoming global instead of nested |
Dynamic scope use | In exception handling |
Dynamic scope advantage | Convenience, the called subprogram is executed in the context of the caller |
Dynamic scope disadvantages | Poor readability, programs are difficult to reason about. No static type checking. All variables from caller are visible to called subprogram |
Referencing environments | The collection of all names that are visible at the statement |
Static scoped language referencing environment | The local variables plus all visible variables in all of the enclosing scopes |
Dynamic-scoped referencing environment | The local variables plus all visible variables in all active subprograms |