1. Home
  2. Explore
  3. Computer Science
  4. Syntax Tree Project Overview

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Syntax Tree Project Overview

  • 21Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Parser Basics
The first step in parsing, which breaks plain text into chunks called tokens, is
analysis.

21 questions

  1. 1
    The first step in parsing, which breaks plain text into chunks called tokens, is
    _____
    analysis.
    Hint

    This step is about breaking text into meaningful tokens before understanding structure.

    Answer

    lexical

  2. 2
    The definition of how words can fit together to form larger concepts in a language is called
    _____
    .
    Hint

    Just like in English, this defines rules for combining words into phrases and sentences.

    Answer

    grammar

  3. 3
    The Syntax Tree project provides an object layer representing the result of parsing
    _____
    .
    Hint

    This language is the focus of the talk.

    Answer

    Ruby

  4. 4
    In Syntax Tree, nodes are
    _____
    by default, meaning they cannot be mutated after creation.
    Hint

    This property avoids side effects and makes reasoning about changes easier.

    Answer

    immutable

  5. 5
    The visitor pattern in Syntax Tree uses a technique called
    _____
    dispatch, where two methods are called to route the visit.
    Hint

    It involves both the node's accept method and the visitor's visit method.

    Answer

    double

  6. 6
    In the visitor pattern, the generic visit method accepts any node and then calls
    _____
    on that node.
    Hint

    This method is defined on every node and triggers the visitor callback.

    Answer

    accept

  7. 7
    The Ripper library is a standard Ruby parser that provides an
    _____
    -based parser.
    Hint

    Ripper fires methods as it parses, which you can define to handle tokens.

    Answer

    event

  8. 8
    Ripper does not provide
    _____
    information for nodes, which Syntax Tree must track separately.
    Hint

    This includes things like line numbers and character positions.

    Answer

    location

  9. 9
    Syntax Tree has fewer nodes than Ripper events because it merges some, such as the if node for both A if B and
    _____
    .
    Hint

    Both are conditional expressions with the same meaning.

    Answer

    if B A

  10. 10
    Comments in Ruby do not appear in Ripper's events; Syntax Tree attaches them after parsing using a
    _____
    search over child nodes.
    Hint

    This efficient search method helps find the best node to associate with a comment.

    Answer

    binary

  11. 11
    The prettyprint algorithm, which powers Syntax Tree's formatter, was developed in the early '90s by
    _____
    .
    Hint

    The author's name is mentioned in the context of the Prettier Printer paper.

    Answer

    Wadler

  12. 12
    In prettyprint, a
    _____
    is a node that indicates where the output can be broken onto new lines.
    Hint

    It allows the formatter to decide when to insert a line break.

    Answer

    breakable

  13. 13
    When the line is too long, the formatter breaks the
    _____
    group first.
    Hint

    It starts with the group that encloses the most code.

    Answer

    outermost

  14. 14
    The Syntax Tree CLI's match command outputs a Ruby expression that can be used in an in clause for
    _____
    matching against a node.
    Hint

    This expression exactly matches the source code given.

    Answer

    pattern

  15. 15
    The Syntax Tree CLI's search command uses pattern matching syntax to find nodes, and it can be combined with the output of the `
    _____
    ` command.
    Hint

    This command generates the pattern you can then search for.

    Answer

    match

  16. 16
    The Language Server Protocol (LSP) runs a
    _____
    RPC server behind an editor to provide language features.
    Hint

    The protocol uses a common data interchange format.

    Answer

    JSON

  17. 17
    Syntax Tree can translate its nodes into the syntax tree used by RuboCop, which is the
    _____
    parser.
    Hint

    This parser is named after its author's GitHub handle.

    Answer

    whitequark

  18. 18
    The YARV visitor in Syntax Tree compiles nodes into instruction sequence objects that represent
    _____
    code.
    Hint

    YARV is the Ruby VM; its instructions are similar to bytecode in other VMs.

    Answer

    bytecode

  19. 19
    The mutation visitor in Syntax Tree uses the `
    _____
    ` method to create a new tree after applying changes.
    Hint

    This method creates a modified copy of the node without mutating the original.

    Answer

    copy

  20. 20
    Kevin Newton is working on a new Ruby parser at Shopify that will be more efficient, error tolerant, and
    _____
    .
    Hint

    The new parser aims to be easier to maintain and use across platforms.

    Answer

    portable

  21. 21
    The Pretty Ruby formatter previously had tens of thousands of lines of code but is now a thin wrapper around
    _____
    .
    Hint

    This is the name of the project presented.

    Answer

    Syntax Tree

1 of 21
Question 1 of 21

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent