Compilers Final Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

difference(s) between an interpreter versus a compiler

Interpreters have: Immediate Response, Runtime allocation of resource is possible (e.g., change of the size of a matrix, type of the variable), Better diagnostics, but Slower in certain programming constructs (loops): it analyzes the loop block statement for each loop execution

parse tree

Tree that represents legal sentences

cross compiler

a compiler that generates an object code for a machine that is different from the machine on which the compiler runs

Regular Expression

a means to describe languages. They are a more compact way to define a language that can be accepted by an FA

Compiler

a software(program) that translates a program written in a source language (source code) into the code in the object language of a target machine (object code)

left hand derivation

always replace the leftmost nonterminal

Machine Language

the native language of the computer in which executable programs are written

motivation for FOLLOW sets

the sets tell us what set of rules to apply in case the FIRST set contains epsilon

motivation for FIRST sets

the sets tell us which rule(s) to select based on what is the first token in the list

Multiple Pass Compiler

two or more passes are necessary to create the object code

Examples of High Level Programming Languages

C, C++, Java, Pascal, Ada, Fortran, Cobol, Scheme, Prolog, Smalltalk

NSFM (Nondeterministic Finite State Machine) with Epsilon transitions

Edges may be labeled with ε (epsilon), the empty string. The automaton can make an ε epsilon transition without consuming the current input character

DFSM (Deterministic Finite State Machine)

No state has more than one outgoing edge with the same label

LL(k) parser

Predictive parser with left to right scan of tokens and leftmost derivation for k character look ahead

top-down parsing

Starts at the root of the parse tree and tries to reconstruct the growth of the tree that led to the given token string

NFSM (Nondeterministic Finite State Machine)

States may have more than one outgoing edge with same label

grammar

A finite set of rules for generating an infinite set of sentences

ambiguous grammar

A grammar if there are two different parse trees for some words in L(G)

context-free grammar

Grammar where the left hand side is a single non terminal character

Examples of strongly typed languages

Imperative: uses statements that change a program's state - von Neumann (Fortran, Pascal, Basic, C) - object-oriented (Smalltalk, Eiffel, C++?, Java) - scripting languages (Perl, Python, JavaScript, PHP) Declarative: expresses the logic of a computation without describing its control flow; programs as theories of a formal logic, and computations as deductions in that logic space - functional (Scheme, ML, pure Lisp, FP) - logic, constraint-based (Prolog, VisiCalc, RPG)

examples of Assembly Language

LR 3,5; it causes the computer to copy the contents of general register 5 into general register 3

Why does left-recursion not work for a top-down parser?

The input will not change and the parse tree will continue to grow. Infinite recursion

lexical analysis/lexical scanning/tokenizing

breaks the source code up into meaningful units called tokens

high level programming language

closer to human languages and more or less independent of a particular type of computer

right hand derivation

each step always replace the rightmost nonterminal

strongly-typed language

everything must be declared by the programmer before use

Native Code

executable program; it consists of bit strings

interpreter

executes the source without creating an object code Ex. Basic, Lisp

Linker

provides the run-time library to the object code and generates an executable code

single pass compiler/one pass compiler

reads the source and writes the object code into a file; example: Pascal compiler

derivation

replacing one non-terminal symbol at a time in order to recognize a sentence

Assembly Language

the first and most primitive programming language


Set pelajaran terkait

NU140- Chapter 3 Health, Wellness, and Health Disparities

View Set

B.2.3 CompTIA A+ 220-1101 (Core 1) Domain 3: Hardware

View Set

Behavioral neuroscience - research methods

View Set

CMED 116: The Back Pt. 1 (The Vertebrae)

View Set

Chapter 17 Patho taken from http://thepoint.lww.com/Book LEVEL 3 MASTERY

View Set

Chapter 23: Children and Adolescents

View Set