levo

Software Engineering and Program Construction

Lexical analysis and the symbol table

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

Overview

First stage of the compilation process, two things a lexical analyser removes from the source program and error can be detected during lexical analysis.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Process

What does a translator record about each identifier, and how is that record used by the stages that follow?

Process

What is the first stage of the compilation process?

Key term

State four items of information a symbol table entry may hold.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is the first stage of the compilation process?

    Model answer

    Lexical analysis, which reads the characters of the source program and groups them into the basic items of the language.

  2. 2

    What is a token?

    Model answer

    A token is a single meaningful item of the language, such as a keyword, an identifier, an operator, a number or a punctuation symbol, represented in a compact coded form.

  3. 3

    State two things a lexical analyser removes from the source program.

    Model answer

    It removes comments and unnecessary spacing such as spaces, tabs and blank lines, because neither affects the meaning of the program.

  4. 4

    Why does removing spacing and comments make the later stages easier?

    Model answer

    Later stages then work on a short, regular stream of tokens rather than on raw text whose layout can vary, so their rules can be about language structure alone.

  5. 5

    Explain how a lexical analyser distinguishes a keyword from a name the programmer has chosen.

    Model answer

    It compares each word it collects against the fixed list of words reserved by the language, and anything not on that list is treated as an identifier.

  6. 6

    What kind of error can be detected during lexical analysis?

    Model answer

    A character or symbol that is not part of the language at all, or a badly formed item such as a number containing a letter, can be reported at this stage.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

Fetch, , execute.
decodecompilestore

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Software Engineering and Program Construction, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.