2020-06-25 15:06:08 +03:00
|
|
|
---
|
|
|
|
layout: developer-doc
|
|
|
|
title: Parser Architecture Overview
|
|
|
|
category: parser
|
|
|
|
tags: [parser, architecture]
|
|
|
|
order: 2
|
|
|
|
---
|
|
|
|
|
|
|
|
# Parser Architecture Overview
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-06-25 15:06:08 +03:00
|
|
|
The Enso parser is designed in a highly modular fashion, with separate crates
|
2020-06-26 16:54:20 +03:00
|
|
|
responsible for the component's various responsibilities. The overall
|
|
|
|
architecture for the parser is described in this document.
|
2020-06-25 15:06:08 +03:00
|
|
|
|
|
|
|
<!-- MarkdownTOC levels="2,3" autolink="true" -->
|
|
|
|
|
|
|
|
- [Overall Architecture](#overall-architecture)
|
|
|
|
|
|
|
|
<!-- /MarkdownTOC -->
|
|
|
|
|
|
|
|
## Overall Architecture
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-06-25 15:06:08 +03:00
|
|
|
The overall architecture of the parser subsystem can be visualised as follows.
|
|
|
|
|
2020-06-26 16:54:20 +03:00
|
|
|
```
|
|
|
|
┌───────────────┐
|
|
|
|
│ Source Code │
|
|
|
|
└───────────────┘
|
|
|
|
│
|
|
|
|
│
|
|
|
|
▽
|
|
|
|
┌─────────────────────────────────────────────────────────────────────────┐
|
|
|
|
│ ┌──────────────┐ Parser │
|
|
|
|
│ │ UTF-X Reader │ │
|
|
|
|
│ └──────────────┘ │
|
|
|
|
│ │ │
|
|
|
|
│ │ Character │
|
|
|
|
│ │ Stream │
|
|
|
|
│ ▽ │
|
|
|
|
│ ┌────────┐ │
|
|
|
|
│ │ Lexer │ │
|
|
|
|
│ │┌──────┐│ │
|
|
|
|
│ ││Flexer││ │
|
|
|
|
│ │└──────┘│ │
|
|
|
|
│ └────────┘ │
|
|
|
|
│ │ │
|
|
|
|
│ │ Structured │
|
|
|
|
│ │ Token Stream │
|
|
|
|
│ ▽ │
|
|
|
|
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
|
|
|
|
│ │ │ │ │ │ │ │
|
|
|
|
│ │ Macro │ Rust AST │ Operator │ Rust AST │ Construct │ │
|
|
|
|
│ │ Resolution │─────────────▷│ Resolution │─────────────▷│ Resolution │ │
|
|
|
|
│ │ │ │ │ │ │ │
|
|
|
|
│ └────────────┘ └────────────┘ └────────────┘ │
|
|
|
|
│ │ │
|
|
|
|
│ Rust AST │ │
|
|
|
|
│ ▽ │
|
|
|
|
│ ┌────────────┐ │
|
|
|
|
│ │ AST Output │ │
|
|
|
|
│ └────────────┘ │
|
|
|
|
└─────────────────────────────────────────────────────────────────────────┘
|
|
|
|
│
|
|
|
|
┌───────────────┤ Rust AST
|
|
|
|
▽ │
|
|
|
|
┌────────────┐ │
|
|
|
|
│ │ │
|
|
|
|
│ JVM Object │ └─────────────────┐
|
|
|
|
│ Generator │ │
|
|
|
|
│ │ │
|
|
|
|
└────────────┘ │
|
|
|
|
│ │
|
|
|
|
JVM AST │ │
|
|
|
|
▽ ▽
|
|
|
|
┌────────────┐ ┌────────────┐
|
|
|
|
│ │ │ │
|
|
|
|
│ Use in JVM │ │ Direct Use │
|
|
|
|
│ Code │ │in Rust Code│
|
|
|
|
│ │ │ │
|
|
|
|
└────────────┘ └────────────┘
|
|
|
|
```
|