@@ -79,6 +79,41 @@ PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);
79
79
*/
80
80
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse (pm_parser_t * parser );
81
81
82
+ /**
83
+ * This function is used in pm_parse_stream to retrieve a line of input from a
84
+ * stream. It closely mirrors that of fgets so that fgets can be used as the
85
+ * default implementation.
86
+ */
87
+ typedef char * (pm_parse_stream_fgets_t )(char * string , int size , void * stream );
88
+
89
+ /**
90
+ * Parse a stream of Ruby source and return the tree.
91
+ *
92
+ * @param parser The parser to use.
93
+ * @param buffer The buffer to use.
94
+ * @param stream The stream to parse.
95
+ * @param fgets The function to use to read from the stream.
96
+ * @param options The optional options to use when parsing.
97
+ * @return The AST representing the source.
98
+ */
99
+ PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream (pm_parser_t * parser , pm_buffer_t * buffer , void * stream , pm_parse_stream_fgets_t * fgets , const pm_options_t * options );
100
+
101
+ // We optionally support serializing to a binary string. For systems that don't
102
+ // want or need this functionality, it can be turned off with the
103
+ // PRISM_EXCLUDE_SERIALIZATION define.
104
+ #ifndef PRISM_EXCLUDE_SERIALIZATION
105
+
106
+ /**
107
+ * Parse and serialize the AST represented by the source that is read out of the
108
+ * given stream into to the given buffer.
109
+ *
110
+ * @param buffer The buffer to serialize to.
111
+ * @param stream The stream to parse.
112
+ * @param fgets The function to use to read from the stream.
113
+ * @param data The optional data to pass to the parser.
114
+ */
115
+ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream (pm_buffer_t * buffer , void * stream , pm_parse_stream_fgets_t * fgets , const char * data );
116
+
82
117
/**
83
118
* Serialize the given list of comments to the given buffer.
84
119
*
@@ -155,6 +190,8 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t
155
190
*/
156
191
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex (pm_buffer_t * buffer , const uint8_t * source , size_t size , const char * data );
157
192
193
+ #endif
194
+
158
195
/**
159
196
* Parse the source and return true if it parses without errors or warnings.
160
197
*
@@ -190,6 +227,10 @@ const char * pm_token_type_human(pm_token_type_t token_type);
190
227
*/
191
228
PRISM_EXPORTED_FUNCTION void pm_parser_errors_format (const pm_parser_t * parser , pm_buffer_t * buffer , bool colorize );
192
229
230
+ // We optionally support dumping to JSON. For systems that don't want or need
231
+ // this functionality, it can be turned off with the PRISM_EXCLUDE_JSON define.
232
+ #ifndef PRISM_EXCLUDE_JSON
233
+
193
234
/**
194
235
* Dump JSON to the given buffer.
195
236
*
@@ -199,6 +240,8 @@ PRISM_EXPORTED_FUNCTION void pm_parser_errors_format(const pm_parser_t *parser,
199
240
*/
200
241
PRISM_EXPORTED_FUNCTION void pm_dump_json (pm_buffer_t * buffer , const pm_parser_t * parser , const pm_node_t * node );
201
242
243
+ #endif
244
+
202
245
/**
203
246
* @mainpage
204
247
*
0 commit comments