mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
225cdaa16a
Add precedence declarations to resolve the ambiguity between: - One-line pattern match: `arg in pattern` - Case/in clause: `case expr; in pattern; end` When seeing `arg in`, the parser should shift to parse `arg in pattern` as a complete expression (matching CRuby behavior), not reduce `arg` to start a case clause. Changes: - Add keyword_in to %nonassoc precedence declarations - Add %prec tLOWEST to the plain `arg` reduction rule This eliminates all bison shift-reduce conflicts (was 2, now 0). Co-authored-by: Claude <noreply@anthropic.com>
mruby-compiler
This mrbgem provides the mruby compiler, which is responsible for parsing Ruby code and generating mruby bytecode.
Functionality
The mruby-compiler gem includes the following components:
- Parser: Translates Ruby source code into an abstract syntax tree (AST).
- Code Generator: Traverses the AST to produce executable mruby bytecode.
mrbcexecutable: A command-line tool for compiling.rbfiles into.mrbbytecode files.
Usage
The mrbc (mruby-bin-mrbc) executable will generate compiled binary from Ruby
programs via this gem.
Example of using mrbc:
# Compile a Ruby script to bytecode
bin/mrbc my_script.rb
# Run the compiled script
bin/mruby my_script.mrb