Граф коммитов

81 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton ac70dd07e6 [ruby/prism] Remove unused string list struct
https://github.com/ruby/prism/commit/36c6851c85
2024-06-05 14:40:03 -04:00
Herwin 61e2916d1c [ruby/prism] Typo fix: poitive => positive
https://github.com/ruby/prism/commit/d13a05252d
2024-05-28 15:28:02 +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
Kevin Newton 89efb94fec [ruby/prism] Reconfigure rationals
This eliminates the subnode on RationalNode and replaces it with two
integer fields, which represent the ratio for the rational. It also
reduces those two integers if they both fit into 32 bits.

Importantly, this PR does not implement bignum reduction. That's something
I'd like to consider for the future, but it's simple enough for now to
leave them unreduced, which makes it more useful than it used to be.

https://github.com/ruby/prism/commit/86e06c7068
2024-05-21 14:27:46 -04:00
Kevin Newton 286d3032a7 [ruby/prism] More mixed encoding errors
https://github.com/ruby/prism/commit/2a43b4f55c
2024-05-16 17:22:14 +00:00
Kevin Newton 0defbc11a5 [ruby/prism] Fix recursive multiply when values are switched in karatsuba_multiply
https://github.com/ruby/prism/commit/4dc6ea960d
2024-04-23 18:17:29 +00:00
Kevin Newton f72436f835 [ruby/prism] Inline pm_state_stack 2024-04-17 10:36:52 -04:00
Kevin Newton f34409bf87 [ruby/prism] Fix up more clang-analyzer failures
https://github.com/ruby/prism/commit/f9a1abbc64
2024-04-17 01:15:21 +00:00
Kevin Newton 646a00892e [ruby/prism] Fix up clang-analyzer violations
https://github.com/ruby/prism/commit/259aef2acd
2024-04-16 14:30:34 +00:00
Kevin Newton 540cc886b9 [ruby/prism] Make the locals set switch from list to hash dynamically
https://github.com/ruby/prism/commit/c977c4c98a
2024-04-05 19:23:57 +00:00
Kevin Newton 358aeb103b [ruby/prism] Switch locals to use a hash
https://github.com/ruby/prism/commit/f38946021e
2024-04-05 19:23:57 +00:00
Kevin Newton 35ff302893 [ruby/prism] Various cleanup with new -x option
https://github.com/ruby/prism/commit/020756fb11
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
Koichi ITO 56a2fad2a4 [ruby/prism] Fix incorrect paring when using invalid regexp options
Fixes https://github.com/ruby/prism/pull/2617.

There was an issue with the lexer as follows.
The following are valid regexp options:

```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/io").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :EOF]
```

The following are invalid regexp options. Unnecessary the `IDENTIFIER` token is appearing:

```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/az").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :IDENTIFIER, :EOF]
```

As a behavior of Ruby, when given `A` to `Z` and `a` to `z`, they act as invalid regexp options. e.g.,

```console
$ ruby -e '/regexp/az'
-e:1: unknown regexp options - az
/regexp/az
-e: compile error (SyntaxError)
```

Thus, it should probably not be construed as `IDENTIFIER` token.

Therefore, `pm_byte_table` has been adapted to accept those invalid regexp option values.
Whether it is a valid regexp option or not is checked by `pm_regular_expression_flags_create`.
For invalid regexp options, `PM_ERR_REGEXP_UNKNOWN_OPTIONS` is added to diagnostics.

https://github.com/ruby/prism/commit/d2a6096fcf
2024-03-25 12:16:32 +00:00
Kevin Newton a05dfbd405
[PRISM] Remove ssize_t definition from prism 2024-03-13 12:06:48 -04:00
Kevin Newton 4dd9602c6f [ruby/prism] Remove ssize_t usage
https://github.com/ruby/prism/commit/64c4f1268b
2024-03-13 16:06:13 +00:00
Nobuyoshi Nakada f42164e037
Define `ssize_t` on mswin build 2024-03-12 14:49:25 +09: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 6242a82c8f [ruby/prism] Provide more documentation for pm_integer_parse_digit_values
https://github.com/ruby/prism/commit/c3fcb5031f
2024-03-11 15:12:14 +00:00
Kevin Newton 2dfa95a272 [ruby/prism] Stop crashing on invalid integers
https://github.com/ruby/prism/commit/afac2d6646
2024-03-11 15:11:42 +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
Kevin Newton c1462250b8 [ruby/prism] Style and allocation functions
https://github.com/ruby/prism/commit/97f838c323
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
tompng 5113d6b059 [ruby/prism] Faster pm_integer_parse pm_integer_string using karatsuba algorithm
https://github.com/ruby/prism/commit/ae4fb6b988
2024-03-07 18:02:33 -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
cui fliter 226a889dc7
[DOC] fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 18:50:47 +09:00
HASUMI Hitoshi b95e2cdca7 [ruby/prism] Additional fix of adding `x` prefix after rebase with main branch
https://github.com/ruby/prism/commit/08733438bd
2024-03-04 16:40:24 +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 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 02b531a813 [ruby/prism] Factor in sign to integer comparison
https://github.com/ruby/prism/commit/377666a5df
2024-02-23 13:25:31 -05:00
Kevin Newton a38cc177d2 [ruby/prism] Duplicated when clauses
https://github.com/ruby/prism/commit/865b0d5fbe
2024-02-23 13:25:31 -05:00
Kevin Newton d1ce989829 [ruby/prism] Duplicated hash keys
https://github.com/ruby/prism/commit/3e10c46c14
2024-02-23 13:25:31 -05:00
Kevin Newton 5e0589cf52 [ruby/prism] Parse float values
https://github.com/ruby/prism/commit/9137226a52
2024-02-22 22:42:44 -05:00
Kevin Newton 3b3def5db7 [ruby/prism] Regenerate snapshots using integer values 2024-02-22 22:42:44 -05:00
Kevin Newton af0a6ea1d5 [ruby/prism] Add an IntegerField for parsing integer values
https://github.com/ruby/prism/commit/120d8c0479
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
HASUMI Hitoshi f0a46c6334 [ruby/prism] Include unistd.h before cheching _POSIX_MAPPED_FILES
https://github.com/ruby/prism/commit/84b3c294f0
2024-02-20 14:21:17 +00:00
HASUMI Hitoshi 15b53e901c [ruby/prism] Use `_POSIX_MAPPED_FILES` and `_WIN32` to know if memory map interface is available in the target platform
https://github.com/ruby/prism/commit/88e2ff52d4
2024-02-20 14:21:16 +00: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
Kevin Newton b56b8ec797 [ruby/prism] Provide the ability to dump AST to JSON from C
https://github.com/ruby/prism/commit/d3a149efc5
2024-02-17 02:05:12 +00:00
Kevin Newton 6f4bb638b0 [ruby/prism] Builtins
https://github.com/ruby/prism/commit/851f2571ff
2024-02-16 19:34:38 +00:00
Kevin Newton 9933377c34 [PRISM] Correctly hook up line numbers for eval 2024-02-14 15:29:26 -05:00
Kevin Newton 2fa051f627 [ruby/prism] Validate multibyte characters in strings
Check that multibyte characters are valid using pm_strpbrk. We need
to add a couple of codepaths to ensure all encodings are covered.

Importantly this doesn't check regular expressions, because
apparently you're allowed to have invalid multibyte characters
inside regular expression comment groups/extended mode.

https://github.com/ruby/prism/commit/2857d3e1b5
2024-02-14 01:01:37 +00:00
Kevin Newton 54295ba5e1 [PRISM] Compile constant reads using opt_getconstant_path 2024-02-08 11:53:10 -05: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 6afccdf449 [ruby/prism] Provide APIs for finding value in constant pool
https://github.com/ruby/prism/commit/be9e2abfa3
2024-02-02 21:45:50 +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
Kevin Newton 76a207e542 [ruby/prism] Fix nested default value error
https://github.com/ruby/prism/commit/ef26b283de
2024-01-11 20:52:48 +00:00