prism 2.0.0-arm-linux-musl
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.
- checksums.yaml +7 -0
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +881 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +58 -0
- data/LICENSE.md +7 -0
- data/Makefile +145 -0
- data/README.md +81 -0
- data/config.yml +4752 -0
- data/docs/build_system.md +119 -0
- data/docs/configuration.md +69 -0
- data/docs/cruby_compilation.md +27 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +121 -0
- data/docs/fuzzing.md +81 -0
- data/docs/heredocs.md +36 -0
- data/docs/javascript.md +133 -0
- data/docs/local_variable_depth.md +229 -0
- data/docs/mapping.md +117 -0
- data/docs/parser_translation.md +24 -0
- data/docs/parsing_rules.md +22 -0
- data/docs/releasing.md +147 -0
- data/docs/relocation.md +32 -0
- data/docs/ripper_translation.md +63 -0
- data/docs/ruby_api.md +45 -0
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +244 -0
- data/docs/testing.md +72 -0
- data/ext/prism/api_node.c +7005 -0
- data/ext/prism/extconf.rb +126 -0
- data/ext/prism/extension.c +1768 -0
- data/ext/prism/extension.h +19 -0
- data/include/prism/arena.h +45 -0
- data/include/prism/arena.hpp +42 -0
- data/include/prism/ast.h +10381 -0
- data/include/prism/ast.hpp +641 -0
- data/include/prism/buffer.h +60 -0
- data/include/prism/buffer.hpp +55 -0
- data/include/prism/comments.h +72 -0
- data/include/prism/compiler/accel.h +26 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/branch.h +26 -0
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/cplusplus.hpp +16 -0
- data/include/prism/compiler/endianness.h +34 -0
- data/include/prism/compiler/exceptions.hpp +17 -0
- data/include/prism/compiler/exported.h +24 -0
- data/include/prism/compiler/fallthrough.h +22 -0
- data/include/prism/compiler/filesystem.h +32 -0
- data/include/prism/compiler/flex_array.h +19 -0
- data/include/prism/compiler/force_inline.h +21 -0
- data/include/prism/compiler/format.h +27 -0
- data/include/prism/compiler/inline.h +17 -0
- data/include/prism/compiler/lifetimebound.hpp +25 -0
- data/include/prism/compiler/nodiscard.h +22 -0
- data/include/prism/compiler/nonnull.h +18 -0
- data/include/prism/compiler/unused.h +18 -0
- data/include/prism/constant_pool.h +106 -0
- data/include/prism/diagnostic.h +111 -0
- data/include/prism/errors_format.h +61 -0
- data/include/prism/excludes.h +29 -0
- data/include/prism/integer.h +41 -0
- data/include/prism/internal/allocator.h +68 -0
- data/include/prism/internal/allocator_debug.h +88 -0
- data/include/prism/internal/arena.h +108 -0
- data/include/prism/internal/bit.h +42 -0
- data/include/prism/internal/buffer.h +94 -0
- data/include/prism/internal/char.h +145 -0
- data/include/prism/internal/comments.h +53 -0
- data/include/prism/internal/constant_pool.h +152 -0
- data/include/prism/internal/diagnostic.h +389 -0
- data/include/prism/internal/encoding.h +242 -0
- data/include/prism/internal/integer.h +68 -0
- data/include/prism/internal/isinf.h +16 -0
- data/include/prism/internal/line_offset_list.h +34 -0
- data/include/prism/internal/list.h +62 -0
- data/include/prism/internal/magic_comments.h +23 -0
- data/include/prism/internal/memchr.h +15 -0
- data/include/prism/internal/node.h +42 -0
- data/include/prism/internal/options.h +232 -0
- data/include/prism/internal/parser.h +1004 -0
- data/include/prism/internal/regexp.h +26 -0
- data/include/prism/internal/serialize.h +39 -0
- data/include/prism/internal/source.h +72 -0
- data/include/prism/internal/static_literals.h +100 -0
- data/include/prism/internal/stringy.h +30 -0
- data/include/prism/internal/strncasecmp.h +18 -0
- data/include/prism/internal/strpbrk.h +33 -0
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/internal/xxh3.h +16 -0
- data/include/prism/json.h +40 -0
- data/include/prism/line_offset_list.h +69 -0
- data/include/prism/magic_comments.h +53 -0
- data/include/prism/node.h +139 -0
- data/include/prism/node.hpp +272 -0
- data/include/prism/node_type.hpp +38 -0
- data/include/prism/options.h +363 -0
- data/include/prism/options.hpp +43 -0
- data/include/prism/parser.h +433 -0
- data/include/prism/parser.hpp +274 -0
- data/include/prism/prettyprint.h +39 -0
- data/include/prism/serialize.h +123 -0
- data/include/prism/source.h +163 -0
- data/include/prism/stream.h +36 -0
- data/include/prism/string_query.h +82 -0
- data/include/prism/stringy.h +61 -0
- data/include/prism/stringy.hpp +31 -0
- data/include/prism/version.h +46 -0
- data/include/prism.h +123 -0
- data/include/prism.hpp +24 -0
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/compiler.rb +815 -0
- data/lib/prism/desugar_compiler.rb +463 -0
- data/lib/prism/dispatcher.rb +2383 -0
- data/lib/prism/dot_visitor.rb +4848 -0
- data/lib/prism/dsl.rb +1369 -0
- data/lib/prism/ffi.rb +746 -0
- data/lib/prism/inspect_visitor.rb +2425 -0
- data/lib/prism/lex_compat.rb +953 -0
- data/lib/prism/mutation_compiler.rb +780 -0
- data/lib/prism/node.rb +33940 -0
- data/lib/prism/node_ext.rb +504 -0
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +72 -0
- data/lib/prism/parse_result/newlines.rb +423 -0
- data/lib/prism/parse_result.rb +1236 -0
- data/lib/prism/pattern.rb +314 -0
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/polyfill/warn.rb +36 -0
- data/lib/prism/reflection.rb +427 -0
- data/lib/prism/relocation.rb +567 -0
- data/lib/prism/serialize.rb +4589 -0
- data/lib/prism/string_query.rb +54 -0
- data/lib/prism/translation/parser/builder.rb +70 -0
- data/lib/prism/translation/parser/compiler.rb +2226 -0
- data/lib/prism/translation/parser/lexer.rb +769 -0
- data/lib/prism/translation/parser.rb +376 -0
- data/lib/prism/translation/parser_current.rb +26 -0
- data/lib/prism/translation/parser_versions.rb +36 -0
- data/lib/prism/translation/ripper/filter.rb +53 -0
- data/lib/prism/translation/ripper/lexer.rb +133 -0
- data/lib/prism/translation/ripper/sexp.rb +118 -0
- data/lib/prism/translation/ripper/shim.rb +7 -0
- data/lib/prism/translation/ripper.rb +4278 -0
- data/lib/prism/translation/ruby_parser.rb +1721 -0
- data/lib/prism/translation.rb +20 -0
- data/lib/prism/visitor.rb +1440 -0
- data/lib/prism.rb +168 -0
- data/prism.gemspec +251 -0
- data/rbi/generated/prism/compiler.rbi +489 -0
- data/rbi/generated/prism/desugar_compiler.rbi +306 -0
- data/rbi/generated/prism/dispatcher.rbi +1138 -0
- data/rbi/generated/prism/dot_visitor.rbi +618 -0
- data/rbi/generated/prism/dsl.rbi +751 -0
- data/rbi/generated/prism/inspect_visitor.rbi +503 -0
- data/rbi/generated/prism/lex_compat.rbi +162 -0
- data/rbi/generated/prism/mutation_compiler.rbi +464 -0
- data/rbi/generated/prism/node.rbi +15143 -0
- data/rbi/generated/prism/node_ext.rbi +259 -0
- data/rbi/generated/prism/node_find.rbi +79 -0
- data/rbi/generated/prism/parse_result/errors.rbi +21 -0
- data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
- data/rbi/generated/prism/parse_result.rbi +776 -0
- data/rbi/generated/prism/pattern.rbi +134 -0
- data/rbi/generated/prism/reflection.rbi +89 -0
- data/rbi/generated/prism/relocation.rbi +329 -0
- data/rbi/generated/prism/serialize.rbi +185 -0
- data/rbi/generated/prism/string_query.rbi +43 -0
- data/rbi/generated/prism/translation.rbi +7 -0
- data/rbi/generated/prism/visitor.rbi +650 -0
- data/rbi/generated/prism.rbi +86 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser_versions.rbi +28 -0
- data/rbi/prism/translation/ripper.rbi +15 -0
- data/rbi/rubyvm/node_find.rbi +14 -0
- data/sig/generated/prism/compiler.rbs +492 -0
- data/sig/generated/prism/desugar_compiler.rbs +305 -0
- data/sig/generated/prism/dispatcher.rbs +1292 -0
- data/sig/generated/prism/dot_visitor.rbs +635 -0
- data/sig/generated/prism/dsl.rbs +928 -0
- data/sig/generated/prism/inspect_visitor.rbs +509 -0
- data/sig/generated/prism/lex_compat.rbs +166 -0
- data/sig/generated/prism/mutation_compiler.rbs +464 -0
- data/sig/generated/prism/node.rbs +21632 -0
- data/sig/generated/prism/node_ext.rbs +290 -0
- data/sig/generated/prism/node_find.rbs +90 -0
- data/sig/generated/prism/parse_result/errors.rbs +22 -0
- data/sig/generated/prism/parse_result/newlines.rbs +223 -0
- data/sig/generated/prism/parse_result.rbs +871 -0
- data/sig/generated/prism/pattern.rbs +156 -0
- data/sig/generated/prism/reflection.rbs +101 -0
- data/sig/generated/prism/relocation.rbs +428 -0
- data/sig/generated/prism/serialize.rbs +200 -0
- data/sig/generated/prism/string_query.rbs +43 -0
- data/sig/generated/prism/translation.rbs +8 -0
- data/sig/generated/prism/visitor.rbs +1111 -0
- data/sig/generated/prism.rbs +84 -0
- data/sig/manifest.yaml +2 -0
- data/src/arena.c +117 -0
- data/src/buffer.c +389 -0
- data/src/char.c +289 -0
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +894 -0
- data/src/encoding.c +5345 -0
- data/src/errors_format.c +519 -0
- data/src/integer.c +681 -0
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/memchr.c +37 -0
- data/src/node.c +4363 -0
- data/src/options.c +445 -0
- data/src/parser.c +371 -0
- data/src/prettyprint.c +9024 -0
- data/src/prism.c +23901 -0
- data/src/regexp.c +1705 -0
- data/src/serialize.c +2660 -0
- data/src/source.c +524 -0
- data/src/static_literals.c +685 -0
- data/src/string_query.c +180 -0
- data/src/stringy.c +61 -0
- data/src/strncasecmp.c +37 -0
- data/src/strpbrk.c +447 -0
- data/src/tokens.c +724 -0
- data/src/xxh3.c +292 -0
- metadata +276 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/*----------------------------------------------------------------------------*/
|
|
2
|
+
/* This file is generated by the templates/template.rb script and should not */
|
|
3
|
+
/* be modified manually. See */
|
|
4
|
+
/* templates/include/prism/internal/diagnostic.h.erb */
|
|
5
|
+
/* if you are looking to modify the */
|
|
6
|
+
/* template */
|
|
7
|
+
/*----------------------------------------------------------------------------*/
|
|
8
|
+
|
|
9
|
+
#ifndef PRISM_INTERNAL_DIAGNOSTIC_H
|
|
10
|
+
#define PRISM_INTERNAL_DIAGNOSTIC_H
|
|
11
|
+
|
|
12
|
+
#include "prism/internal/list.h"
|
|
13
|
+
|
|
14
|
+
#include "prism/arena.h"
|
|
15
|
+
#include "prism/diagnostic.h"
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* The diagnostic IDs of all of the diagnostics, used to communicate the types
|
|
19
|
+
* of errors between the parser and the user.
|
|
20
|
+
*/
|
|
21
|
+
typedef enum {
|
|
22
|
+
/* These are the error diagnostics. */
|
|
23
|
+
PM_ERR_ALIAS_ARGUMENT,
|
|
24
|
+
PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE,
|
|
25
|
+
PM_ERR_AMPAMPEQ_MULTI_ASSIGN,
|
|
26
|
+
PM_ERR_ARGUMENT_AFTER_BLOCK,
|
|
27
|
+
PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES,
|
|
28
|
+
PM_ERR_ARGUMENT_BARE_HASH,
|
|
29
|
+
PM_ERR_ARGUMENT_BLOCK_MULTI,
|
|
30
|
+
PM_ERR_ARGUMENT_CONFLICT_AMPERSAND,
|
|
31
|
+
PM_ERR_ARGUMENT_CONFLICT_STAR,
|
|
32
|
+
PM_ERR_ARGUMENT_CONFLICT_STAR_STAR,
|
|
33
|
+
PM_ERR_ARGUMENT_FORMAL_CLASS,
|
|
34
|
+
PM_ERR_ARGUMENT_FORMAL_CONSTANT,
|
|
35
|
+
PM_ERR_ARGUMENT_FORMAL_GLOBAL,
|
|
36
|
+
PM_ERR_ARGUMENT_FORMAL_IVAR,
|
|
37
|
+
PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
|
|
38
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND,
|
|
39
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
|
|
40
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA,
|
|
41
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK,
|
|
42
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
|
|
43
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR,
|
|
44
|
+
PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT,
|
|
45
|
+
PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT,
|
|
46
|
+
PM_ERR_ARGUMENT_TERM_PAREN,
|
|
47
|
+
PM_ERR_ARGUMENT_UNEXPECTED_BLOCK,
|
|
48
|
+
PM_ERR_ARRAY_ELEMENT,
|
|
49
|
+
PM_ERR_ARRAY_EXPRESSION,
|
|
50
|
+
PM_ERR_ARRAY_EXPRESSION_AFTER_STAR,
|
|
51
|
+
PM_ERR_ARRAY_SEPARATOR,
|
|
52
|
+
PM_ERR_ARRAY_TERM,
|
|
53
|
+
PM_ERR_BEGIN_LONELY_ELSE,
|
|
54
|
+
PM_ERR_BEGIN_TERM,
|
|
55
|
+
PM_ERR_BEGIN_UPCASE_BRACE,
|
|
56
|
+
PM_ERR_BEGIN_UPCASE_TERM,
|
|
57
|
+
PM_ERR_BEGIN_UPCASE_TOPLEVEL,
|
|
58
|
+
PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE,
|
|
59
|
+
PM_ERR_BLOCK_PARAM_PIPE_TERM,
|
|
60
|
+
PM_ERR_BLOCK_TERM_BRACE,
|
|
61
|
+
PM_ERR_BLOCK_TERM_END,
|
|
62
|
+
PM_ERR_CANNOT_PARSE_EXPRESSION,
|
|
63
|
+
PM_ERR_CANNOT_PARSE_STRING_PART,
|
|
64
|
+
PM_ERR_CASE_EXPRESSION_AFTER_CASE,
|
|
65
|
+
PM_ERR_CASE_EXPRESSION_AFTER_WHEN,
|
|
66
|
+
PM_ERR_CASE_MATCH_MISSING_PREDICATE,
|
|
67
|
+
PM_ERR_CASE_MISSING_CONDITIONS,
|
|
68
|
+
PM_ERR_CASE_TERM,
|
|
69
|
+
PM_ERR_CLASS_IN_METHOD,
|
|
70
|
+
PM_ERR_CLASS_NAME,
|
|
71
|
+
PM_ERR_CLASS_SUPERCLASS,
|
|
72
|
+
PM_ERR_CLASS_TERM,
|
|
73
|
+
PM_ERR_CLASS_UNEXPECTED_END,
|
|
74
|
+
PM_ERR_CLASS_VARIABLE_BARE,
|
|
75
|
+
PM_ERR_CONDITIONAL_ELSIF_PREDICATE,
|
|
76
|
+
PM_ERR_CONDITIONAL_IF_PREDICATE,
|
|
77
|
+
PM_ERR_CONDITIONAL_PREDICATE_TERM,
|
|
78
|
+
PM_ERR_CONDITIONAL_TERM,
|
|
79
|
+
PM_ERR_CONDITIONAL_TERM_ELSE,
|
|
80
|
+
PM_ERR_CONDITIONAL_UNLESS_PREDICATE,
|
|
81
|
+
PM_ERR_CONDITIONAL_UNTIL_PREDICATE,
|
|
82
|
+
PM_ERR_CONDITIONAL_WHILE_PREDICATE,
|
|
83
|
+
PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT,
|
|
84
|
+
PM_ERR_DEF_ENDLESS,
|
|
85
|
+
PM_ERR_DEF_ENDLESS_PARAMETERS,
|
|
86
|
+
PM_ERR_DEF_ENDLESS_SETTER,
|
|
87
|
+
PM_ERR_DEF_ENDLESS_DO_BLOCK,
|
|
88
|
+
PM_ERR_DEF_NAME,
|
|
89
|
+
PM_ERR_DEF_PARAMS_TERM,
|
|
90
|
+
PM_ERR_DEF_PARAMS_TERM_PAREN,
|
|
91
|
+
PM_ERR_DEF_RECEIVER,
|
|
92
|
+
PM_ERR_DEF_RECEIVER_TERM,
|
|
93
|
+
PM_ERR_DEF_TERM,
|
|
94
|
+
PM_ERR_DEFINED_EXPRESSION,
|
|
95
|
+
PM_ERR_EMBDOC_TERM,
|
|
96
|
+
PM_ERR_EMBEXPR_END,
|
|
97
|
+
PM_ERR_EMBVAR_INVALID,
|
|
98
|
+
PM_ERR_END_UPCASE_BRACE,
|
|
99
|
+
PM_ERR_END_UPCASE_TERM,
|
|
100
|
+
PM_ERR_ESCAPE_INVALID_CONTROL,
|
|
101
|
+
PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT,
|
|
102
|
+
PM_ERR_ESCAPE_INVALID_HEXADECIMAL,
|
|
103
|
+
PM_ERR_ESCAPE_INVALID_META,
|
|
104
|
+
PM_ERR_ESCAPE_INVALID_META_REPEAT,
|
|
105
|
+
PM_ERR_ESCAPE_INVALID_UNICODE,
|
|
106
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS,
|
|
107
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LIST,
|
|
108
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL,
|
|
109
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LONG,
|
|
110
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_SHORT,
|
|
111
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_TERM,
|
|
112
|
+
PM_ERR_EXPECT_ARGUMENT,
|
|
113
|
+
PM_ERR_EXPECT_EOL_AFTER_STATEMENT,
|
|
114
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ,
|
|
115
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA,
|
|
116
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL,
|
|
117
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS,
|
|
118
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN,
|
|
119
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR,
|
|
120
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ,
|
|
121
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT,
|
|
122
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH,
|
|
123
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_STAR,
|
|
124
|
+
PM_ERR_EXPECT_FOR_DELIMITER,
|
|
125
|
+
PM_ERR_EXPECT_IDENT_REQ_PARAMETER,
|
|
126
|
+
PM_ERR_EXPECT_IN_DELIMITER,
|
|
127
|
+
PM_ERR_EXPECT_LPAREN_AFTER_NOT_LPAREN,
|
|
128
|
+
PM_ERR_EXPECT_LPAREN_AFTER_NOT_OTHER,
|
|
129
|
+
PM_ERR_EXPECT_LPAREN_REQ_PARAMETER,
|
|
130
|
+
PM_ERR_EXPECT_MESSAGE,
|
|
131
|
+
PM_ERR_EXPECT_RBRACKET,
|
|
132
|
+
PM_ERR_EXPECT_RPAREN,
|
|
133
|
+
PM_ERR_EXPECT_RPAREN_AFTER_MULTI,
|
|
134
|
+
PM_ERR_EXPECT_RPAREN_REQ_PARAMETER,
|
|
135
|
+
PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER,
|
|
136
|
+
PM_ERR_EXPECT_STRING_CONTENT,
|
|
137
|
+
PM_ERR_EXPECT_WHEN_DELIMITER,
|
|
138
|
+
PM_ERR_EXPRESSION_BARE_HASH,
|
|
139
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE,
|
|
140
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING,
|
|
141
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE,
|
|
142
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_FILE,
|
|
143
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_LINE,
|
|
144
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_NIL,
|
|
145
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED,
|
|
146
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_SELF,
|
|
147
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE,
|
|
148
|
+
PM_ERR_FLOAT_PARSE,
|
|
149
|
+
PM_ERR_FOR_COLLECTION,
|
|
150
|
+
PM_ERR_FOR_IN,
|
|
151
|
+
PM_ERR_FOR_INDEX,
|
|
152
|
+
PM_ERR_FOR_TERM,
|
|
153
|
+
PM_ERR_GLOBAL_VARIABLE_BARE,
|
|
154
|
+
PM_ERR_HASH_EXPRESSION_AFTER_LABEL,
|
|
155
|
+
PM_ERR_HASH_KEY,
|
|
156
|
+
PM_ERR_HASH_ROCKET,
|
|
157
|
+
PM_ERR_HASH_TERM,
|
|
158
|
+
PM_ERR_HASH_VALUE,
|
|
159
|
+
PM_ERR_HEREDOC_IDENTIFIER,
|
|
160
|
+
PM_ERR_HEREDOC_TERM,
|
|
161
|
+
PM_ERR_INCOMPLETE_QUESTION_MARK,
|
|
162
|
+
PM_ERR_INCOMPLETE_VARIABLE_CLASS,
|
|
163
|
+
PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3,
|
|
164
|
+
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE,
|
|
165
|
+
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3,
|
|
166
|
+
PM_ERR_INSTANCE_VARIABLE_BARE,
|
|
167
|
+
PM_ERR_INVALID_BLOCK_EXIT,
|
|
168
|
+
PM_ERR_INVALID_CHARACTER,
|
|
169
|
+
PM_ERR_INVALID_COMMA,
|
|
170
|
+
PM_ERR_INVALID_ENCODING_MAGIC_COMMENT,
|
|
171
|
+
PM_ERR_INVALID_ESCAPE_CHARACTER,
|
|
172
|
+
PM_ERR_INVALID_FLOAT_EXPONENT,
|
|
173
|
+
PM_ERR_INVALID_LOCAL_VARIABLE_READ,
|
|
174
|
+
PM_ERR_INVALID_LOCAL_VARIABLE_WRITE,
|
|
175
|
+
PM_ERR_INVALID_MULTIBYTE_CHAR,
|
|
176
|
+
PM_ERR_INVALID_MULTIBYTE_CHARACTER,
|
|
177
|
+
PM_ERR_INVALID_MULTIBYTE_ESCAPE,
|
|
178
|
+
PM_ERR_INVALID_NUMBER_BINARY,
|
|
179
|
+
PM_ERR_INVALID_NUMBER_DECIMAL,
|
|
180
|
+
PM_ERR_INVALID_NUMBER_FRACTION,
|
|
181
|
+
PM_ERR_INVALID_NUMBER_HEXADECIMAL,
|
|
182
|
+
PM_ERR_INVALID_NUMBER_OCTAL,
|
|
183
|
+
PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
|
|
184
|
+
PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
|
|
185
|
+
PM_ERR_INVALID_PERCENT,
|
|
186
|
+
PM_ERR_INVALID_PERCENT_EOF,
|
|
187
|
+
PM_ERR_INVALID_PRINTABLE_CHARACTER,
|
|
188
|
+
PM_ERR_INVALID_RETRY_AFTER_ELSE,
|
|
189
|
+
PM_ERR_INVALID_RETRY_AFTER_ENSURE,
|
|
190
|
+
PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
|
|
191
|
+
PM_ERR_INVALID_SYMBOL,
|
|
192
|
+
PM_ERR_INVALID_VARIABLE_GLOBAL,
|
|
193
|
+
PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
|
|
194
|
+
PM_ERR_INVALID_YIELD,
|
|
195
|
+
PM_ERR_IT_NOT_ALLOWED_NUMBERED,
|
|
196
|
+
PM_ERR_IT_NOT_ALLOWED_ORDINARY,
|
|
197
|
+
PM_ERR_LAMBDA_OPEN,
|
|
198
|
+
PM_ERR_LAMBDA_TERM_BRACE,
|
|
199
|
+
PM_ERR_LAMBDA_TERM_END,
|
|
200
|
+
PM_ERR_LIST_I_LOWER_ELEMENT,
|
|
201
|
+
PM_ERR_LIST_I_LOWER_TERM,
|
|
202
|
+
PM_ERR_LIST_I_UPPER_ELEMENT,
|
|
203
|
+
PM_ERR_LIST_I_UPPER_TERM,
|
|
204
|
+
PM_ERR_LIST_W_LOWER_ELEMENT,
|
|
205
|
+
PM_ERR_LIST_W_LOWER_TERM,
|
|
206
|
+
PM_ERR_LIST_W_UPPER_ELEMENT,
|
|
207
|
+
PM_ERR_LIST_W_UPPER_TERM,
|
|
208
|
+
PM_ERR_MALLOC_FAILED,
|
|
209
|
+
PM_ERR_MIXED_ENCODING,
|
|
210
|
+
PM_ERR_MODULE_IN_METHOD,
|
|
211
|
+
PM_ERR_MODULE_NAME,
|
|
212
|
+
PM_ERR_MODULE_TERM,
|
|
213
|
+
PM_ERR_MULTI_ASSIGN_MULTI_SPLATS,
|
|
214
|
+
PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST,
|
|
215
|
+
PM_ERR_NESTING_TOO_DEEP,
|
|
216
|
+
PM_ERR_NO_LOCAL_VARIABLE,
|
|
217
|
+
PM_ERR_NON_ASSOCIATIVE_OPERATOR,
|
|
218
|
+
PM_ERR_NOT_EXPRESSION,
|
|
219
|
+
PM_ERR_NUMBER_LITERAL_UNDERSCORE,
|
|
220
|
+
PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK,
|
|
221
|
+
PM_ERR_NUMBERED_PARAMETER_IT,
|
|
222
|
+
PM_ERR_NUMBERED_PARAMETER_ORDINARY,
|
|
223
|
+
PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK,
|
|
224
|
+
PM_ERR_OPERATOR_MULTI_ASSIGN,
|
|
225
|
+
PM_ERR_OPERATOR_WRITE_ARGUMENTS,
|
|
226
|
+
PM_ERR_OPERATOR_WRITE_BLOCK,
|
|
227
|
+
PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI,
|
|
228
|
+
PM_ERR_PARAMETER_BLOCK_MULTI,
|
|
229
|
+
PM_ERR_PARAMETER_CIRCULAR,
|
|
230
|
+
PM_ERR_PARAMETER_FORWARDING_AFTER_REST,
|
|
231
|
+
PM_ERR_PARAMETER_METHOD_NAME,
|
|
232
|
+
PM_ERR_PARAMETER_NAME_DUPLICATED,
|
|
233
|
+
PM_ERR_PARAMETER_NO_DEFAULT,
|
|
234
|
+
PM_ERR_PARAMETER_NO_DEFAULT_KW,
|
|
235
|
+
PM_ERR_PARAMETER_NUMBERED_RESERVED,
|
|
236
|
+
PM_ERR_PARAMETER_ORDER,
|
|
237
|
+
PM_ERR_PARAMETER_SPLAT_MULTI,
|
|
238
|
+
PM_ERR_PARAMETER_STAR,
|
|
239
|
+
PM_ERR_PARAMETER_UNEXPECTED_FWD,
|
|
240
|
+
PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
|
|
241
|
+
PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
|
|
242
|
+
PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS,
|
|
243
|
+
PM_ERR_PATTERN_CAPTURE_DUPLICATE,
|
|
244
|
+
PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE,
|
|
245
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
|
|
246
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
|
|
247
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
|
|
248
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_IN,
|
|
249
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_KEY,
|
|
250
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN,
|
|
251
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PIN,
|
|
252
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE,
|
|
253
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE,
|
|
254
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_REST,
|
|
255
|
+
PM_ERR_PATTERN_FIND_MISSING_INNER,
|
|
256
|
+
PM_ERR_PATTERN_HASH_IMPLICIT,
|
|
257
|
+
PM_ERR_PATTERN_HASH_KEY,
|
|
258
|
+
PM_ERR_PATTERN_HASH_KEY_DUPLICATE,
|
|
259
|
+
PM_ERR_PATTERN_HASH_KEY_INTERPOLATED,
|
|
260
|
+
PM_ERR_PATTERN_HASH_KEY_LABEL,
|
|
261
|
+
PM_ERR_PATTERN_HASH_KEY_LOCALS,
|
|
262
|
+
PM_ERR_PATTERN_IDENT_AFTER_HROCKET,
|
|
263
|
+
PM_ERR_PATTERN_LABEL_AFTER_COMMA,
|
|
264
|
+
PM_ERR_PATTERN_REST,
|
|
265
|
+
PM_ERR_PATTERN_TERM_BRACE,
|
|
266
|
+
PM_ERR_PATTERN_TERM_BRACKET,
|
|
267
|
+
PM_ERR_PATTERN_TERM_PAREN,
|
|
268
|
+
PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN,
|
|
269
|
+
PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH,
|
|
270
|
+
PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8,
|
|
271
|
+
PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING,
|
|
272
|
+
PM_ERR_REGEXP_INVALID_CHAR_PROPERTY,
|
|
273
|
+
PM_ERR_REGEXP_INVALID_UNICODE_RANGE,
|
|
274
|
+
PM_ERR_REGEXP_NON_ESCAPED_MBC,
|
|
275
|
+
PM_ERR_REGEXP_PARSE_ERROR,
|
|
276
|
+
PM_ERR_REGEXP_TERM,
|
|
277
|
+
PM_ERR_REGEXP_UNKNOWN_OPTIONS,
|
|
278
|
+
PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP,
|
|
279
|
+
PM_ERR_RESCUE_EXPRESSION,
|
|
280
|
+
PM_ERR_RESCUE_MODIFIER_VALUE,
|
|
281
|
+
PM_ERR_RESCUE_TERM,
|
|
282
|
+
PM_ERR_RESCUE_VARIABLE,
|
|
283
|
+
PM_ERR_RETURN_INVALID,
|
|
284
|
+
PM_ERR_SCRIPT_NOT_FOUND,
|
|
285
|
+
PM_ERR_SINGLETON_FOR_LITERALS,
|
|
286
|
+
PM_ERR_STATEMENT_ALIAS,
|
|
287
|
+
PM_ERR_STATEMENT_POSTEXE_END,
|
|
288
|
+
PM_ERR_STATEMENT_PREEXE_BEGIN,
|
|
289
|
+
PM_ERR_STATEMENT_UNDEF,
|
|
290
|
+
PM_ERR_STRING_CONCATENATION,
|
|
291
|
+
PM_ERR_STRING_INTERPOLATED_TERM,
|
|
292
|
+
PM_ERR_STRING_LITERAL_EOF,
|
|
293
|
+
PM_ERR_STRING_LITERAL_TERM,
|
|
294
|
+
PM_ERR_SYMBOL_INVALID,
|
|
295
|
+
PM_ERR_SYMBOL_TERM_DYNAMIC,
|
|
296
|
+
PM_ERR_SYMBOL_TERM_INTERPOLATED,
|
|
297
|
+
PM_ERR_TERNARY_COLON,
|
|
298
|
+
PM_ERR_TERNARY_EXPRESSION_FALSE,
|
|
299
|
+
PM_ERR_TERNARY_EXPRESSION_TRUE,
|
|
300
|
+
PM_ERR_UNARY_DISALLOWED,
|
|
301
|
+
PM_ERR_UNARY_RECEIVER,
|
|
302
|
+
PM_ERR_UNDEF_ARGUMENT,
|
|
303
|
+
PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
|
|
304
|
+
PM_ERR_UNEXPECTED_INDEX_BLOCK,
|
|
305
|
+
PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
|
|
306
|
+
PM_ERR_UNEXPECTED_LABEL,
|
|
307
|
+
PM_ERR_UNEXPECTED_MULTI_WRITE,
|
|
308
|
+
PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE,
|
|
309
|
+
PM_ERR_UNEXPECTED_RANGE_OPERATOR,
|
|
310
|
+
PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
|
|
311
|
+
PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
|
|
312
|
+
PM_ERR_UNEXPECTED_TOKEN_IGNORE,
|
|
313
|
+
PM_ERR_UNTIL_TERM,
|
|
314
|
+
PM_ERR_VOID_EXPRESSION,
|
|
315
|
+
PM_ERR_WHILE_TERM,
|
|
316
|
+
PM_ERR_WRITE_TARGET_IN_METHOD,
|
|
317
|
+
PM_ERR_WRITE_TARGET_READONLY,
|
|
318
|
+
PM_ERR_WRITE_TARGET_UNEXPECTED,
|
|
319
|
+
PM_ERR_XSTRING_TERM,
|
|
320
|
+
|
|
321
|
+
/* These are the warning diagnostics. */
|
|
322
|
+
PM_WARN_AMBIGUOUS_BINARY_OPERATOR,
|
|
323
|
+
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS,
|
|
324
|
+
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
|
|
325
|
+
PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND,
|
|
326
|
+
PM_WARN_AMBIGUOUS_PREFIX_STAR,
|
|
327
|
+
PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR,
|
|
328
|
+
PM_WARN_AMBIGUOUS_SLASH,
|
|
329
|
+
PM_WARN_COMPARISON_AFTER_COMPARISON,
|
|
330
|
+
PM_WARN_DOT_DOT_DOT_EOL,
|
|
331
|
+
PM_WARN_EQUAL_IN_CONDITIONAL,
|
|
332
|
+
PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
|
|
333
|
+
PM_WARN_END_IN_METHOD,
|
|
334
|
+
PM_WARN_DUPLICATED_HASH_KEY,
|
|
335
|
+
PM_WARN_DUPLICATED_WHEN_CLAUSE,
|
|
336
|
+
PM_WARN_FLOAT_OUT_OF_RANGE,
|
|
337
|
+
PM_WARN_IGNORED_FROZEN_STRING_LITERAL,
|
|
338
|
+
PM_WARN_INDENTATION_MISMATCH,
|
|
339
|
+
PM_WARN_INTEGER_IN_FLIP_FLOP,
|
|
340
|
+
PM_WARN_INVALID_CHARACTER,
|
|
341
|
+
PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
|
|
342
|
+
PM_WARN_INVALID_NUMBERED_REFERENCE,
|
|
343
|
+
PM_WARN_KEYWORD_EOL,
|
|
344
|
+
PM_WARN_LITERAL_IN_CONDITION_DEFAULT,
|
|
345
|
+
PM_WARN_LITERAL_IN_CONDITION_VERBOSE,
|
|
346
|
+
PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE,
|
|
347
|
+
PM_WARN_SHEBANG_CARRIAGE_RETURN,
|
|
348
|
+
PM_WARN_UNEXPECTED_CARRIAGE_RETURN,
|
|
349
|
+
PM_WARN_UNREACHABLE_STATEMENT,
|
|
350
|
+
PM_WARN_UNUSED_LOCAL_VARIABLE,
|
|
351
|
+
PM_WARN_VOID_STATEMENT,
|
|
352
|
+
} pm_diagnostic_id_t;
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* This struct represents a diagnostic generated during parsing.
|
|
356
|
+
*/
|
|
357
|
+
struct pm_diagnostic_t {
|
|
358
|
+
/* The embedded base node. */
|
|
359
|
+
pm_list_node_t node;
|
|
360
|
+
|
|
361
|
+
/* The location of the diagnostic in the source. */
|
|
362
|
+
pm_location_t location;
|
|
363
|
+
|
|
364
|
+
/* The ID of the diagnostic. */
|
|
365
|
+
pm_diagnostic_id_t diag_id;
|
|
366
|
+
|
|
367
|
+
/* The message associated with the diagnostic. */
|
|
368
|
+
const char *message;
|
|
369
|
+
|
|
370
|
+
/*
|
|
371
|
+
* The level of the diagnostic, see `pm_error_level_t` and
|
|
372
|
+
* `pm_warning_level_t` for possible values.
|
|
373
|
+
*/
|
|
374
|
+
uint8_t level;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/*
|
|
378
|
+
* Append a diagnostic to the given list of diagnostics that is using shared
|
|
379
|
+
* memory for its message.
|
|
380
|
+
*/
|
|
381
|
+
void pm_diagnostic_list_append(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id);
|
|
382
|
+
|
|
383
|
+
/*
|
|
384
|
+
* Append a diagnostic to the given list of diagnostics that is using a format
|
|
385
|
+
* string for its message.
|
|
386
|
+
*/
|
|
387
|
+
void pm_diagnostic_list_append_format(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id, ...);
|
|
388
|
+
|
|
389
|
+
#endif
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_ENCODING_H
|
|
2
|
+
#define PRISM_INTERNAL_ENCODING_H
|
|
3
|
+
|
|
4
|
+
#include <stdbool.h>
|
|
5
|
+
#include <stddef.h>
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* This struct defines the functions necessary to implement the encoding
|
|
10
|
+
* interface so we can determine how many bytes the subsequent character takes.
|
|
11
|
+
* Each callback should return the number of bytes, or 0 if the next bytes are
|
|
12
|
+
* invalid for the encoding and type.
|
|
13
|
+
*/
|
|
14
|
+
typedef struct {
|
|
15
|
+
/*
|
|
16
|
+
* Return the number of bytes that the next character takes if it is valid
|
|
17
|
+
* in the encoding. Does not read more than n bytes. It is assumed that n is
|
|
18
|
+
* at least 1.
|
|
19
|
+
*/
|
|
20
|
+
size_t (*char_width)(const uint8_t *b, ptrdiff_t n);
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Return the number of bytes that the next character takes if it is valid
|
|
24
|
+
* in the encoding and is alphabetical. Does not read more than n bytes. It
|
|
25
|
+
* is assumed that n is at least 1.
|
|
26
|
+
*/
|
|
27
|
+
size_t (*alpha_char)(const uint8_t *b, ptrdiff_t n);
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Return the number of bytes that the next character takes if it is valid
|
|
31
|
+
* in the encoding and is alphanumeric. Does not read more than n bytes. It
|
|
32
|
+
* is assumed that n is at least 1.
|
|
33
|
+
*/
|
|
34
|
+
size_t (*alnum_char)(const uint8_t *b, ptrdiff_t n);
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Return true if the next character is valid in the encoding and is an
|
|
38
|
+
* uppercase character. Does not read more than n bytes. It is assumed that
|
|
39
|
+
* n is at least 1.
|
|
40
|
+
*/
|
|
41
|
+
bool (*isupper_char)(const uint8_t *b, ptrdiff_t n);
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* The name of the encoding. This should correspond to a value that can be
|
|
45
|
+
* passed to Encoding.find in Ruby.
|
|
46
|
+
*/
|
|
47
|
+
const char *name;
|
|
48
|
+
|
|
49
|
+
/* Return true if the encoding is a multibyte encoding. */
|
|
50
|
+
bool multibyte;
|
|
51
|
+
} pm_encoding_t;
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* All of the lookup tables use the first bit of each embedded byte to indicate
|
|
55
|
+
* whether the codepoint is alphabetical.
|
|
56
|
+
*/
|
|
57
|
+
#define PRISM_ENCODING_ALPHABETIC_BIT 1 << 0
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* All of the lookup tables use the second bit of each embedded byte to indicate
|
|
61
|
+
* whether the codepoint is alphanumeric.
|
|
62
|
+
*/
|
|
63
|
+
#define PRISM_ENCODING_ALPHANUMERIC_BIT 1 << 1
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* All of the lookup tables use the third bit of each embedded byte to indicate
|
|
67
|
+
* whether the codepoint is uppercase.
|
|
68
|
+
*/
|
|
69
|
+
#define PRISM_ENCODING_UPPERCASE_BIT 1 << 2
|
|
70
|
+
|
|
71
|
+
/* Return the size of the next character in the UTF-8 encoding. */
|
|
72
|
+
size_t pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n);
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* Return the size of the next character in the UTF-8 encoding if it is an
|
|
76
|
+
* alphabetical character.
|
|
77
|
+
*/
|
|
78
|
+
size_t pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n);
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Return the size of the next character in the UTF-8 encoding if it is an
|
|
82
|
+
* alphanumeric character.
|
|
83
|
+
*/
|
|
84
|
+
size_t pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n);
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
* Return true if the next character in the UTF-8 encoding if it is an uppercase
|
|
88
|
+
* character.
|
|
89
|
+
*/
|
|
90
|
+
bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n);
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* This lookup table is referenced in both the UTF-8 encoding file and the
|
|
94
|
+
* parser directly in order to speed up the default encoding processing. It is
|
|
95
|
+
* used to indicate whether a character is alphabetical, alphanumeric, or
|
|
96
|
+
* uppercase in unicode mappings.
|
|
97
|
+
*/
|
|
98
|
+
extern const uint8_t pm_encoding_unicode_table[256];
|
|
99
|
+
|
|
100
|
+
/* These are all of the encodings that prism supports. */
|
|
101
|
+
typedef enum {
|
|
102
|
+
PM_ENCODING_UTF_8 = 0,
|
|
103
|
+
PM_ENCODING_US_ASCII,
|
|
104
|
+
PM_ENCODING_ASCII_8BIT,
|
|
105
|
+
PM_ENCODING_EUC_JP,
|
|
106
|
+
PM_ENCODING_WINDOWS_31J,
|
|
107
|
+
|
|
108
|
+
/* We optionally support excluding the full set of encodings to only support the
|
|
109
|
+
* minimum necessary to process Ruby code without encoding comments. */
|
|
110
|
+
#ifndef PRISM_ENCODING_EXCLUDE_FULL
|
|
111
|
+
PM_ENCODING_BIG5,
|
|
112
|
+
PM_ENCODING_BIG5_HKSCS,
|
|
113
|
+
PM_ENCODING_BIG5_UAO,
|
|
114
|
+
PM_ENCODING_CESU_8,
|
|
115
|
+
PM_ENCODING_CP51932,
|
|
116
|
+
PM_ENCODING_CP850,
|
|
117
|
+
PM_ENCODING_CP852,
|
|
118
|
+
PM_ENCODING_CP855,
|
|
119
|
+
PM_ENCODING_CP949,
|
|
120
|
+
PM_ENCODING_CP950,
|
|
121
|
+
PM_ENCODING_CP951,
|
|
122
|
+
PM_ENCODING_EMACS_MULE,
|
|
123
|
+
PM_ENCODING_EUC_JP_MS,
|
|
124
|
+
PM_ENCODING_EUC_JIS_2004,
|
|
125
|
+
PM_ENCODING_EUC_KR,
|
|
126
|
+
PM_ENCODING_EUC_TW,
|
|
127
|
+
PM_ENCODING_GB12345,
|
|
128
|
+
PM_ENCODING_GB18030,
|
|
129
|
+
PM_ENCODING_GB1988,
|
|
130
|
+
PM_ENCODING_GB2312,
|
|
131
|
+
PM_ENCODING_GBK,
|
|
132
|
+
PM_ENCODING_IBM437,
|
|
133
|
+
PM_ENCODING_IBM720,
|
|
134
|
+
PM_ENCODING_IBM737,
|
|
135
|
+
PM_ENCODING_IBM775,
|
|
136
|
+
PM_ENCODING_IBM852,
|
|
137
|
+
PM_ENCODING_IBM855,
|
|
138
|
+
PM_ENCODING_IBM857,
|
|
139
|
+
PM_ENCODING_IBM860,
|
|
140
|
+
PM_ENCODING_IBM861,
|
|
141
|
+
PM_ENCODING_IBM862,
|
|
142
|
+
PM_ENCODING_IBM863,
|
|
143
|
+
PM_ENCODING_IBM864,
|
|
144
|
+
PM_ENCODING_IBM865,
|
|
145
|
+
PM_ENCODING_IBM866,
|
|
146
|
+
PM_ENCODING_IBM869,
|
|
147
|
+
PM_ENCODING_ISO_8859_1,
|
|
148
|
+
PM_ENCODING_ISO_8859_2,
|
|
149
|
+
PM_ENCODING_ISO_8859_3,
|
|
150
|
+
PM_ENCODING_ISO_8859_4,
|
|
151
|
+
PM_ENCODING_ISO_8859_5,
|
|
152
|
+
PM_ENCODING_ISO_8859_6,
|
|
153
|
+
PM_ENCODING_ISO_8859_7,
|
|
154
|
+
PM_ENCODING_ISO_8859_8,
|
|
155
|
+
PM_ENCODING_ISO_8859_9,
|
|
156
|
+
PM_ENCODING_ISO_8859_10,
|
|
157
|
+
PM_ENCODING_ISO_8859_11,
|
|
158
|
+
PM_ENCODING_ISO_8859_13,
|
|
159
|
+
PM_ENCODING_ISO_8859_14,
|
|
160
|
+
PM_ENCODING_ISO_8859_15,
|
|
161
|
+
PM_ENCODING_ISO_8859_16,
|
|
162
|
+
PM_ENCODING_KOI8_R,
|
|
163
|
+
PM_ENCODING_KOI8_U,
|
|
164
|
+
PM_ENCODING_MAC_CENT_EURO,
|
|
165
|
+
PM_ENCODING_MAC_CROATIAN,
|
|
166
|
+
PM_ENCODING_MAC_CYRILLIC,
|
|
167
|
+
PM_ENCODING_MAC_GREEK,
|
|
168
|
+
PM_ENCODING_MAC_ICELAND,
|
|
169
|
+
PM_ENCODING_MAC_JAPANESE,
|
|
170
|
+
PM_ENCODING_MAC_ROMAN,
|
|
171
|
+
PM_ENCODING_MAC_ROMANIA,
|
|
172
|
+
PM_ENCODING_MAC_THAI,
|
|
173
|
+
PM_ENCODING_MAC_TURKISH,
|
|
174
|
+
PM_ENCODING_MAC_UKRAINE,
|
|
175
|
+
PM_ENCODING_SHIFT_JIS,
|
|
176
|
+
PM_ENCODING_SJIS_DOCOMO,
|
|
177
|
+
PM_ENCODING_SJIS_KDDI,
|
|
178
|
+
PM_ENCODING_SJIS_SOFTBANK,
|
|
179
|
+
PM_ENCODING_STATELESS_ISO_2022_JP,
|
|
180
|
+
PM_ENCODING_STATELESS_ISO_2022_JP_KDDI,
|
|
181
|
+
PM_ENCODING_TIS_620,
|
|
182
|
+
PM_ENCODING_UTF8_MAC,
|
|
183
|
+
PM_ENCODING_UTF8_DOCOMO,
|
|
184
|
+
PM_ENCODING_UTF8_KDDI,
|
|
185
|
+
PM_ENCODING_UTF8_SOFTBANK,
|
|
186
|
+
PM_ENCODING_WINDOWS_1250,
|
|
187
|
+
PM_ENCODING_WINDOWS_1251,
|
|
188
|
+
PM_ENCODING_WINDOWS_1252,
|
|
189
|
+
PM_ENCODING_WINDOWS_1253,
|
|
190
|
+
PM_ENCODING_WINDOWS_1254,
|
|
191
|
+
PM_ENCODING_WINDOWS_1255,
|
|
192
|
+
PM_ENCODING_WINDOWS_1256,
|
|
193
|
+
PM_ENCODING_WINDOWS_1257,
|
|
194
|
+
PM_ENCODING_WINDOWS_1258,
|
|
195
|
+
PM_ENCODING_WINDOWS_874,
|
|
196
|
+
#endif
|
|
197
|
+
|
|
198
|
+
PM_ENCODING_MAXIMUM
|
|
199
|
+
} pm_encoding_type_t;
|
|
200
|
+
|
|
201
|
+
/* This is the table of all of the encodings that prism supports. */
|
|
202
|
+
extern const pm_encoding_t pm_encodings[PM_ENCODING_MAXIMUM];
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
* This is the default UTF-8 encoding. We need a reference to it to quickly
|
|
206
|
+
* create parsers.
|
|
207
|
+
*/
|
|
208
|
+
#define PM_ENCODING_UTF_8_ENTRY (&pm_encodings[PM_ENCODING_UTF_8])
|
|
209
|
+
|
|
210
|
+
/*
|
|
211
|
+
* This is the US-ASCII encoding. We need a reference to it to be able to
|
|
212
|
+
* compare against it when a string is being created because it could possibly
|
|
213
|
+
* need to fall back to ASCII-8BIT.
|
|
214
|
+
*/
|
|
215
|
+
#define PM_ENCODING_US_ASCII_ENTRY (&pm_encodings[PM_ENCODING_US_ASCII])
|
|
216
|
+
|
|
217
|
+
/*
|
|
218
|
+
* This is the ASCII-8BIT encoding. We need a reference to it so that pm_strpbrk
|
|
219
|
+
* can compare against it because invalid multibyte characters are not a thing
|
|
220
|
+
* in this encoding. It is also needed for handling Regexp encoding flags.
|
|
221
|
+
*/
|
|
222
|
+
#define PM_ENCODING_ASCII_8BIT_ENTRY (&pm_encodings[PM_ENCODING_ASCII_8BIT])
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
* This is the EUC-JP encoding. We need a reference to it to quickly process
|
|
226
|
+
* regular expression modifiers.
|
|
227
|
+
*/
|
|
228
|
+
#define PM_ENCODING_EUC_JP_ENTRY (&pm_encodings[PM_ENCODING_EUC_JP])
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* This is the Windows-31J encoding. We need a reference to it to quickly
|
|
232
|
+
* process regular expression modifiers.
|
|
233
|
+
*/
|
|
234
|
+
#define PM_ENCODING_WINDOWS_31J_ENTRY (&pm_encodings[PM_ENCODING_WINDOWS_31J])
|
|
235
|
+
|
|
236
|
+
/*
|
|
237
|
+
* Parse the given name of an encoding and return a pointer to the corresponding
|
|
238
|
+
* encoding struct if one can be found, otherwise return NULL.
|
|
239
|
+
*/
|
|
240
|
+
const pm_encoding_t * pm_encoding_find(const uint8_t *start, const uint8_t *end);
|
|
241
|
+
|
|
242
|
+
#endif
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This module provides functions for working with arbitrary-sized integers.
|
|
3
|
+
*/
|
|
4
|
+
#ifndef PRISM_INTERNAL_INTEGER_H
|
|
5
|
+
#define PRISM_INTERNAL_INTEGER_H
|
|
6
|
+
|
|
7
|
+
#include "prism/buffer.h"
|
|
8
|
+
#include "prism/integer.h"
|
|
9
|
+
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* An enum controlling the base of an integer. It is expected that the base is
|
|
14
|
+
* already known before parsing the integer, even though it could be derived
|
|
15
|
+
* from the string itself.
|
|
16
|
+
*/
|
|
17
|
+
typedef enum {
|
|
18
|
+
/* The default decimal base, with no prefix. Leading 0s will be ignored. */
|
|
19
|
+
PM_INTEGER_BASE_DEFAULT,
|
|
20
|
+
|
|
21
|
+
/* The binary base, indicated by a 0b or 0B prefix. */
|
|
22
|
+
PM_INTEGER_BASE_BINARY,
|
|
23
|
+
|
|
24
|
+
/* The octal base, indicated by a 0, 0o, or 0O prefix. */
|
|
25
|
+
PM_INTEGER_BASE_OCTAL,
|
|
26
|
+
|
|
27
|
+
/* The decimal base, indicated by a 0d, 0D, or empty prefix. */
|
|
28
|
+
PM_INTEGER_BASE_DECIMAL,
|
|
29
|
+
|
|
30
|
+
/* The hexadecimal base, indicated by a 0x or 0X prefix. */
|
|
31
|
+
PM_INTEGER_BASE_HEXADECIMAL,
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* An unknown base, in which case pm_integer_parse will derive it based on
|
|
35
|
+
* the content of the string. This is less efficient and does more
|
|
36
|
+
* comparisons, so if callers know the base ahead of time, they should use
|
|
37
|
+
* that instead.
|
|
38
|
+
*/
|
|
39
|
+
PM_INTEGER_BASE_UNKNOWN
|
|
40
|
+
} pm_integer_base_t;
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* Parse an integer from a string. This assumes that the format of the integer
|
|
44
|
+
* has already been validated, as internal validation checks are not performed
|
|
45
|
+
* here.
|
|
46
|
+
*/
|
|
47
|
+
void pm_integer_parse(pm_integer_t *integer, pm_integer_base_t base, const uint8_t *start, const uint8_t *end);
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Compare two integers. This function returns -1 if the left integer is less
|
|
51
|
+
* than the right integer, 0 if they are equal, and 1 if the left integer is
|
|
52
|
+
* greater than the right integer.
|
|
53
|
+
*/
|
|
54
|
+
int pm_integer_compare(const pm_integer_t *left, const pm_integer_t *right);
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* Reduce a ratio of integers to its simplest form.
|
|
58
|
+
*
|
|
59
|
+
* If either the numerator or denominator do not fit into a 32-bit integer, then
|
|
60
|
+
* this function is a no-op. In the future, we may consider reducing even the
|
|
61
|
+
* larger numbers, but for now we're going to keep it simple.
|
|
62
|
+
*/
|
|
63
|
+
void pm_integers_reduce(pm_integer_t *numerator, pm_integer_t *denominator);
|
|
64
|
+
|
|
65
|
+
/* Convert an integer to a decimal string. */
|
|
66
|
+
void pm_integer_string(pm_buffer_t *buffer, const pm_integer_t *integer);
|
|
67
|
+
|
|
68
|
+
#endif
|