CliXoN
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
clixon_yang_parse.h
Go to the documentation of this file.
1 /*
2  * Yang 1.0 parser according to RFC6020.
3  * It is hopefully useful but not complete
4  * RFC7950 defines Yang version 1.1
5  *
6  ***** BEGIN LICENSE BLOCK *****
7 
8  Copyright (C) 2009-2017 Olof Hagsand and Benny Holmgren
9 
10  This file is part of CLIXON.
11 
12  Licensed under the Apache License, Version 2.0 (the "License");
13  you may not use this file except in compliance with the License.
14  You may obtain a copy of the License at
15 
16  http://www.apache.org/licenses/LICENSE-2.0
17 
18  Unless required by applicable law or agreed to in writing, software
19  distributed under the License is distributed on an "AS IS" BASIS,
20  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  See the License for the specific language governing permissions and
22  limitations under the License.
23 
24  Alternatively, the contents of this file may be used under the terms of
25  the GNU General Public License Version 3 or later (the "GPL"),
26  in which case the provisions of the GPL are applicable instead
27  of those above. If you wish to allow use of your version of this file only
28  under the terms of the GPL, and not to allow others to
29  use your version of this file under the terms of Apache License version 2,
30  indicate your decision by deleting the provisions above and replace them with
31  the notice and other provisions required by the GPL. If you do not delete
32  the provisions above, a recipient may use your version of this file under
33  the terms of any one of the Apache License version 2 or the GPL.
34 
35  ***** END LICENSE BLOCK *****
36 
37  * Database specification parser cli syntax
38  * (Cloned from cligen parser)
39  */
40 #ifndef _CLIXON_YANG_PARSE_H_
41 #define _CLIXON_YANG_PARSE_H_
42 
43 /*
44  * Types
45  */
46 
47 struct ys_stack{
48  struct ys_stack *ys_next;
49  struct yang_node *ys_node;
50 };
51 
52 struct clicon_yang_yacc_arg{ /* XXX: mostly unrelevant */
53  clicon_handle yy_handle; /* cligen_handle */
54  char *yy_name; /* Name of syntax (for error string) */
55  int yy_linenum; /* Number of \n in parsed buffer */
56  char *yy_parse_string; /* original (copy of) parse string */
57  void *yy_lexbuf; /* internal parse buffer from lex */
58  struct ys_stack *yy_stack; /* Stack of levels: push/pop on () and [] */
59  int yy_lex_state; /* lex start condition (ESCAPE/COMMENT) */
60  int yy_lex_string_state; /* lex start condition (STRING) */
61  yang_stmt *yy_module; /* top-level (sub)module - return value of
62  parser */
63 };
64 
65 /* This is a malloced piece of code we attach to cligen objects used as db-specs.
66  * So if(when) we translate cg_obj to yang_obj (or something). These are the fields
67  * we should add.
68  */
70  char *du_indexvar; /* (clicon) This command is a list and
71  this string is the key/index of the list
72  */
73  char *du_yang; /* (clicon) Save yang key for cli
74  generation */
75  int du_optional; /* (clicon) Optional element in list */
76  struct cg_var *du_default; /* default value(clicon) */
77  char du_vector; /* (clicon) Possibly more than one element */
78 };
79 
80 /*
81  * Variables
82  */
83 extern char *clixon_yang_parsetext;
84 
85 /*
86  * Prototypes
87  */
88 int yang_scan_init(struct clicon_yang_yacc_arg *ya);
89 int yang_scan_exit(struct clicon_yang_yacc_arg *ya);
90 
91 int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_spec *ysp);
93 
94 int clixon_yang_parselex(void *_ya);
95 int clixon_yang_parseparse(void *);
96 void clixon_yang_parseerror(void *_ya, char*);
97 
98 int ystack_pop(struct clicon_yang_yacc_arg *ya);
99 struct ys_stack *ystack_push(struct clicon_yang_yacc_arg *ya, yang_node *yn);
100 
101 #endif /* _CLIXON_YANG_PARSE_H_ */
int yy_lex_state
Definition: clixon_yang_parse.h:59
struct ys_stack * yy_stack
Definition: clixon_yang_parse.h:58
Definition: clixon_yang_parse.h:52
struct ys_stack * ystack_push(struct clicon_yang_yacc_arg *ya, yang_node *yn)
Definition: clixon_yang_parse.tab.c:360
char * clixon_yang_parsetext
Definition: clixon_yang_parse.l:84
struct ys_stack * ys_next
Definition: clixon_yang_parse.h:48
int yy_lex_string_state
Definition: clixon_yang_parse.h:60
struct cg_var * du_default
Definition: clixon_yang_parse.h:76
int yang_parse_exit(struct clicon_yang_yacc_arg *ya)
Definition: clixon_yang_parse.tab.c:343
char * yy_parse_string
Definition: clixon_yang_parse.h:56
clicon_handle yy_handle
Definition: clixon_yang_parse.h:53
char * du_yang
Definition: clixon_yang_parse.h:73
Definition: clixon_yang_parse.h:47
char * du_indexvar
Definition: clixon_yang_parse.h:70
int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_spec *ysp)
Definition: clixon_yang_parse.tab.c:336
void * yy_lexbuf
Definition: clixon_yang_parse.h:57
int clixon_yang_parseparse(void *)
int clixon_yang_parselex(void *_ya)
int ystack_pop(struct clicon_yang_yacc_arg *ya)
Definition: clixon_yang_parse.tab.c:349
int du_optional
Definition: clixon_yang_parse.h:75
Definition: clixon_yang_parse.h:69
int yang_scan_init(struct clicon_yang_yacc_arg *ya)
Definition: lex.clixon_yang_parse.c:2656
int yy_linenum
Definition: clixon_yang_parse.h:55
void clixon_yang_parseerror(void *_ya, char *)
Definition: clixon_yang_parse.tab.c:325
int yang_scan_exit(struct clicon_yang_yacc_arg *ya)
Definition: lex.clixon_yang_parse.c:2674
char * yy_name
Definition: clixon_yang_parse.h:54
struct yang_node * ys_node
Definition: clixon_yang_parse.h:49
yang_stmt * yy_module
Definition: clixon_yang_parse.h:61
char du_vector
Definition: clixon_yang_parse.h:77