Language Processing Flashcards

(24 cards)

1
Q

scanning

A

maps characters into tokens and finds token syntax errors

a.k.a tokenising

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

flex

A

rule based scanner generator that constructs a DFA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

domain specific languages

A

a small language for a narrow purpose

aims to make it easy to write concise programs

flex is an example of a DSL for generating a scanner

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

parsing

A

builds parse trees (ASTs) from tokens

identifies phrase syntax errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

hand coded parsers

A

recursive descent or top-down parsing

some grammars cannot be processed with recursive descent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

parser generators

A

top-down or bottom-up parsers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

grammar categories

A

type 3 - regular grammar
type 2 - context-free grammar
type 1 - context-sensitive grammar
type 0 - free grammar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

type 3 grammar

A

finite state automata, state and transitions

next state = input + current state

useful for token recognition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

type 2 grammar

A

pushdown automata, FSA and stack

next state = input + current state + top of stack

useful for phrase recoginition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

interpreter

A

computes an answer from a parse tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

hand coded interpreter

A

tree walk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

interpreter generator

A

not used outside of research

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

type checking (lang processing)

A

interprets a program to verify its type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

type inference (lang processing)

A

interprets a program to compute its type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

tree interpreters

A

interpretation process is a tree walk

code for node type can change what is next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

graph interpreters

A

used in combinator redution languages

17
Q

linear interpretation

A

virtual machines like the JVM

mimics hardware in software, write once and run anywhere

18
Q

0-address architecture

A

architecture used by VMs where there are no registers and only a stack

operands are implicitly consumed from the top of the stack and results are pushed to the top of the stack

19
Q

instruction set design options

A
  • RISC style
  • less RISCy with compound instructions (use static profiling to choose compound instructions)
20
Q

program representation options

A
  • pure 0-address + byte codes
  • quasi 0-address + multibyte codes
21
Q

compiler

A

translates source program to target program

they can either
* generate target machine code
* generate intermediate machine code (VM code)

22
Q

intermediate languages

A
  • Microsoft Common Intermediate Language (.NET)
  • LLVM
  • any VM bytecode (e.g. JVM bytecode)
23
Q

three address code

A

idealised intermediate language

dst = src1 op src2

generated by doing a tree walk

24
Q

IR optimisation

A
  • common subexpression elimination (re use computed expressions)
  • copy propagation ( given a = b replace all a with b until b is written to)
  • dead code elimination (remove useless code, e.g. variables that aren’t read)
  • constant folding (b = 4 - 2 becomes b = 2)
  • algebraic transformations (simplify expressions like x + 0 or x * 1)
  • strength reduction (replace expensive operations with cheaper ones (x^2 becomes x * x, x * 2 becomes x + x)