prism 2.0.0.rc2 → 2.0.0
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 +4 -4
- data/CHANGELOG.md +9 -2
- data/docs/serialization.md +19 -6
- data/ext/prism/api_node.c +80 -80
- data/ext/prism/extension.c +34 -67
- data/ext/prism/extension.h +1 -1
- data/include/prism/arena.h +8 -0
- data/include/prism/arena.hpp +42 -0
- data/include/prism/ast.h +11 -1
- data/include/prism/ast.hpp +641 -0
- data/include/prism/buffer.h +8 -0
- data/include/prism/buffer.hpp +55 -0
- data/include/prism/comments.h +17 -0
- data/include/prism/compiler/branch.h +26 -0
- data/include/prism/compiler/cplusplus.hpp +16 -0
- data/include/prism/compiler/exceptions.hpp +17 -0
- data/include/prism/compiler/format.h +2 -0
- data/include/prism/compiler/lifetimebound.hpp +25 -0
- data/include/prism/constant_pool.h +25 -0
- data/include/prism/diagnostic.h +18 -0
- data/include/prism/errors_format.h +8 -0
- data/include/prism/internal/node.h +8 -4
- data/include/prism/internal/stringy.h +1 -6
- data/include/prism/json.h +8 -0
- data/include/prism/line_offset_list.h +8 -0
- data/include/prism/magic_comments.h +18 -0
- data/include/prism/node.h +55 -10
- data/include/prism/node.hpp +272 -0
- data/include/prism/node_type.hpp +38 -0
- data/include/prism/options.h +10 -1
- data/include/prism/options.hpp +43 -0
- data/include/prism/parser.h +72 -64
- data/include/prism/parser.hpp +274 -0
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/serialize.h +8 -0
- data/include/prism/source.h +8 -0
- data/include/prism/stream.h +8 -0
- data/include/prism/string_query.h +8 -0
- data/include/prism/stringy.h +16 -27
- data/include/prism/stringy.hpp +31 -0
- data/include/prism/version.h +9 -1
- data/include/prism.h +0 -8
- data/include/prism.hpp +24 -0
- data/lib/prism/serialize.rb +2549 -3281
- data/prism.gemspec +14 -1
- data/rbi/generated/prism/node.rbi +736 -0
- data/rbi/generated/prism/serialize.rbi +6 -5
- data/sig/generated/prism/node.rbs +736 -0
- data/sig/generated/prism/serialize.rbs +7 -5
- data/src/comments.c +2 -2
- data/src/diagnostic.c +8 -0
- data/src/node.c +216 -368
- data/src/options.c +7 -13
- data/src/parser.c +52 -48
- data/src/prism.c +175 -194
- data/src/regexp.c +0 -1
- data/src/serialize.c +2300 -1950
- data/src/source.c +8 -2
- data/src/stringy.c +3 -33
- metadata +14 -1
data/src/source.c
CHANGED
|
@@ -377,7 +377,13 @@ pm_source_stream_read(pm_source_t *source) {
|
|
|
377
377
|
*/
|
|
378
378
|
#define LINE_FILL 0xff
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
/*
|
|
381
|
+
* The fgets and feof members share their names with standard library
|
|
382
|
+
* functions, which <stdio.h> may define as function-like macros (newlib on
|
|
383
|
+
* Cygwin does this for feof). Parenthesizing the member access keeps those
|
|
384
|
+
* macros from expanding at the call sites.
|
|
385
|
+
*/
|
|
386
|
+
while (memset(line, LINE_FILL, LINE_SIZE), (source->stream.fgets)(line, LINE_SIZE, source->stream.stream) != NULL) {
|
|
381
387
|
/*
|
|
382
388
|
* Locate the NUL terminator written by fgets (the last NUL in the
|
|
383
389
|
* buffer) to recover the length of the chunk, then drop the terminator.
|
|
@@ -408,7 +414,7 @@ pm_source_stream_read(pm_source_t *source) {
|
|
|
408
414
|
* EOF. A newline-terminated line needs no such check: if it happens to
|
|
409
415
|
* be the last line, the next fgets returns NULL and ends the loop.
|
|
410
416
|
*/
|
|
411
|
-
if (!newline && !source->stream.feof(source->stream.stream)) {
|
|
417
|
+
if (!newline && !(source->stream.feof)(source->stream.stream)) {
|
|
412
418
|
continue;
|
|
413
419
|
}
|
|
414
420
|
|
data/src/stringy.c
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#include "prism/internal/stringy.h"
|
|
2
2
|
|
|
3
|
-
#include "prism/internal/allocator.h"
|
|
4
|
-
|
|
5
3
|
#include <assert.h>
|
|
6
|
-
#include <stdlib.h>
|
|
7
4
|
#include <string.h>
|
|
8
5
|
|
|
9
6
|
/**
|
|
@@ -14,34 +11,17 @@ pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *
|
|
|
14
11
|
assert(start <= end);
|
|
15
12
|
|
|
16
13
|
*string = (pm_string_t) {
|
|
17
|
-
.type = PM_STRING_SHARED,
|
|
18
14
|
.source = start,
|
|
19
15
|
.length = (size_t) (end - start)
|
|
20
16
|
};
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
/**
|
|
24
|
-
* Initialize
|
|
25
|
-
*/
|
|
26
|
-
void
|
|
27
|
-
pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) {
|
|
28
|
-
*string = (pm_string_t) {
|
|
29
|
-
.type = PM_STRING_OWNED,
|
|
30
|
-
.source = source,
|
|
31
|
-
.length = length
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Initialize a constant string that doesn't own its memory source.
|
|
20
|
+
* Initialize a string that views the given bytes.
|
|
37
21
|
*/
|
|
38
22
|
void
|
|
39
|
-
|
|
40
|
-
*string = (pm_string_t) {
|
|
41
|
-
.type = PM_STRING_CONSTANT,
|
|
42
|
-
.source = (const uint8_t *) source,
|
|
43
|
-
.length = length
|
|
44
|
-
};
|
|
23
|
+
pm_string_init(pm_string_t *string, const uint8_t *source, size_t length) {
|
|
24
|
+
*string = (pm_string_t) { .source = source, .length = length };
|
|
45
25
|
}
|
|
46
26
|
|
|
47
27
|
/**
|
|
@@ -79,13 +59,3 @@ const uint8_t *
|
|
|
79
59
|
pm_string_source(const pm_string_t *string) {
|
|
80
60
|
return string->source;
|
|
81
61
|
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Free the associated memory of the given string.
|
|
85
|
-
*/
|
|
86
|
-
void
|
|
87
|
-
pm_string_cleanup(pm_string_t *string) {
|
|
88
|
-
if (string->type == PM_STRING_OWNED) {
|
|
89
|
-
xfree_sized((void *) string->source, string->length);
|
|
90
|
-
}
|
|
91
|
-
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prism
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ruby developers
|
|
@@ -48,15 +48,22 @@ files:
|
|
|
48
48
|
- ext/prism/extension.c
|
|
49
49
|
- ext/prism/extension.h
|
|
50
50
|
- include/prism.h
|
|
51
|
+
- include/prism.hpp
|
|
51
52
|
- include/prism/arena.h
|
|
53
|
+
- include/prism/arena.hpp
|
|
52
54
|
- include/prism/ast.h
|
|
55
|
+
- include/prism/ast.hpp
|
|
53
56
|
- include/prism/buffer.h
|
|
57
|
+
- include/prism/buffer.hpp
|
|
54
58
|
- include/prism/comments.h
|
|
55
59
|
- include/prism/compiler/accel.h
|
|
56
60
|
- include/prism/compiler/align.h
|
|
57
61
|
- include/prism/compiler/assume.h
|
|
62
|
+
- include/prism/compiler/branch.h
|
|
58
63
|
- include/prism/compiler/bswap.h
|
|
64
|
+
- include/prism/compiler/cplusplus.hpp
|
|
59
65
|
- include/prism/compiler/endianness.h
|
|
66
|
+
- include/prism/compiler/exceptions.hpp
|
|
60
67
|
- include/prism/compiler/exported.h
|
|
61
68
|
- include/prism/compiler/fallthrough.h
|
|
62
69
|
- include/prism/compiler/filesystem.h
|
|
@@ -64,6 +71,7 @@ files:
|
|
|
64
71
|
- include/prism/compiler/force_inline.h
|
|
65
72
|
- include/prism/compiler/format.h
|
|
66
73
|
- include/prism/compiler/inline.h
|
|
74
|
+
- include/prism/compiler/lifetimebound.hpp
|
|
67
75
|
- include/prism/compiler/nodiscard.h
|
|
68
76
|
- include/prism/compiler/nonnull.h
|
|
69
77
|
- include/prism/compiler/unused.h
|
|
@@ -104,14 +112,19 @@ files:
|
|
|
104
112
|
- include/prism/line_offset_list.h
|
|
105
113
|
- include/prism/magic_comments.h
|
|
106
114
|
- include/prism/node.h
|
|
115
|
+
- include/prism/node.hpp
|
|
116
|
+
- include/prism/node_type.hpp
|
|
107
117
|
- include/prism/options.h
|
|
118
|
+
- include/prism/options.hpp
|
|
108
119
|
- include/prism/parser.h
|
|
120
|
+
- include/prism/parser.hpp
|
|
109
121
|
- include/prism/prettyprint.h
|
|
110
122
|
- include/prism/serialize.h
|
|
111
123
|
- include/prism/source.h
|
|
112
124
|
- include/prism/stream.h
|
|
113
125
|
- include/prism/string_query.h
|
|
114
126
|
- include/prism/stringy.h
|
|
127
|
+
- include/prism/stringy.hpp
|
|
115
128
|
- include/prism/version.h
|
|
116
129
|
- lib/prism.rb
|
|
117
130
|
- lib/prism/compiler.rb
|