Skip to content

Commit d7988f8

Browse files
andrykonchineregon
authored andcommitted
1 parent 3545de8 commit d7988f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+13830
-13068
lines changed

src/main/c/yarp/.gitignore

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
/vendor/bundle
1212

1313
/build/
14-
/lib/yarp/yarp.*
15-
/lib/yarp.bundle
16-
/lib/yarp.so
14+
/lib/prism/prism.*
15+
/lib/prism.bundle
16+
/lib/prism.so
1717
/test.rb
1818
*.dSYM
1919
/*.iml
@@ -22,15 +22,19 @@
2222
test.c
2323
a.out
2424

25-
/ext/yarp/api_node.c
25+
/ext/prism/api_node.c
2626
/fuzz/output/
27-
/include/yarp/ast.h
28-
/java/org/yarp/AbstractNodeVisitor.java
29-
/java/org/yarp/Loader.java
30-
/java/org/yarp/Nodes.java
31-
/lib/yarp/mutation_visitor.rb
32-
/lib/yarp/node.rb
33-
/lib/yarp/serialize.rb
27+
/include/prism/ast.h
28+
/java/org/prism/AbstractNodeVisitor.java
29+
/java/org/prism/Loader.java
30+
/java/org/prism/Nodes.java
31+
/lib/prism/compiler.rb
32+
/lib/prism/dispatcher.rb
33+
/lib/prism/dsl.rb
34+
/lib/prism/mutation_compiler.rb
35+
/lib/prism/node.rb
36+
/lib/prism/serialize.rb
37+
/lib/prism/visitor.rb
3438
/src/node.c
3539
/src/prettyprint.c
3640
/src/serialize.c

src/main/c/yarp/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ build/librubyparser.a: $(STATIC_OBJECTS)
3535
build/shared/%.o: src/%.c Makefile $(HEADERS)
3636
$(ECHO) "compiling $@"
3737
$(Q) mkdir -p $(@D)
38-
$(Q) $(CC) $(DEBUG_FLAGS) -DYP_EXPORT_SYMBOLS $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
38+
$(Q) $(CC) $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
3939

4040
build/static/%.o: src/%.c Makefile $(HEADERS)
4141
$(ECHO) "compiling $@"
@@ -55,20 +55,20 @@ build/fuzz.heisenbug.%: $(SOURCES) fuzz/%.c fuzz/heisenbug.c
5555

5656
fuzz-debug:
5757
$(ECHO) "entering debug shell"
58-
$(Q) docker run -it --rm -e HISTFILE=/yarp/fuzz/output/.bash_history -v $(shell pwd):/yarp -v $(FUZZ_OUTPUT_DIR):/fuzz_output yarp/fuzz
58+
$(Q) docker run -it --rm -e HISTFILE=/prism/fuzz/output/.bash_history -v $(shell pwd):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz
5959

6060
fuzz-docker-build: fuzz/docker/Dockerfile
6161
$(ECHO) "building docker image"
62-
$(Q) docker build -t yarp/fuzz fuzz/docker/
62+
$(Q) docker build -t prism/fuzz fuzz/docker/
6363

6464
fuzz-run-%: FORCE fuzz-docker-build
6565
$(ECHO) "generating templates"
6666
$(Q) bundle exec rake templates
6767
$(ECHO) "running $* fuzzer"
68-
$(Q) docker run --rm -v $(shell pwd):/yarp yarp/fuzz /bin/bash -c "FUZZ_FLAGS=\"$(FUZZ_FLAGS)\" make build/fuzz.$*"
68+
$(Q) docker run --rm -v $(shell pwd):/prism prism/fuzz /bin/bash -c "FUZZ_FLAGS=\"$(FUZZ_FLAGS)\" make build/fuzz.$*"
6969
$(ECHO) "starting AFL++ run"
7070
$(Q) mkdir -p $(FUZZ_OUTPUT_DIR)/$*
71-
$(Q) docker run -it --rm -v $(shell pwd):/yarp -v $(FUZZ_OUTPUT_DIR):/fuzz_output yarp/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*"
71+
$(Q) docker run -it --rm -v $(shell pwd):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*"
7272
FORCE:
7373

7474
fuzz-clean:

src/main/c/yarp/include/prism.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#ifndef PRISM_H
2+
#define PRISM_H
3+
4+
#include "prism/defines.h"
5+
#include "prism/ast.h"
6+
#include "prism/diagnostic.h"
7+
#include "prism/node.h"
8+
#include "prism/pack.h"
9+
#include "prism/parser.h"
10+
#include "prism/regexp.h"
11+
#include "prism/unescape.h"
12+
#include "prism/util/pm_buffer.h"
13+
#include "prism/util/pm_char.h"
14+
#include "prism/util/pm_memchr.h"
15+
#include "prism/util/pm_strpbrk.h"
16+
#include "prism/version.h"
17+
18+
#include <assert.h>
19+
#include <errno.h>
20+
#include <stdarg.h>
21+
#include <stdbool.h>
22+
#include <stdint.h>
23+
#include <stdio.h>
24+
#include <stdlib.h>
25+
#include <string.h>
26+
27+
#ifndef _WIN32
28+
#include <strings.h>
29+
#endif
30+
31+
void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
32+
33+
void pm_print_node(pm_parser_t *parser, pm_node_t *node);
34+
35+
void pm_parser_metadata(pm_parser_t *parser, const char *metadata);
36+
37+
// Generate a scope node from the given node.
38+
void pm_scope_node_init(pm_node_t *node, pm_scope_node_t *dest);
39+
40+
// The prism version and the serialization format.
41+
PRISM_EXPORTED_FUNCTION const char * pm_version(void);
42+
43+
// Initialize a parser with the given start and end pointers.
44+
PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const char *filepath);
45+
46+
// Register a callback that will be called whenever prism changes the encoding it
47+
// is using to parse based on the magic comment.
48+
PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_changed_callback_t callback);
49+
50+
// Register a callback that will be called when prism encounters a magic comment
51+
// with an encoding referenced that it doesn't understand. The callback should
52+
// return NULL if it also doesn't understand the encoding or it should return a
53+
// pointer to a pm_encoding_t struct that contains the functions necessary to
54+
// parse identifiers.
55+
PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_decode_callback(pm_parser_t *parser, pm_encoding_decode_callback_t callback);
56+
57+
// Free any memory associated with the given parser.
58+
PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);
59+
60+
// Parse the Ruby source associated with the given parser and return the tree.
61+
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser);
62+
63+
// Pretty-prints the AST represented by the given node to the given buffer.
64+
PRISM_EXPORTED_FUNCTION void pm_prettyprint(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
65+
66+
// Serialize the AST represented by the given node to the given buffer.
67+
PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
68+
69+
// Parse the given source to the AST and serialize the AST to the given buffer.
70+
PRISM_EXPORTED_FUNCTION void pm_parse_serialize(const uint8_t *source, size_t size, pm_buffer_t *buffer, const char *metadata);
71+
72+
// Lex the given source and serialize to the given buffer.
73+
PRISM_EXPORTED_FUNCTION void pm_lex_serialize(const uint8_t *source, size_t size, const char *filepath, pm_buffer_t *buffer);
74+
75+
// Parse and serialize both the AST and the tokens represented by the given
76+
// source to the given buffer.
77+
PRISM_EXPORTED_FUNCTION void pm_parse_lex_serialize(const uint8_t *source, size_t size, pm_buffer_t *buffer, const char *metadata);
78+
79+
// Returns a string representation of the given token type.
80+
PRISM_EXPORTED_FUNCTION const char * pm_token_type_to_str(pm_token_type_t token_type);
81+
82+
#endif

0 commit comments

Comments
 (0)