blob: 94ec0d9ffd3c5127248ee603071d59f7e907d34e (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/* argot - Gray's Extensible Configuration System
Copyright (C) 2007-2016 Sergey Poznyakoff
Grecs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
Grecs 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "argot.h"
int argot_error_count = 0;
int argot_default_port = 0;
int argot_trace_flags = 0;
int argot_parser_options = 0;
#ifndef ARGOT_DEFAULT_PARSER
# define ARGOT_DEFAULT_PARSER argot_argot_parser
#endif
struct argot_node *(*argot_parser_fun)(const char *name, int trace) =
ARGOT_DEFAULT_PARSER;
void
argot_gram_trace(int n)
{
if (n)
argot_trace_flags |= ARGOT_TRACE_GRAM;
else
argot_trace_flags &= ~ARGOT_TRACE_GRAM;
}
void
argot_lex_trace(int n)
{
if (n)
argot_trace_flags |= ARGOT_TRACE_LEX;
else
argot_trace_flags &= ~ARGOT_TRACE_LEX;
}
struct argot_node *
argot_parse(const char *name)
{
if (!argot_trace_flags) {
char *p = getenv("ARGOT_DEBUG");
if (p) {
while (*p) {
switch (*p++) {
case 'g':
case 'G':
argot_trace_flags |= ARGOT_TRACE_GRAM;
break;
case 'l':
case 'L':
argot_trace_flags |= ARGOT_TRACE_LEX;
break;
}
}
}
}
argot_error_count = 0;
argot_current_locus_point.file = argot_install_text(name);
argot_current_locus_point.line = 1;
argot_current_locus_point.col = 0;
return argot_parser_fun(name, argot_trace_flags);
}
|