82 Commits

Author SHA1 Message Date
Alexander Momchilov
83e72fde83 Optimize Array allocations
… by allocating them with the correct capacity.
2024-08-27 16:23:50 +00:00
Kevin Newton
5cb6954baa [ruby/prism] Fix up lex result constants
https://github.com/ruby/prism/commit/084baca463
2024-08-15 16:50:00 +00:00
Koichi ITO
ad23bbe574 [ruby/prism] [Doc] Tweak the docs for lex APIs
`Prism.lex` and `Prism.lex_file` return `ParseLexResult` instead of `Array`.
`Prism::parse_lex` and `Prism::parse_lex_file` return `ParseLexResult` instead of `ParseResult`.
This PR updates the documentation to reflect these return values.

https://github.com/ruby/prism/commit/ee331941c0
2024-08-10 08:42:36 +00:00
Kevin Newton
e77e4aa608 [ruby/prism] Have parse_stream handle NUL bytes
https://github.com/ruby/prism/commit/4a41d298c8
2024-07-17 19:44:32 +00:00
Kevin Newton
c93b70cfdd [ruby/prism] Make sure Init_prism is visible for extension
https://github.com/ruby/prism/commit/4601d3adfd
2024-06-19 00:06:01 +00:00
Kevin Newton
d827d32527 [ruby/prism] Provide ability to lock encoding while parsing
https://github.com/ruby/prism/commit/f7faedfb3f
2024-06-10 17:21:32 -04:00
Nobuyoshi Nakada
c357138aa3
Use PRISM_EXPORTED_FUNCTION consistently with the header 2024-06-09 17:34:37 +09:00
Kevin Newton
745a948b6d [ruby/prism] Remove dynamic Debug module methods
https://github.com/ruby/prism/commit/b850794db9
2024-05-24 17:19:36 +00:00
Kevin Newton
79001c8b4a [ruby/prism] Remove error formatting, put directly in CRuby
https://github.com/ruby/prism/commit/53b2866487
2024-05-24 17:19:36 +00:00
Kevin Newton
653652bcbe [ruby/prism] Remove Debug#named_captures
https://github.com/ruby/prism/commit/5050dfbe70
2024-05-24 17:19:35 +00:00
Kevin Newton
e1041a8eda [ruby/prism] Move profiling to prism module directly
https://github.com/ruby/prism/commit/75fabf7081
2024-05-24 17:19:35 +00:00
Kevin Newton
b04c959621 [ruby/prism] Remove various unused memsize infra
https://github.com/ruby/prism/commit/283938ed1f
2024-05-24 17:19:34 +00:00
Kevin Newton
b8681c2e37 [ruby/prism] Remove Debug::integer_parse
https://github.com/ruby/prism/commit/14e397598b
2024-05-24 17:19:33 +00:00
Kevin Newton
870350253e [ruby/prism] Remove Debug::static_inspect
https://github.com/ruby/prism/commit/486c71c426
2024-05-24 17:19:33 +00:00
Vinicius Stock
4fbb208185 [ruby/prism] Create specialized ASCIISource with asciionly optimizations
https://github.com/ruby/prism/commit/40993166a8
2024-05-03 18:10:21 +00:00
Kevin Newton
7d64fbda53 [ruby/prism] Remove static literals dependence on parser definition
https://github.com/ruby/prism/commit/b3e104e8a2
2024-04-24 19:39:41 +00:00
Kevin Newton
23be6599a2 [ruby/prism] Split parse result based on type
https://github.com/ruby/prism/commit/17194e096d
2024-04-19 19:25:32 +00:00
Kevin Newton
d186eb36a4 [ruby/prism] Add a reflection API for determining the fields of a node
https://github.com/ruby/prism/commit/f3f9950a74
2024-04-17 13:54:29 -04:00
Kevin Newton
d583616f32 [ruby/prism] Ensure deserialization works with errors+warnings>256
https://github.com/ruby/prism/commit/f540e830b5
2024-03-28 12:04:35 -04:00
Kevin Newton
fcc06fa82a [ruby/prism] CLI -x flag
https://github.com/ruby/prism/commit/2068e3c30a
2024-03-28 12:04:35 -04:00
Kevin Newton
9b816e674a [ruby/prism] Add option for inlining messages for error formatting
https://github.com/ruby/prism/commit/af0204a8ab
2024-03-27 13:03:11 -04:00
Koichi ITO
52cf6ec46b [ruby/prism] Fix typos
After finding the "if if" typo, some additional typos identified by running `codespell` are also being corrected:
https://github.com/codespell-project/codespell

https://github.com/ruby/prism/commit/e6a34cfeeb
2024-03-26 10:51:12 +00:00
Kevin Newton
a08954569f
[ruby/prism] Fix up minimal build setting
https://github.com/ruby/prism/commit/98c85c4acb
2024-03-25 11:54:20 -04:00
Kevin Newton
af7bf9e0d8 [ruby/prism] Provide options for reducing size
https://github.com/ruby/prism/commit/592128de4d
2024-03-20 17:32:03 -04:00
Jean Boussier
53a77d9b90 [ruby/prism] Change frozen_string_literal to be a tri-state
An explicit `false` is not equivalent to the comment being missing,
because the default can be switched with a runtime flag:

```bash
$ ruby --enable-frozen-string-literal -e 'p "foo".frozen?'
true
```

https://github.com/ruby/prism/commit/4660f58775
2024-03-13 16:03:24 +00:00
Kevin Newton
21ea290b34 [ruby/prism] Static literals inspect
https://github.com/ruby/prism/commit/4913d112da
2024-03-12 03:30:50 +00:00
Kevin Newton
2ab75bc444 [ruby/prism] Support offset
https://github.com/ruby/prism/commit/665f533373
2024-03-11 14:49:23 +00:00
Kevin Newton
f5294ebbdb [ruby/prism] Shared integer parsing logic
https://github.com/ruby/prism/commit/a2594a23c1
2024-03-07 18:02:33 -05:00
tompng
81f02eb6ba [ruby/prism] Change pm_integer_t structure
https://github.com/ruby/prism/commit/588acf823f
2024-03-07 18:02:33 -05:00
Kevin Newton
977012bae8 [ruby/prism] Remove restrict to fix windows 2015
https://github.com/ruby/prism/commit/f0a2ce1c0e
2024-03-07 21:23:18 +00:00
Kevin Newton
ec159fc8ba [ruby/prism] Support parsing streams
https://github.com/ruby/prism/commit/efdc2b7222
2024-03-07 20:40:39 +00:00
Kevin Newton
38c2774420 [ruby/prism] Expose types on diagnostics
https://github.com/ruby/prism/commit/a735c2262f
2024-03-06 21:42:54 -05:00
Kevin Newton
b88973165a [ruby/prism] Parse files from Ruby API using fread, not mmap
https://github.com/ruby/prism/commit/62d4376a53
2024-03-06 17:45:56 +00:00
HASUMI Hitoshi
c4bd6da298 [ruby/prism] Make alloc interface replaceable
- Add `x` prefix to malloc, calloc, realloc, and free
  (eg: malloc -> xmalloc)
- By default, they are replaced with stdlib's functions at build
- You can use custom functions by defining `PRISM_CUSTOM_ALLOCATOR` macro

https://github.com/ruby/prism/commit/7a878af619
2024-03-04 16:40:23 +00:00
Kevin Newton
50e999c56d [ruby/prism] Command line options as a bitset
https://github.com/ruby/prism/commit/369ffbd57e
2024-02-29 12:05:19 -05:00
Kevin Newton
cd8d1018bb [ruby/prism] Resync RBI and test it in CI
https://github.com/ruby/prism/commit/4ef4032774
2024-02-29 16:29:16 +00:00
Kevin Newton
3ca8b4aee0 [ruby/prism] Support -p, -n, -a, and -l command line options
https://github.com/ruby/prism/commit/959eb506ca
2024-02-27 04:22:39 +00:00
Kevin Newton
96907f9495 [ruby/prism] Convert pm_integer_t to strings
https://github.com/ruby/prism/commit/fa9a30ad91
2024-02-23 21:54:01 +00:00
Kevin Newton
ec6532b458 [ruby/prism] Add some encoding debugging to make testing easier
https://github.com/ruby/prism/commit/0c042561c6
2024-02-23 20:02:19 +00:00
Kevin Newton
3b3def5db7 [ruby/prism] Regenerate snapshots using integer values 2024-02-22 22:42:44 -05:00
Kevin Newton
ff6ebba9de [ruby/prism] Parse numeric values
https://github.com/ruby/prism/commit/a6a552411c
2024-02-22 22:42:44 -05:00
Kevin Newton
00bda2aa3b [ruby/prism] Fix up GCC analyzer
https://github.com/ruby/prism/commit/2e8bc17528
2024-02-17 21:53:54 +00:00
Benoit Daloze
c2d8d6eba6 Initialize the Prism::Source directly with all 3 fields for the C extension
* Faster that way:
  $ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }'
  195.722k (± 0.5%) i/s
  rb_iv_set():
  179.609k (± 0.5%) i/s
  rb_funcall():
  190.030k (± 0.3%) i/s
  before this PR:
  183.319k (± 0.4%) i/s
2024-02-14 15:48:33 +00:00
Benoit Daloze
f0f6ffef42 [ruby/prism] Serialize the newline_list to avoid recomputing it again later
* Fixes https://github.com/ruby/prism/issues/2380

https://github.com/ruby/prism/commit/4eaaa90114
2024-02-14 15:48:32 +00:00
eileencodes
936c0ab5e8 [ruby/prism] Implement file parsing error handling
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:

- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.

Fixes: ruby/prism#2207

https://github.com/ruby/prism/commit/b2f7494ff5
2024-02-06 20:49:33 +00:00
Kevin Newton
07611acb0c [ruby/prism] Add another error type for raising argument errors
https://github.com/ruby/prism/commit/f3030cb2b2
2024-02-05 19:24:57 +00:00
Kevin Newton
e9f1324464 Sync to latest prism 2024-02-01 12:52:16 -05:00
Kevin Newton
e337c9478a [ruby/prism] Error follow-up
Split up the diagnostic levels so that error and warning levels
aren't mixed. Also fix up deconstruct_keys implementation.

https://github.com/ruby/prism/commit/bd3eeb308d

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-01-27 18:46:16 +00:00
Benoit Daloze
de135bc247 [ruby/prism] Add level to warnings and errors to categorize them
* Fixes https://github.com/ruby/prism/issues/2082

https://github.com/ruby/prism/commit/7a74576357
2024-01-26 21:34:34 +00:00
Kevin Newton
e00f42e5d3 [ruby/prism] Return 1-indexed line numbers
https://github.com/ruby/prism/commit/ad17f58729
2024-01-22 16:13:36 +00:00