cctools
jx_parse.h
Go to the documentation of this file.
1/*
2Copyright (C) 2022 The University of Notre Dame
3This software is distributed under the GNU General Public License.
4See the file COPYING for details.
5*/
6
7#ifndef JX_PARSE_H
8#define JX_PARSE_H
9
20#include "jx.h"
21#include "link.h"
22
23#include <stdbool.h>
24#include <stdio.h>
25
26struct jx_parser;
27
28/* Sets module-wide flag for static parse mode */
29void jx_parse_set_static_mode( bool mode );
30
32struct jx * jx_parse_string( const char *str );
33
35struct jx * jx_parse_string_and_length( const char *str, int length );
36
38struct jx * jx_parse_stream( FILE *file );
39
41struct jx * jx_parse_file( const char *name );
42
44struct jx * jx_parse_link( struct link *l, time_t stoptime );
45
53struct jx *jx_parse_cmd_args(struct jx *jx_args, char *args_file);
54
61int jx_parse_cmd_define(struct jx *jx_args, char *define_stmt);
62
64struct jx_parser *jx_parser_create(bool strict_mode);
65
67void jx_parser_read_stream( struct jx_parser *p, FILE *file );
68
70void jx_parser_read_string( struct jx_parser *p, const char *str );
71
73void jx_parser_read_string_and_length( struct jx_parser *p, const char *str, int length );
74
76void jx_parser_read_link( struct jx_parser *p, struct link *l, time_t stoptime );
77
79struct jx * jx_parser_yield( struct jx_parser *p );
80
82struct jx * jx_parse( struct jx_parser *p );
83
85int jx_parser_errors( struct jx_parser *p );
86
88const char *jx_parser_error_string( struct jx_parser *p );
89
91void jx_parser_delete( struct jx_parser *p );
92
93/* Private function used by jx_print to put parens in the right place. */
94int jx_operator_precedence( jx_operator_t op );
95
96
97#endif
JSON Expressions (JX) library.
struct jx * jx_parse_string_and_length(const char *str, int length)
Parse a JSON string to a JX expression.
int jx_parser_errors(struct jx_parser *p)
Return number of parse errors.
void jx_parser_delete(struct jx_parser *p)
Delete a parser.
struct jx * jx_parse(struct jx_parser *p)
Parse a JX expression.
struct jx * jx_parse_string(const char *str)
Parse a JSON string to a JX expression.
void jx_parser_read_stream(struct jx_parser *p, FILE *file)
Attach parser to a file.
struct jx * jx_parse_stream(FILE *file)
Parse a standard IO stream to a JX expression.
void jx_parser_read_link(struct jx_parser *p, struct link *l, time_t stoptime)
Attach parser to a link.
const char * jx_parser_error_string(struct jx_parser *p)
Return text of first parse error encountered.
struct jx_parser * jx_parser_create(bool strict_mode)
Create a JX parser object.
struct jx * jx_parse_file(const char *name)
Parse a file to a JX expression.
struct jx * jx_parser_yield(struct jx_parser *p)
Parse and return a single value.
void jx_parser_read_string_and_length(struct jx_parser *p, const char *str, int length)
Attach parser to a raw string with known length.
struct jx * jx_parse_link(struct link *l, time_t stoptime)
Parse a network link to a JX expression.
void jx_parser_read_string(struct jx_parser *p, const char *str)
Attach parser to a null-terminate string.
struct jx * jx_parse_cmd_args(struct jx *jx_args, char *args_file)
Parse a jx argument file from a commandline option.
int jx_parse_cmd_define(struct jx *jx_args, char *define_stmt)
Parse a jx define statement from a commandline option.
JX value representing any expression type.
Definition jx.h:117