Fan-made, handmade, recursive-descent parser for the Dart programming language.

Overview

Very Unofficial Parser

Coverage style: very good analysis License: MIT

Fan-made, handmade, recursive-descent parser for the Dart programming language.

Although this parser strives to parse the language according to the language specification, no guarantees can be made that it is perfect. Filing an issue, sending us valid code that should parse (but doesn't), and opening pull requests is all greatly appreciated — if you're into this sort of thing.

👷 Note: Implementing a parser for the Dart programming language is a large undertaking. As such, this project is still under development. Many of the basic tokens in the lexer have already been implemented, and the basic skeleton for parsing expressions with respect for operator precedence has also been constructed. For a full list of everything that has been accomplished, see below.

If you want development to finish faster, please help!

Features

A checklist of the implemented features is provided below.

Lexer

Comments

  • Single line comments
  • Documentation comments
  • Multiline comments

Numbers

  • Hexadecimal numbers
  • Decimal numbers (w/ exponents, etc)

Strings

  • Raw single line strings.
  • Raw multiline strings.
  • Single line strings with simple string interpolation.
  • Single line strings with complex string interpolation.
  • Multiline strings with simple string interpolation.
  • Multiline strings with complex string interpolation.

Misc

  • Whitespace
  • Newlines
  • Operators
  • Braces, brackets, parenthesis, etc.

Parser

Expressions

  • Operator precedence parsing

Primitives

  • Numbers
  • Booleans
  • Raw strings, single and multiline simple interpolated strings
  • Single and multiline strings with complex interpolation (in progress)

Misc

  • Special handling for trivia tokens

Dart Analyzer and Historical Issues

Dart's analyzer API's are tied to certain platforms and not technically intended for public use (although that never stopped anyone).

The analyzer package README says the following:

The APIs in this package were originally machine generated by a translator and were based on an earlier Java implementation. Several of the API's still look like their Java predecessors rather than clean Dart APIs.

In addition, there is currently no clean distinction between public and internal APIs. We plan to address this issue but doing so will, unfortunately, require a large number of breaking changes. We will try to minimize the pain this causes for our clients, but some pain is inevitable.

No one wants to use a dependency that promises "pain is inevitable." If we liked pain, we'd write our own parsers. Er, okay — but that's not the point. Either way, it'd be nice if there was a lightweight alternative to the analyzer for situations where the analyzer is too cumbersome (or overkill).

Currently, if you need to programmatically analyze Dart source code (with or without fully resolved types), you have no choice but to use the analyzer packages. In my experience, the analyzer is most often encountered when creating source generators for build_runner (which is notoriously slow and heavy) or creating custom lint rules by working with the analyzer plugin system directly (via unofficial practices). To make matters worse, the analyzer system completely obliterates the computer's memory usage when loading custom plugins, which makes using custom lint rules nearly impossible in any substantial project.

If the analyzer is improved substantially within our lifetime, this project probably won't be needed.

Potential Uses

Wondering what could be done with this once it's finished? Allow me to offer a few ideas, roughly ranked from "barely reasonable" to "rather implausible":

  • Create automatic code migration tools.
  • Create a lightweight source generator or linting system that provides just an AST (no fully resolved types) for the sake of simplicity and performance.
  • Create a transpiler — i.e., compile Dart code to another language.
  • Create an interpreter so you can run Dart inside Dart.
  • Create a compiler, in case you don't like the official one.
  • etc.

Contributing

We would love your help! If you like pain love making programming languages, you might just enjoy converting the Dart language specification into code. Please strive for readability over conciseness, and don't forget the tests!

Source code for recursive descent parsers are really easy to read and maintain. Handwriting the parser and node descriptions helps ensure they are ergonomic and easy to work with.

Credits

You're probably wondering who would do a thing like this. Me, apparently—but I blame Bob. In fact, if Bob's book Crafting Interpreters hadn't made it so easy to understand how to build a programming language, I might have gotten a lot more sleep.

Programming Language Theory

In case you're wondering what this is all about, here's a list of some helpful books and guides on some programming language topics.

Made with blood, sweat, and tears by 🐴 Very Unofficial Ventures.

You might also like...

🇮🇪 A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart.

Irishman 🇮🇪 A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart. Installation To install this package

Oct 8, 2022

Flutter language pickers2 - Language pickers package for Dart and Flutter

Flutter language pickers2 - Language pickers package for Dart and Flutter

language_pickers2 Notes: Original repository from github.com/gomgom, unfortunate

Feb 6, 2022

Receipt parser application written in dart.

Receipt parser application written in dart.

Receipt manager You can find pre-compiled releases on the Github release page or in the FDROID repository. All the needed info about how to use the re

Dec 29, 2022

Dart duration iso parser - Package to parse duration from ISO 8601 string

duration_iso_parser Package for parsing ISO 8601 durations string to the Duratio

Jan 18, 2022

A Dart EPUB parser built from the ground up, and designed to support a variety of use cases and custom

A Dart EPUB parser built from the ground up, and designed to support a variety of use cases and custom implementations such as on-device caching and serving content from a server.

Nov 3, 2022

An intuitive Token Parser that includes grammar definition, tokenization, parsing, syntax error and debugging. Implementation based on Lexical Analysis for Dart.

Token Parser An intuitive Token Parser that includes syntax/grammar definition, tokenization and parsing. Implementation based on Lexical Analysis. Re

Dec 15, 2022

FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

Flutter Interface Definition Language (FIDL) README in English(TODO) FIDL 即 Flutter 接口定义语言,类似于AIDL(Android Interface Definition Language)。您可以利用它定义不同平台

Dec 7, 2022

Eflashcard - Ready to learn a new language? Try this flashcards app that will help you learn the different writing systems of each language

Eflashcard - Ready to learn a new language? Try this flashcards app that will help you learn the different writing systems of each language

Language Flashcards Mobile App Ready to learn a new language? Try this mobile fl

Jan 8, 2022

Response Parser makes it easier to parse data and error response from server.

Response Parser makes it easier to parse data and error response from server. Getting started Do you want to write this pretty functions... FutureEit

Nov 5, 2022
Comments
  • style: Making `match`'s logic obvious

    style: Making `match`'s logic obvious

    Description

    The logic in match confused me, so I made it more obvious. =)

    Type of Change

    • [ ] ✨ New feature (non-breaking change which adds functionality)
    • [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
    • [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
    • [x] 🧹 Code refactor
    • [ ] ✅ Build configuration change
    • [ ] 📝 Documentation
    • [ ] 🗑️ Chore
    opened by domesticmouse 1
  • feat: add trivia handling

    feat: add trivia handling

    Description

    Adds a simple trivia handling system. Whitespace, new lines, and comments are considered trivia.

    For simplicity, all trivia tokens are considered to precede the next non-trivial tokens. There is no concept of trailing trivia in this parser. If this proves to be overly-simple we can adjust our approach in the future.

    Tokens are "nearly" immutable. Tokens can receive a one-time call to setTrivia to receive their preceding trivia tokens.

    Type of Change

    • [x] ✨ New feature (non-breaking change which adds functionality)
    • [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
    • [x] ❌ Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] 🧹 Code refactor
    • [ ] ✅ Build configuration change
    • [ ] 📝 Documentation
    • [x] 🗑️ Chore
    opened by definitelyokay 0
Owner
Joanna May
Making magic at 🦄 Very Good Ventures!
Joanna May
Two-dimensional recursive spatial subdivision: Flutter implementation of d3-quadtree

d3-quadtree A quadtree recursively partitions two-dimensional space into squares, dividing each square into four equally-sized squares. Each distinct

Tutero 4 Nov 26, 2022
Challenge cannabis - Challenge for Slicing UI Cannabis from FLutter Fan Indonesia

challenge_cannabis Challenge buat Slicing UI Cannabis dari om Kipas Angin FLutte

wind city 3 May 11, 2022
Docker images for the Dart programming language (https://dart.dev)

dart-docker This is the Git repo of the Docker "Official Images" for the Dart programming language. See the Docker Hub page for a full description on

Dart 49 Dec 14, 2022
Intel Corporation 238 Dec 24, 2022
This repository was created to provide the basics of the Dart programming language and Its use cases.

dart-exercises A collection of source code of the Dart Programming language. How does this repository works? Clone / Fork this repository to make your

Technosoft Labs 2 Oct 28, 2021
Repo for Teach Yourself mastering dart programming language

mastering-dart Repo for Teach Yourself mastering dart programming language Chapter Membuat Aplikasi Pertama Menggunakan Dart Percabangan Perulangan Fu

Feri Lukmansyah 50 Nov 10, 2022
App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction.

Grocery Shop Flutter App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction. About The app w

Wilton Neto 485 Dec 9, 2022
The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion.

Fluid Slider Flutter The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion. About The component was

Wilton Neto 41 Sep 30, 2022
Flutter component concept created with Flutter using Dart programming language, inspired by Gooey Rab Bar.

Gooey Tab Bar Flutter Flutter component concept created with Flutter using Dart programming language, inspired by Gooey Tab Bar. About This component

Wilton Neto 216 Dec 14, 2022
Implementation of data structures and algorithms in Dart programming language.

Algorithms in Dart Implementation of several algorithms with Dart programming language. Use dartdoc to generate documentation. Lists List data structu

Mafinar Khan 197 Dec 24, 2022