ed-precompiled_prism 1.5.2-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +723 -0
  4. data/CODE_OF_CONDUCT.md +76 -0
  5. data/CONTRIBUTING.md +58 -0
  6. data/LICENSE.md +7 -0
  7. data/Makefile +110 -0
  8. data/README.md +143 -0
  9. data/config.yml +4714 -0
  10. data/docs/build_system.md +119 -0
  11. data/docs/configuration.md +68 -0
  12. data/docs/cruby_compilation.md +27 -0
  13. data/docs/design.md +53 -0
  14. data/docs/encoding.md +121 -0
  15. data/docs/fuzzing.md +88 -0
  16. data/docs/heredocs.md +36 -0
  17. data/docs/javascript.md +118 -0
  18. data/docs/local_variable_depth.md +229 -0
  19. data/docs/mapping.md +117 -0
  20. data/docs/parser_translation.md +24 -0
  21. data/docs/parsing_rules.md +22 -0
  22. data/docs/releasing.md +98 -0
  23. data/docs/relocation.md +34 -0
  24. data/docs/ripper_translation.md +72 -0
  25. data/docs/ruby_api.md +44 -0
  26. data/docs/ruby_parser_translation.md +19 -0
  27. data/docs/serialization.md +233 -0
  28. data/docs/testing.md +55 -0
  29. data/ext/prism/api_node.c +6941 -0
  30. data/ext/prism/api_pack.c +276 -0
  31. data/ext/prism/extconf.rb +127 -0
  32. data/ext/prism/extension.c +1419 -0
  33. data/ext/prism/extension.h +19 -0
  34. data/include/prism/ast.h +8220 -0
  35. data/include/prism/defines.h +260 -0
  36. data/include/prism/diagnostic.h +456 -0
  37. data/include/prism/encoding.h +283 -0
  38. data/include/prism/node.h +129 -0
  39. data/include/prism/options.h +482 -0
  40. data/include/prism/pack.h +163 -0
  41. data/include/prism/parser.h +933 -0
  42. data/include/prism/prettyprint.h +34 -0
  43. data/include/prism/regexp.h +43 -0
  44. data/include/prism/static_literals.h +121 -0
  45. data/include/prism/util/pm_buffer.h +236 -0
  46. data/include/prism/util/pm_char.h +204 -0
  47. data/include/prism/util/pm_constant_pool.h +218 -0
  48. data/include/prism/util/pm_integer.h +130 -0
  49. data/include/prism/util/pm_list.h +103 -0
  50. data/include/prism/util/pm_memchr.h +29 -0
  51. data/include/prism/util/pm_newline_list.h +113 -0
  52. data/include/prism/util/pm_string.h +200 -0
  53. data/include/prism/util/pm_strncasecmp.h +32 -0
  54. data/include/prism/util/pm_strpbrk.h +46 -0
  55. data/include/prism/version.h +29 -0
  56. data/include/prism.h +408 -0
  57. data/lib/prism/3.0/prism.so +0 -0
  58. data/lib/prism/3.1/prism.so +0 -0
  59. data/lib/prism/3.2/prism.so +0 -0
  60. data/lib/prism/3.3/prism.so +0 -0
  61. data/lib/prism/3.4/prism.so +0 -0
  62. data/lib/prism/compiler.rb +801 -0
  63. data/lib/prism/desugar_compiler.rb +392 -0
  64. data/lib/prism/dispatcher.rb +2210 -0
  65. data/lib/prism/dot_visitor.rb +4762 -0
  66. data/lib/prism/dsl.rb +1003 -0
  67. data/lib/prism/ffi.rb +570 -0
  68. data/lib/prism/inspect_visitor.rb +2392 -0
  69. data/lib/prism/lex_compat.rb +928 -0
  70. data/lib/prism/mutation_compiler.rb +772 -0
  71. data/lib/prism/node.rb +18816 -0
  72. data/lib/prism/node_ext.rb +511 -0
  73. data/lib/prism/pack.rb +230 -0
  74. data/lib/prism/parse_result/comments.rb +188 -0
  75. data/lib/prism/parse_result/errors.rb +66 -0
  76. data/lib/prism/parse_result/newlines.rb +155 -0
  77. data/lib/prism/parse_result.rb +911 -0
  78. data/lib/prism/pattern.rb +269 -0
  79. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  80. data/lib/prism/polyfill/byteindex.rb +13 -0
  81. data/lib/prism/polyfill/scan_byte.rb +14 -0
  82. data/lib/prism/polyfill/unpack1.rb +14 -0
  83. data/lib/prism/polyfill/warn.rb +36 -0
  84. data/lib/prism/prism.so +0 -0
  85. data/lib/prism/reflection.rb +416 -0
  86. data/lib/prism/relocation.rb +505 -0
  87. data/lib/prism/serialize.rb +2398 -0
  88. data/lib/prism/string_query.rb +31 -0
  89. data/lib/prism/translation/parser/builder.rb +62 -0
  90. data/lib/prism/translation/parser/compiler.rb +2234 -0
  91. data/lib/prism/translation/parser/lexer.rb +820 -0
  92. data/lib/prism/translation/parser.rb +374 -0
  93. data/lib/prism/translation/parser33.rb +13 -0
  94. data/lib/prism/translation/parser34.rb +13 -0
  95. data/lib/prism/translation/parser35.rb +13 -0
  96. data/lib/prism/translation/parser_current.rb +24 -0
  97. data/lib/prism/translation/ripper/sexp.rb +126 -0
  98. data/lib/prism/translation/ripper/shim.rb +5 -0
  99. data/lib/prism/translation/ripper.rb +3474 -0
  100. data/lib/prism/translation/ruby_parser.rb +1929 -0
  101. data/lib/prism/translation.rb +16 -0
  102. data/lib/prism/visitor.rb +813 -0
  103. data/lib/prism.rb +97 -0
  104. data/prism.gemspec +174 -0
  105. data/rbi/prism/compiler.rbi +12 -0
  106. data/rbi/prism/dsl.rbi +524 -0
  107. data/rbi/prism/inspect_visitor.rbi +12 -0
  108. data/rbi/prism/node.rbi +8734 -0
  109. data/rbi/prism/node_ext.rbi +107 -0
  110. data/rbi/prism/parse_result.rbi +404 -0
  111. data/rbi/prism/reflection.rbi +58 -0
  112. data/rbi/prism/string_query.rbi +12 -0
  113. data/rbi/prism/translation/parser.rbi +11 -0
  114. data/rbi/prism/translation/parser33.rbi +6 -0
  115. data/rbi/prism/translation/parser34.rbi +6 -0
  116. data/rbi/prism/translation/parser35.rbi +6 -0
  117. data/rbi/prism/translation/ripper.rbi +15 -0
  118. data/rbi/prism/visitor.rbi +473 -0
  119. data/rbi/prism.rbi +66 -0
  120. data/sig/prism/compiler.rbs +9 -0
  121. data/sig/prism/dispatcher.rbs +19 -0
  122. data/sig/prism/dot_visitor.rbs +6 -0
  123. data/sig/prism/dsl.rbs +351 -0
  124. data/sig/prism/inspect_visitor.rbs +22 -0
  125. data/sig/prism/lex_compat.rbs +10 -0
  126. data/sig/prism/mutation_compiler.rbs +159 -0
  127. data/sig/prism/node.rbs +4028 -0
  128. data/sig/prism/node_ext.rbs +149 -0
  129. data/sig/prism/pack.rbs +43 -0
  130. data/sig/prism/parse_result/comments.rbs +38 -0
  131. data/sig/prism/parse_result.rbs +196 -0
  132. data/sig/prism/pattern.rbs +13 -0
  133. data/sig/prism/reflection.rbs +50 -0
  134. data/sig/prism/relocation.rbs +185 -0
  135. data/sig/prism/serialize.rbs +8 -0
  136. data/sig/prism/string_query.rbs +11 -0
  137. data/sig/prism/visitor.rbs +169 -0
  138. data/sig/prism.rbs +254 -0
  139. data/src/diagnostic.c +850 -0
  140. data/src/encoding.c +5235 -0
  141. data/src/node.c +8676 -0
  142. data/src/options.c +328 -0
  143. data/src/pack.c +509 -0
  144. data/src/prettyprint.c +8941 -0
  145. data/src/prism.c +23361 -0
  146. data/src/regexp.c +790 -0
  147. data/src/serialize.c +2268 -0
  148. data/src/static_literals.c +617 -0
  149. data/src/token_type.c +703 -0
  150. data/src/util/pm_buffer.c +357 -0
  151. data/src/util/pm_char.c +318 -0
  152. data/src/util/pm_constant_pool.c +342 -0
  153. data/src/util/pm_integer.c +670 -0
  154. data/src/util/pm_list.c +49 -0
  155. data/src/util/pm_memchr.c +35 -0
  156. data/src/util/pm_newline_list.c +125 -0
  157. data/src/util/pm_string.c +381 -0
  158. data/src/util/pm_strncasecmp.c +36 -0
  159. data/src/util/pm_strpbrk.c +206 -0
  160. metadata +203 -0
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@shopify.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,58 @@
1
+ # Contributing
2
+
3
+ Thank you for your interest in contributing to prism! Below are a couple of ways that you can help out.
4
+
5
+ ## Discussions
6
+
7
+ The discussions page on the GitHub repository are open. If you have a question or want to discuss the project, feel free to open a new discussion or comment on an existing one. This is the best place to ask questions about the project.
8
+
9
+ ## Code
10
+
11
+ If you want to contribute code, please first open or contribute to a discussion. A lot of the project is in flux, and we want to make sure that you are contributing to the right place. Once you have a discussion going, you can open a pull request with your changes. We will review your code and get it merged in.
12
+
13
+ ## Tests
14
+
15
+ We could always use more tests! One of the biggest challenges of this project is building up a big test suite. If you want to contribute tests, feel free to open a pull request. These will get merged in as soon as possible.
16
+
17
+ The `test` Rake task will not compile libraries or the C extension, and this is intentional (to make testing against an installed version easier). If you want to test your changes, please make sure you're also running either the task:
18
+
19
+ ``` sh
20
+ bundle exec rake
21
+ ```
22
+
23
+ or explicitly running the `compile` task:
24
+
25
+ ``` sh
26
+ bundle exec rake compile test
27
+ # or to just compile the C extension ...
28
+ bundle exec rake compile:prism test
29
+ ```
30
+
31
+ To test the rust bindings (with caveats about setting up your Rust environment properly first):
32
+
33
+ ``` sh
34
+ bundle exec rake compile test:rust
35
+ ```
36
+
37
+
38
+ ## Documentation
39
+
40
+ We could always use more documentation! If you want to contribute documentation, feel free to open a pull request. These will get merged in as soon as possible. Documenting functions or methods is always useful, but we also need more guides and tutorials. If you have an idea for a guide or tutorial, feel free to open an issue and we can discuss it.
41
+
42
+ ## Developing
43
+
44
+ To get `clangd` support in the editor for development, generate the compilation database. This command will
45
+ create an ignored `compile_commands.json` file at the project root, which is used by clangd to provide functionality.
46
+
47
+ You will need `bear` which can be installed on macOS with `brew install bear`.
48
+
49
+ ```sh
50
+ bundle exec rake bear
51
+ ```
52
+
53
+ ## Debugging
54
+
55
+ Some useful rake tasks:
56
+
57
+ - `test:valgrind` runs the test suite under valgrind to look for illegal memory access or memory leaks
58
+ - `test:gdb` and `test:lldb` run the test suite under those debuggers
data/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022-present, Shopify Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,110 @@
1
+
2
+ # V=0 quiet, V=1 verbose. other values don't work.
3
+ V = 0
4
+ V0 = $(V:0=)
5
+ Q1 = $(V:1=)
6
+ Q = $(Q1:0=@)
7
+ ECHO1 = $(V:1=@ :)
8
+ ECHO = $(ECHO1:0=@ echo)
9
+ FUZZ_OUTPUT_DIR = $(CURDIR)/fuzz/output
10
+
11
+ SOEXT ?= $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]')
12
+
13
+ CPPFLAGS := -Iinclude $(CPPFLAGS)
14
+ CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden -Wimplicit-fallthrough $(CFLAGS)
15
+ JAVA_WASM_CFLAGS := -g -Oz -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden -Wimplicit-fallthrough $(JAVA_WASM_CFLAGS)
16
+ CC ?= cc
17
+ AR ?= ar
18
+ ARFLAGS ?= -r$(V0:1=v)
19
+ WASI_SDK_PATH := /opt/wasi-sdk
20
+
21
+ MAKEDIRS ?= mkdir -p
22
+ RMALL ?= rm -f -r
23
+
24
+ HEADERS := $(wildcard include/*.h include/*/*.h include/*/*/*.h')
25
+ SOURCES := $(wildcard src/*.c src/*/*.c)
26
+ SHARED_OBJECTS := $(subst src/,build/shared/,$(SOURCES:.c=.o))
27
+ STATIC_OBJECTS := $(subst src/,build/static/,$(SOURCES:.c=.o))
28
+
29
+ all: shared static
30
+
31
+ shared: build/libprism.$(SOEXT)
32
+ static: build/libprism.a
33
+ wasm: javascript/src/prism.wasm
34
+ java-wasm: java-wasm/src/test/resources/prism.wasm
35
+
36
+ build/libprism.$(SOEXT): $(SHARED_OBJECTS)
37
+ $(ECHO) "linking $@ with $(CC)"
38
+ $(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS)
39
+
40
+ build/libprism.a: $(STATIC_OBJECTS)
41
+ $(ECHO) "building $@ with $(AR)"
42
+ $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS)
43
+
44
+ javascript/src/prism.wasm: Makefile $(SOURCES) $(HEADERS)
45
+ $(ECHO) "building $@"
46
+ $(Q) $(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot/ $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(CFLAGS) -Wl,--export-all -Wl,--no-entry -mexec-model=reactor -o $@ $(SOURCES)
47
+
48
+ java-wasm/src/test/resources/prism.wasm: Makefile $(SOURCES) $(HEADERS)
49
+ $(ECHO) "building $@"
50
+ $(Q) $(WASI_SDK_PATH)/bin/clang $(DEBUG_FLAGS) -DPRISM_EXCLUDE_PRETTYPRINT -DPRISM_EXPORT_SYMBOLS -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(JAVA_WASM_CFLAGS) -Wl,--export-all -Wl,--no-entry -mexec-model=reactor -lc++ -lc++abi -o $@ $(SOURCES)
51
+
52
+ build/shared/%.o: src/%.c Makefile $(HEADERS)
53
+ $(ECHO) "compiling $@"
54
+ $(Q) $(MAKEDIRS) $(@D)
55
+ $(Q) $(CC) $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
56
+
57
+ build/static/%.o: src/%.c Makefile $(HEADERS)
58
+ $(ECHO) "compiling $@"
59
+ $(Q) $(MAKEDIRS) $(@D)
60
+ $(Q) $(CC) $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
61
+
62
+ build/fuzz.%: $(SOURCES) fuzz/%.c fuzz/fuzz.c
63
+ $(ECHO) "building $* fuzzer"
64
+ $(Q) $(MAKEDIRS) $(@D)
65
+ $(ECHO) "building main fuzz binary"
66
+ $(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
67
+ $(ECHO) "building cmplog binary"
68
+ $(Q) AFL_HARDEN=1 AFL_LLVM_CMPLOG=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@.cmplog $^
69
+
70
+ build/fuzz.heisenbug.%: $(SOURCES) fuzz/%.c fuzz/heisenbug.c
71
+ $(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
72
+
73
+ fuzz-debug:
74
+ $(ECHO) "entering debug shell"
75
+ $(Q) docker run -it --rm -e HISTFILE=/prism/fuzz/output/.bash_history -v $(CURDIR):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz
76
+
77
+ fuzz-docker-build: fuzz/docker/Dockerfile
78
+ $(ECHO) "building docker image"
79
+ $(Q) docker build -t prism/fuzz fuzz/docker/
80
+
81
+ fuzz-run-%: FORCE fuzz-docker-build
82
+ $(ECHO) "generating templates"
83
+ $(Q) bundle exec rake templates
84
+ $(ECHO) "running $* fuzzer"
85
+ $(Q) docker run --rm -v $(CURDIR):/prism prism/fuzz /bin/bash -c "FUZZ_FLAGS=\"$(FUZZ_FLAGS)\" make build/fuzz.$*"
86
+ $(ECHO) "starting AFL++ run"
87
+ $(Q) $(MAKEDIRS) $(FUZZ_OUTPUT_DIR)/$*
88
+ $(Q) docker run -it --rm -v $(CURDIR):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*"
89
+ FORCE:
90
+
91
+ fuzz-clean:
92
+ $(Q) $(RMALL) fuzz/output
93
+
94
+ clean:
95
+ $(Q) $(RMALL) build
96
+
97
+ .PHONY: clean fuzz-clean
98
+
99
+ all-no-debug: DEBUG_FLAGS := -DNDEBUG=1
100
+ all-no-debug: OPTFLAGS := -O3
101
+ all-no-debug: all
102
+
103
+ minimal: CFLAGS := $(CFLAGS) -DPRISM_BUILD_MINIMAL
104
+ minimal: all
105
+
106
+ run: Makefile $(STATIC_OBJECTS) $(HEADERS) test.c
107
+ $(ECHO) "compiling test.c"
108
+ $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) $(STATIC_OBJECTS) test.c
109
+ $(ECHO) "running test.c"
110
+ $(Q) ./a.out
data/README.md ADDED
@@ -0,0 +1,143 @@
1
+ <h1 align="center">Prism Ruby parser</h1>
2
+ <div align="center">
3
+ <img alt="Prism Ruby parser" height="256px" src="https://github.com/ruby/prism/blob/main/doc/images/prism.png?raw=true">
4
+ </div>
5
+
6
+ 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.
7
+
8
+ ## Overview
9
+
10
+ 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.
11
+
12
+ ```
13
+ .
14
+ ├── Makefile configuration to compile the shared library and native tests
15
+ ├── Rakefile configuration to compile the native extension and run the Ruby tests
16
+ ├── bin
17
+ │   ├── lex runs the lexer on a file or string, prints the tokens, and compares to ripper
18
+ │   ├── parse runs the parse on a file or string and prints the AST
19
+ │   └── prism a CLI for development and debugging
20
+ ├── config.yml specification for tokens and nodes in the tree
21
+ ├── doc documentation website
22
+ ├── docs markdown documentation about the project
23
+ ├── ext
24
+ │   └── prism
25
+ │   ├── extconf.rb configuration to generate the Makefile for the native extension
26
+ │   └── extension.c the native extension that interacts with libprism
27
+ ├── fuzz files related to fuzz testing
28
+ ├── gemfiles gemfiles used by different Ruby versions in CI
29
+ ├── include
30
+ │   ├── prism header files for the shared library
31
+ │   └── prism.h main header file for the shared library
32
+ ├── java Java bindings for the shared library
33
+ ├── java-wasm Java WASM bindings for the shared library
34
+ ├── javascript JavaScript WASM bindings for the shared library
35
+ ├── lib
36
+ │   ├── prism Ruby library files
37
+ │   └── prism.rb main entrypoint for the Ruby library
38
+ ├── rakelib various Rake tasks for the project
39
+ ├── rbi RBI type signatures for the Ruby library
40
+ ├── rust
41
+ │   ├── ruby-prism Rustified crate for the shared library
42
+ │   └── ruby-prism-sys FFI binding for Rust
43
+ ├── sample
44
+ │ └── prism Sample code that uses the Ruby API for documentation purposes
45
+ ├── sig RBS type signatures for the Ruby library
46
+ ├── src
47
+ │   ├── util various utility files
48
+ │   └── prism.c main entrypoint for the shared library
49
+ ├── templates contains ERB templates generated by templates/template.rb
50
+ │   └── template.rb generates code from the nodes and tokens configured by config.yml
51
+ └── test
52
+ └── prism
53
+ ├── fixtures Ruby code used for testing
54
+ └── snapshots snapshots of generated syntax trees corresponding to fixtures
55
+ ```
56
+
57
+ ## Getting started
58
+
59
+ To compile the shared library, you will need:
60
+
61
+ * C99 compiler
62
+ * GNU make
63
+ * Ruby 2.7.0 or later
64
+
65
+ Once you have these dependencies, run:
66
+
67
+ ```
68
+ bundle install
69
+ ```
70
+
71
+ to fetch the Ruby dependencies. Finally, run:
72
+
73
+ ```
74
+ bundle exec rake compile
75
+ ```
76
+
77
+ to compile the shared library. It will be built in the `build` directory. To test that everything is working, run:
78
+
79
+ ```
80
+ bin/parse -e "1 + 2"
81
+ ```
82
+
83
+ to see the syntax tree for the expression `1 + 2`.
84
+
85
+ ## Contributing
86
+
87
+ 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.
88
+
89
+ * [Build system](docs/build_system.md)
90
+ * [Configuration](docs/configuration.md)
91
+ * [CRuby compilation](docs/cruby_compilation.md)
92
+ * [Design](docs/design.md)
93
+ * [Encoding](docs/encoding.md)
94
+ * [Fuzzing](docs/fuzzing.md)
95
+ * [Heredocs](docs/heredocs.md)
96
+ * [JavaScript](docs/javascript.md)
97
+ * [Local variable depth](docs/local_variable_depth.md)
98
+ * [Mapping](docs/mapping.md)
99
+ * [Parser translation](docs/parser_translation.md)
100
+ * [Parsing rules](docs/parsing_rules.md)
101
+ * [Releasing](docs/releasing.md)
102
+ * [Ripper translation](docs/ripper_translation.md)
103
+ * [Ruby API](docs/ruby_api.md)
104
+ * [RubyParser translation](docs/ruby_parser_translation.md)
105
+ * [Serialization](docs/serialization.md)
106
+ * [Testing](docs/testing.md)
107
+
108
+ ## Examples
109
+
110
+ 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:
111
+
112
+ ### Runtimes
113
+
114
+ * [CRuby](https://github.com/ruby/ruby/pull/7964) (via C)
115
+ * [Garnet](https://github.com/camertron/garnet-js) (via WASM)
116
+ * [JRuby](https://github.com/jruby/jruby/pull/8103) (via Java)
117
+ * [Natalie](https://github.com/natalie-lang/natalie/pull/1213) (via C++ and Ruby)
118
+ * [Opal](https://github.com/opal/opal/pull/2642) (via Ruby and WASM)
119
+ * [TruffleRuby](https://github.com/oracle/truffleruby/issues/3117) (via Java)
120
+
121
+ ### Libraries
122
+
123
+ * [dispersion](https://github.com/joeldrapper/dispersion)
124
+ * [minifyrb](https://github.com/koic/minifyrb)
125
+ * [packwerk](https://github.com/Shopify/packwerk/pull/388) (via parser translator)
126
+ * [rbi](https://github.com/Shopify/rbi)
127
+ * [rails](https://github.com/rails/rails)
128
+ * [parsing renders](https://github.com/rails/rails/pull/49438)
129
+ * [parsing rdoc](https://github.com/rails/rails/pull/50870)
130
+ * [parsing tests](https://github.com/rails/rails/pull/51006)
131
+ * [repl_type_completor](https://github.com/ruby/repl_type_completor)
132
+ * [rubocop](https://docs.rubocop.org/rubocop/configuration.html#setting-the-parser-engine) (via parser translator)
133
+ * [ruby-lsp](https://github.com/Shopify/ruby-lsp)
134
+ * [smart_todo](https://github.com/Shopify/smart_todo/pull/69)
135
+ * [sorbet-eraser](https://github.com/kddnewton/sorbet-eraser/pull/25)
136
+ * [synvert](https://github.com/xinminlabs/synvert-core-ruby)
137
+ * [typeprof](https://github.com/ruby/typeprof)
138
+ * [unparser](https://github.com/mbj/unparser) (via parser translator)
139
+
140
+ ### Applications
141
+
142
+ * [gem.sh](https://github.com/marcoroth/gem.sh/pull/96)
143
+ * [Sorbet](https://github.com/sorbet/sorbet)