项目介绍

ruby/lrama 是一个托管在 GitHub 上的开源项目,主要使用 Ruby 编写,目前获得 319 个 Star、32 次 Fork。

仓库全名
ruby/lrama
Star 数
319
Fork 数
32
未关闭 Issue
2

README 摘要

Lrama Lrama (pronounced in the same way as the noun “llama” in English) is LALR (1) parser generator written by Ruby. The first goal of this project is providing error tolerant parser for CRuby with minimal changes on CRuby parse.y file. Features Installation Usage Documentation Versions and Branches v0\8 (master branch) v0\7 (lrama07 branch) v0\6 (lrama06 branch) v0\5 (lrama05 branch) v0\4 (lrama04 branch)…

完整内容见 GitHub 原始 README 或本页 。

常见问题

lrama 用什么语言开发?

主要使用 Ruby 编写,目前有 319 个 Star。

如何获取 lrama 的源码?

可以直接克隆仓库:git clone https://github.com/ruby/lrama.git,默认分支为 master;安装与运行步骤见仓库 README。

lrama 最近还在维护吗?

仓库最近一次更新为 22 小时前,当前有 2 个未关闭 Issue;Star 数为 319,可作为社区活跃度的参考。

关于

Pure Ruby LALR parser generator

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
417
价值分
204
活跃状态
活跃

语言占比

C
HTML
Ruby
Yacc

Release

README

Lrama

Gem Version build RubyDoc

Lrama (pronounced in the same way as the noun “llama” in English) is LALR (1) parser generator written by Ruby. The first goal of this project is providing error tolerant parser for CRuby with minimal changes on CRuby parse.y file.

Features

  • Bison style grammar file is supported with some assumptions
    • b4_locations_if is always true
    • b4_pure_if is always true
    • b4_pull_if is always false
    • b4_lac_if is always false
  • Error Tolerance parser
  • Parameterizing rules
    • The definition of a non-terminal symbol can be parameterized with other (terminal or non-terminal) symbols.
    • Providing a generic definition of parameterized rules as a standard library.
  • Inlining
    • The %inline directive causes all references to symbols to be replaced with its definition.
    • Resolve shift/reduce conflicts without artificially altering the grammar file.
  • Syntax Diagrams
    • Easily generate syntax diagrams from the grammar file.
    • These visual diagrams are an useful development tool for grammar development and can also function as automatic self-documentation.

Installation

$ gem install lrama

From source codes,

$ cd "$(lrama root)"
$ bundle install
$ bundle exec rake install
$ bundle exec lrama --version
lrama 0.7.0

Usage

# "y.tab.c" and "y.tab.h" are generated
$ lrama -d sample/parse.y
# "calc", "calc.c", and "calc.h" are generated
$ lrama -d sample/calc.y -o calc.c && gcc -Wall calc.c -o calc && ./calc
Enter the formula:
1
=> 1
1+2*3
=> 7
(1+2)*3
=> 9

Documentation

https://ruby.github.io/lrama/ provides a comprehensive guide to Lrama’s features and usage.

Versions and Branches

v0_8 (master branch)

This branch is for Ruby 4.1. lrama_0_8 branch is created from this branch, once Ruby 4.1 is released.

v0_7 (lrama_0_7 branch)

This branch is for Ruby 4.0.

v0_6 (lrama_0_6 branch)

This branch is for Ruby 3.4.

v0_5 (lrama_0_5 branch)

This branch is for Ruby 3.3.

v0_4 (lrama_0_4 branch)

This branch generates “parse.c” compatible with Bison 3.8.2 for ruby 3.0, 3.1, 3.2. The first version migrated to ruby is “0.4.0” therefore keep this branch for Bison compatible branch.

Supported Ruby version

See Supported Ruby version in doc.

Development

How to generate parser.rb

$ bundle exec rake build:parser

parser.rb is generated from parser.y by Racc. Run the rake command when you update parser.y then commit changes of both files.

How to Write a Type Signature

We use Steep for type checking and rbs-inline for type declarations.

Currently, type signatures are declared in the sig/lrama directory. However, these files will be replaced with rbs-inline. This means type signatures should be written directly in the source code.

For guidance on writing type signatures, refer to the Syntax Guide in the rbs-inline documentation.

Test

Running tests:

$ bundle install
$ bundle exec rspec
# or
$ bundle exec rake spec

Running type check:

$ bundle install
$ bundle exec rbs collection install
$ bundle exec steep check
# or
$ bundle exec rake steep

Running both of them:

$ bundle install
$ bundle exec rake

Build Ruby

  1. Install Lrama
  2. Run make main

Release flow

  1. Update Lrama::VERSION and NEWS.md
  2. Release as a gem by rake release
  3. Update Lrama in ruby/ruby by cp -r LEGAL.md NEWS.md MIT exe lib template ruby/tool/lrama
  4. Create new release on GitHub

License

See LEGAL.md file.

评论

暂无评论