AI prompts
base on Prism Ruby parser <h1 align="center">Prism Ruby parser</h1>
<div align="center">
<img alt="Prism Ruby parser" height="256px" src="https://github.com/ruby/prism/blob/main/doc/images/prism.png?raw=true">
</div>
This is a parser for the Ruby programming language. It is designed to be portable, error tolerant, and maintainable. It is written in C99 and has no dependencies.
## Overview
The repository contains the infrastructure for both a shared library (libprism) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against `ruby.h`, and so is suitable in the context of CRuby.
```
.
├── Makefile configuration to compile the shared library and native tests
├── Rakefile configuration to compile the native extension and run the Ruby tests
├── bin
│ ├── lex runs the lexer on a file or string, prints the tokens, and compares to ripper
│ ├── parse runs the parse on a file or string and prints the AST
│ └── prism a CLI for development and debugging
├── config.yml specification for tokens and nodes in the tree
├── doc documentation website
├── docs markdown documentation about the project
├── ext
│ └── prism
│ ├── extconf.rb configuration to generate the Makefile for the native extension
│ └── extension.c the native extension that interacts with libprism
├── fuzz files related to fuzz testing
├── gemfiles gemfiles used by different Ruby versions in CI
├── include
│ ├── prism header files for the shared library
│ └── prism.h main header file for the shared library
├── java Java bindings for the shared library
├── java-wasm Java WASM bindings for the shared library
├── javascript JavaScript WASM bindings for the shared library
├── lib
│ ├── prism Ruby library files
│ └── prism.rb main entrypoint for the Ruby library
├── rakelib various Rake tasks for the project
├── rbi RBI type signatures for the Ruby library
├── rust
│ ├── ruby-prism Rustified crate for the shared library
│ └── ruby-prism-sys FFI binding for Rust
├── sample
│ └── prism Sample code that uses the Ruby API for documentation purposes
├── sig RBS type signatures for the Ruby library
├── src
│ ├── util various utility files
│ └── prism.c main entrypoint for the shared library
├── templates contains ERB templates generated by templates/template.rb
│ └── template.rb generates code from the nodes and tokens configured by config.yml
└── test
└── prism
├── fixtures Ruby code used for testing
└── snapshots snapshots of generated syntax trees corresponding to fixtures
```
## Getting started
To compile the shared library, you will need:
* C99 compiler
* GNU make
* Ruby 2.7.0 or later
Once you have these dependencies, run:
```
bundle install
```
to fetch the Ruby dependencies. Finally, run:
```
bundle exec rake compile
```
to compile the shared library. It will be built in the `build` directory. To test that everything is working, run:
```
bin/parse -e "1 + 2"
```
to see the syntax tree for the expression `1 + 2`.
## Contributing
See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. We additionally have documentation about the overall design of the project as well as various subtopics.
* [Build system](docs/build_system.md)
* [Configuration](docs/configuration.md)
* [CRuby compilation](docs/cruby_compilation.md)
* [Design](docs/design.md)
* [Encoding](docs/encoding.md)
* [Fuzzing](docs/fuzzing.md)
* [Heredocs](docs/heredocs.md)
* [JavaScript](docs/javascript.md)
* [Local variable depth](docs/local_variable_depth.md)
* [Mapping](docs/mapping.md)
* [Parser translation](docs/parser_translation.md)
* [Parsing rules](docs/parsing_rules.md)
* [Releasing](docs/releasing.md)
* [Ripper translation](docs/ripper_translation.md)
* [Ruby API](docs/ruby_api.md)
* [RubyParser translation](docs/ruby_parser_translation.md)
* [Serialization](docs/serialization.md)
* [Testing](docs/testing.md)
## Examples
Prism has been integrated into the majority of Ruby runtimes, many libraries, and some applications. Below is a list of some of the projects that use Prism:
### Runtimes
* [CRuby](https://github.com/ruby/ruby/pull/7964) (via C)
* [Garnet](https://github.com/camertron/garnet-js) (via WASM)
* [JRuby](https://github.com/jruby/jruby/pull/8103) (via Java)
* [Natalie](https://github.com/natalie-lang/natalie/pull/1213) (via C++ and Ruby)
* [Opal](https://github.com/opal/opal/pull/2642) (via Ruby and WASM)
* [TruffleRuby](https://github.com/oracle/truffleruby/issues/3117) (via Java)
### Libraries
* [dispersion](https://github.com/joeldrapper/dispersion)
* [minifyrb](https://github.com/koic/minifyrb)
* [packwerk](https://github.com/Shopify/packwerk/pull/388) (via parser translator)
* [rbi](https://github.com/Shopify/rbi)
* [rails](https://github.com/rails/rails)
* [parsing renders](https://github.com/rails/rails/pull/49438)
* [parsing rdoc](https://github.com/rails/rails/pull/50870)
* [parsing tests](https://github.com/rails/rails/pull/51006)
* [repl_type_completor](https://github.com/ruby/repl_type_completor)
* [rubocop](https://docs.rubocop.org/rubocop/configuration.html#setting-the-parser-engine) (via parser translator)
* [ruby-lsp](https://github.com/Shopify/ruby-lsp)
* [smart_todo](https://github.com/Shopify/smart_todo/pull/69)
* [sorbet-eraser](https://github.com/kddnewton/sorbet-eraser/pull/25)
* [synvert](https://github.com/xinminlabs/synvert-core-ruby)
* [typeprof](https://github.com/ruby/typeprof)
### Applications
* [gem.sh](https://github.com/marcoroth/gem.sh/pull/96)
", Assign "at most 3 tags" to the expected json: {"id":"5124","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"