Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Compiler Design Patterns

15

Flashcards

0/15

Still learning
StarStarStarStar

Decorator Pattern

StarStarStarStar

The Decorator pattern allows behavior to be added to individual objects, statically or dynamically, without affecting the behavior of other objects from the same class. Compilers use this to extend functionalities of specific nodes in AST without modifying the class itself.

StarStarStarStar

Abstract Factory Pattern

StarStarStarStar

The Abstract Factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. A compiler might use this to handle different target languages or environments.

StarStarStarStar

Visitor Pattern

StarStarStarStar

The Visitor pattern is used to separate an algorithm from an object structure on which it operates. In compilers, it's used to perform operations on an AST, such as type-checking and code generation, without modifying the nodes.

StarStarStarStar

Interpreter Pattern

StarStarStarStar

The Interpreter pattern is about defining a representation for a language's grammar alongside an interpreter that uses the representation to interpret sentences in the language. Compilers use this for interpreting expressions or small-scale scripts.

StarStarStarStar

Chain of Responsibility Pattern

StarStarStarStar

The Chain of Responsibility pattern passes a request along a chain of handlers. Upon receiving a request, each handler decides either to process it or to pass it to the next handler in the chain. In compilers, this can be used for error handling or event processing pipelines.

StarStarStarStar

Adapter Pattern

StarStarStarStar

The Adapter pattern allows objects with incompatible interfaces to collaborate. Compilers might use this pattern to ensure that code written against different versions of an interface or different IRs can still work together.

StarStarStarStar

Proxy Pattern

StarStarStarStar

The Proxy pattern provides a surrogate or placeholder for another object to control access to it. Compilers may use it to defer the cost of initializing a resource-heavy object, such as a symbol table or type information.

StarStarStarStar

Prototype Pattern

StarStarStarStar

The Prototype pattern is used to create duplicate objects while keeping performance in mind. Compilers might use this to copy AST nodes or IR instructions without going through expensive initialization.

StarStarStarStar

Command Pattern

StarStarStarStar

The Command pattern turns a request into a stand-alone object that contains all information about the request. Compilers might use this pattern for implementing undo/redo actions or for structuring transformation passes.

StarStarStarStar

Builder Pattern

StarStarStarStar

The Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to create different representations. Compilers use this for incremental construction of ASTs or IR representations.

StarStarStarStar

Factory Method Pattern

StarStarStarStar

The Factory Method pattern defines an interface for creating objects but lets subclasses change the type of objects that will be created. Compilers use this when different representations of code entities are needed based on the input.

StarStarStarStar

Singleton Pattern

StarStarStarStar

The Singleton pattern ensures that a class has only one instance and provides a global point of access to it. Compilers might use this pattern for components like symbol tables or configuration settings.

StarStarStarStar

State Pattern

StarStarStarStar

The State pattern allows an object to alter its behavior when its internal state changes. In compiler construction, this pattern can be used for parsing state machines or during phase transitions like lexing, parsing, and code generation.

StarStarStarStar

Strategy Pattern

StarStarStarStar

The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Compilers use this pattern to select different optimization or code generation strategies.

StarStarStarStar

Flyweight Pattern

StarStarStarStar

The Flyweight pattern is used to reduce the cost of creating and manipulating a large number of similar objects. In compilers, it's used for sharing nodes, like literals or identifiers, across the AST or IR to save memory.

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.