forked from swissmicros/SDKdemo
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathparser.h
61 lines (55 loc) · 2.18 KB
/
parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef PARSER_H
#define PARSER_H
// ****************************************************************************
// parser.h DB48X project
// ****************************************************************************
//
// File Description:
//
// RPL parser information
//
// The parser turns text into RPL objects.
// It needs to operate on objects that can move due to garbage collection
//
//
//
//
//
// ****************************************************************************
// (C) 2022 Christophe de Dinechin <[email protected]>
// This software is licensed under the terms outlined in LICENSE.txt
// ****************************************************************************
// This file is part of DB48X.
//
// DB48X is free software: you can redistribute it and/or modify
// it under the terms outlined in the LICENSE.txt file
//
// DB48X is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// ****************************************************************************
#include "object.h"
#include "runtime.h"
struct parser
// ----------------------------------------------------------------------------
// Arguments to the PARSE command
// ----------------------------------------------------------------------------
{
typedef object::id id;
parser(utf8 source, size_t length, int precedence = 0, unicode separator=0)
: source(source), length(length), out(nullptr),
precedence(precedence), separator(separator)
{}
parser(const parser &from, utf8 source, int precedence)
: source(source),
length(from.length - (+source - +from.source)),
out(nullptr),
precedence(precedence), separator() {}
public:
gcutf8 source; // Text to parse
size_t length; // Length to parse -> length parsed
object_g out; // Output object if any
int precedence; // Precedence level in equations
unicode separator; // Separator in multi-part objects
};
#endif // PARSER_H