Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/gravity
Path: blob/master/src/compiler/gravity_parser.h
1214 views
1
//
2
// gravity_parser.h
3
// gravity
4
//
5
// Created by Marco Bambini on 01/09/14.
6
// Copyright (c) 2014 CreoLabs. All rights reserved.
7
//
8
9
#ifndef __GRAVITY_PARSER__
10
#define __GRAVITY_PARSER__
11
12
#include "gravity_compiler.h"
13
#include "debug_macros.h"
14
#include "gravity_ast.h"
15
16
/*
17
Parser is responsible to build the AST, convert strings and number from tokens and
18
implement syntax error recovery strategy.
19
20
Notes about error recovery:
21
Each parse* function can return NULL in case of error but each function is RESPONSIBLE
22
to make appropriate actions in order to handle/recover errors.
23
24
Error recovery techniques can be:
25
Shallow Error Recovery
26
Deep Error Recovery
27
https://javacc.java.net/doc/errorrecovery.html
28
29
*/
30
31
// opaque datatype
32
typedef struct gravity_parser_t gravity_parser_t;
33
34
// public functions
35
gravity_parser_t *gravity_parser_create (const char *source, size_t len, uint32_t fileid, bool is_static);
36
gnode_t *gravity_parser_run (gravity_parser_t *parser, gravity_delegate_t *delegate);
37
void gravity_parser_free (gravity_parser_t *parser);
38
39
#endif
40
41