[ruby/prism] Fix up minimal build setting

https://github.com/ruby/prism/commit/98c85c4acb
This commit is contained in:
Kevin Newton 2024-03-25 10:08:21 -04:00
Родитель 53cc272387
Коммит a08954569f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0EAD74C79EC73F26
8 изменённых файлов: 60 добавлений и 13 удалений

Просмотреть файл

@ -1,5 +1,12 @@
#include "prism/extension.h"
#ifdef PRISM_EXCLUDE_PACK
void
Init_prism_pack(void) {}
#else
static VALUE rb_cPrism;
static VALUE rb_cPrismPack;
static VALUE rb_cPrismPackDirective;
@ -265,3 +272,5 @@ Init_prism_pack(void) {
pack_symbol = ID2SYM(rb_intern("pack"));
unpack_symbol = ID2SYM(rb_intern("unpack"));
}
#endif

Просмотреть файл

@ -182,4 +182,25 @@
#endif
#endif
/**
* If PRISM_BUILD_MINIMAL is defined, then we're going to define every possible
* switch that will turn off certain features of prism.
*/
#ifdef PRISM_BUILD_MINIMAL
/** Exclude the serialization API. */
#define PRISM_EXCLUDE_SERIALIZATION
/** Exclude the JSON serialization API. */
#define PRISM_EXCLUDE_JSON
/** Exclude the Array#pack parser API. */
#define PRISM_EXCLUDE_PACK
/** Exclude the prettyprint API. */
#define PRISM_EXCLUDE_PRETTYPRINT
/** Exclude the full set of encodings, using the minimal only. */
#define PRISM_ENCODING_EXCLUDE_FULL
#endif
#endif

Просмотреть файл

@ -270,6 +270,8 @@ file_options(int argc, VALUE *argv, pm_string_t *input, pm_options_t *options) {
}
}
#ifndef PRISM_EXCLUDE_SERIALIZATION
/******************************************************************************/
/* Serializing the AST */
/******************************************************************************/
@ -351,6 +353,8 @@ dump_file(int argc, VALUE *argv, VALUE self) {
return value;
}
#endif
/******************************************************************************/
/* Extracting values for the parse result */
/******************************************************************************/
@ -1129,6 +1133,8 @@ profile_file(VALUE self, VALUE filepath) {
return Qnil;
}
#ifndef PRISM_EXCLUDE_PRETTYPRINT
/**
* call-seq:
* Debug::inspect_node(source) -> inspected
@ -1159,6 +1165,8 @@ inspect_node(VALUE self, VALUE source) {
return string;
}
#endif
/**
* call-seq:
* Debug::format_errors(source, colorize) -> String
@ -1349,8 +1357,6 @@ Init_prism(void) {
rb_define_const(rb_cPrism, "VERSION", rb_str_new2(EXPECTED_PRISM_VERSION));
// First, the functions that have to do with lexing and parsing.
rb_define_singleton_method(rb_cPrism, "dump", dump, -1);
rb_define_singleton_method(rb_cPrism, "dump_file", dump_file, -1);
rb_define_singleton_method(rb_cPrism, "lex", lex, -1);
rb_define_singleton_method(rb_cPrism, "lex_file", lex_file, -1);
rb_define_singleton_method(rb_cPrism, "parse", parse, -1);
@ -1363,6 +1369,11 @@ Init_prism(void) {
rb_define_singleton_method(rb_cPrism, "parse_success?", parse_success_p, -1);
rb_define_singleton_method(rb_cPrism, "parse_file_success?", parse_file_success_p, -1);
#ifndef PRISM_EXCLUDE_SERIALIZATION
rb_define_singleton_method(rb_cPrism, "dump", dump, -1);
rb_define_singleton_method(rb_cPrism, "dump_file", dump_file, -1);
#endif
// Next, the functions that will be called by the parser to perform various
// internal tasks. We expose these to make them easier to test.
VALUE rb_cPrismDebug = rb_define_module_under(rb_cPrism, "Debug");
@ -1370,10 +1381,13 @@ Init_prism(void) {
rb_define_singleton_method(rb_cPrismDebug, "integer_parse", integer_parse, 1);
rb_define_singleton_method(rb_cPrismDebug, "memsize", memsize, 1);
rb_define_singleton_method(rb_cPrismDebug, "profile_file", profile_file, 1);
rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1);
rb_define_singleton_method(rb_cPrismDebug, "format_errors", format_errors, 2);
rb_define_singleton_method(rb_cPrismDebug, "static_inspect", static_inspect, -1);
#ifndef PRISM_EXCLUDE_PRETTYPRINT
rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1);
#endif
// Next, define the functions that are exposed through the private
// Debug::Encoding class.
rb_cPrismDebugEncoding = rb_define_class_under(rb_cPrismDebug, "Encoding", rb_cObject);

Просмотреть файл

@ -6,6 +6,8 @@
#ifndef PRISM_PACK_H
#define PRISM_PACK_H
#include "prism/defines.h"
// We optionally support parsing String#pack templates. For systems that don't
// want or need this functionality, it can be turned off with the
// PRISM_EXCLUDE_PACK define.
@ -15,8 +17,6 @@ void pm_pack_parse(void);
#else
#include "prism/defines.h"
#include <stdint.h>
#include <stdlib.h>

Просмотреть файл

@ -6,8 +6,8 @@
#ifndef PRISM_PARSER_H
#define PRISM_PARSER_H
#include "prism/ast.h"
#include "prism/defines.h"
#include "prism/ast.h"
#include "prism/encoding.h"
#include "prism/options.h"
#include "prism/util/pm_constant_pool.h"

Просмотреть файл

@ -6,14 +6,14 @@
#ifndef PRISM_PRETTYPRINT_H
#define PRISM_PRETTYPRINT_H
#include "prism/defines.h"
#ifdef PRISM_EXCLUDE_PRETTYPRINT
void pm_prettyprint(void);
#else
#include "prism/defines.h"
#include <stdio.h>
#include "prism/ast.h"

Просмотреть файл

@ -10842,9 +10842,9 @@ parser_lex(pm_parser_t *parser) {
break;
}
parser->current.end = breakpoint + 1;
pm_regexp_token_buffer_escape(parser, &token_buffer);
breakpoint++;
parser->current.end = breakpoint;
pm_regexp_token_buffer_escape(parser, &token_buffer);
token_buffer.base.cursor = breakpoint;
/* fallthrough */
@ -11069,9 +11069,9 @@ parser_lex(pm_parser_t *parser) {
// If we hit a \r\n sequence, then we need to treat it
// as a newline.
parser->current.end = breakpoint + 1;
pm_token_buffer_escape(parser, &token_buffer);
breakpoint++;
parser->current.end = breakpoint;
pm_token_buffer_escape(parser, &token_buffer);
token_buffer.cursor = breakpoint;
/* fallthrough */
@ -11321,8 +11321,8 @@ parser_lex(pm_parser_t *parser) {
// If we hit a \r\n sequence, then we want to replace it
// with a single \n character in the final string.
pm_token_buffer_escape(parser, &token_buffer);
breakpoint++;
pm_token_buffer_escape(parser, &token_buffer);
token_buffer.cursor = breakpoint;
/* fallthrough */

Просмотреть файл

@ -68,6 +68,9 @@ module Prism
seattlerb/heredoc_bad_hex_escape.txt
seattlerb/heredoc_bad_oct_escape.txt
seattlerb/heredoc_with_extra_carriage_horrible_mix.txt
seattlerb/heredoc_with_extra_carriage_returns_windows.txt
seattlerb/heredoc_with_only_carriage_returns_windows.txt
seattlerb/heredoc_with_only_carriage_returns.txt
spanning_heredoc_newlines.txt
spanning_heredoc.txt
tilde_heredocs.txt