0.02
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
NatalieParser is a zero-dependency, from-scratch, hand-written recursive descent parser for the Ruby Programming Language.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Natalie Parser

NOT MAINTAINED: This parser has been archived in favor of Prism. Natalie now uses Prism instead.

Gem Version github build status MIT License

This is a parser for the Ruby programming language, written in C++. It was extracted from the Natalie project.

You can use this library directly from a C/C++ project, or you can build it as a Ruby gem and use it from Ruby itself.

We are currently targeting Ruby 3.0 syntax, but that will probably change over time, depending on what things we want to support and what kind of help we get from the community.

NOTE: This project is still very new and there are certainly bugs. See the list below for things we already know about, but expect there are more we don't know about yet. We don't recommend you use this in production applications.

To Do

  • Parse the Natalie compiler and standard library
  • Pass (mostly) the RubyParser test suite
  • Support different source encodings
  • Support more of the Ruby 3.0 syntax
    • "Endless" method definition (def foo = bar)
    • Argument forwarding (...)
    • Numbered block parameters (_1, _2, etc.)
    • Rational and Complex literals (1r and 2i)
    • Non-ASCII identifiers
    • Pattern matching

Development

You'll need:

  • gcc or clang
  • ruby-dev (dev headers)
  • ccache (optional)
  • compiledb (optional)
rake
ruby -I lib:ext -r natalie_parser -e "p NatalieParser.parse('1 + 2')"
# => s(:block, s(:call, s(:lit, 1), :+, s(:lit, 2)))

Running Tests

rake test

Copyright & License

Natalie is copyright 2022, Tim Morgan and contributors. Natalie is licensed under the MIT License; see the LICENSE file in this directory for the full text.

Note about Outside Sources

The file test/test_ruby_parser.rb is copyright Ryan Davis and is licensed MIT.