1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | '''
|
---|
4 | Created on 10.07.2009
|
---|
5 |
|
---|
6 | @author: hmueller
|
---|
7 |
|
---|
8 | Syntax description of bacula config files
|
---|
9 | '''
|
---|
10 |
|
---|
11 | from simpleparse.common import numbers, strings, comments
|
---|
12 | from simpleparse.parser import Parser
|
---|
13 |
|
---|
14 | import resource
|
---|
15 |
|
---|
16 | declaration = r"""
|
---|
17 | #text_pattern := ’\/’
|
---|
18 | #text_subst := delim_init / ’/’
|
---|
19 | #text_args := delim_init / ’)’
|
---|
20 | #text_exp := delim_init / delim_close / ’:’ / ’+’
|
---|
21 | text := delim_init / index_open /index_close
|
---|
22 | delim_init := '$'
|
---|
23 | delim_open := '{'
|
---|
24 | delim_close := '}'
|
---|
25 | index_open := '['
|
---|
26 | index_close := ']'
|
---|
27 | index_mark := '#'
|
---|
28 | name_chars := [a-zA-Z0-9]
|
---|
29 | """
|
---|
30 |
|
---|
31 | if __name__ == "__main__":
|
---|
32 | parser = Parser(declaration)
|
---|
33 |
|
---|
34 | #input ::= ( TEXT
|
---|
35 | # | variable
|
---|
36 | # | INDEX_OPEN input INDEX_CLOSE (loop_limits)?
|
---|
37 | # )*
|
---|
38 | #variable ::= DELIM_INIT (name|expression)
|
---|
39 | #name ::= (NAME_CHARS)+
|
---|
40 | #expression ::= DELIM_OPEN
|
---|
41 | # (name|variable)+
|
---|
42 | # (INDEX_OPEN num_exp INDEX_CLOSE)?
|
---|
43 | # (’:’ command)*
|
---|
44 | # DELIM_CLOSE
|
---|
45 | #command ::= ’-’ (TEXT_EXP|variable)+
|
---|
46 | # | ’+’ (TEXT_EXP|variable)+
|
---|
47 | # | ’o’ NUMBER (’-’|’,’) (NUMBER)?
|
---|
48 | # | ’#’
|
---|
49 | # | ’*’ (TEXT_EXP|variable)+
|
---|
50 | # | ’s’ ’/’ (TEXT_PATTERN)+
|
---|
51 | # ’/’ (variable|TEXT_SUBST)*
|
---|
52 | # ’/’ (’m’|’g’|’i’|’t’)*
|
---|
53 | # | ’y’ ’/’ (variable|TEXT_SUBST)+
|
---|
54 | # ’/’ (variable|TEXT_SUBST)*
|
---|
55 | # ’/’
|
---|
56 | # | ’p’ ’/’ NUMBER
|
---|
57 | # ’/’ (variable|TEXT_SUBST)*
|
---|
58 | # ’/’ (’r’|’l’|’c’)
|
---|
59 | # | ’%’ (name|variable)+
|
---|
60 | # (’(’ (TEXT_ARGS)? ’)’)?
|
---|
61 | # | ’l’
|
---|
62 | # | ’u’
|
---|
63 | # num_exp ::= operand
|
---|
64 | # | operand (’+’|’-’|’*’|’/’|’%’) num_exp
|
---|
65 | # operand ::= (’+’|’-’)? NUMBER
|
---|
66 | # | INDEX_MARK
|
---|
67 | # | ’(’ num_exp ’)’
|
---|
68 | # | variable
|
---|
69 | # loop_limits ::= DELIM_OPEN
|
---|
70 | # (num_exp)? ’,’ (num_exp)? (’,’ (num_exp)?)?
|
---|
71 | # DELIM_CLOSE
|
---|
72 | # NUMBER ::= (’0’|...|’9’)+
|
---|
73 | # TEXT_PATTERN::= (^(’/’))+
|
---|
74 | # TEXT_SUBST ::= (^(DELIM_INIT|’/’))+
|
---|
75 | # TEXT_ARGS ::= (^(DELIM_INIT|’)’))+
|
---|
76 | # TEXT_EXP ::= (^(DELIM_INIT|DELIM_CLOSE|’:’|’+’))+
|
---|
77 | # TEXT ::= (^(DELIM_INIT|INDEX_OPEN|INDEX_CLOSE))+
|
---|
78 | # DELIM_INIT ::= ’$’
|
---|
79 | # DELIM_OPEN ::= ’{’
|
---|
80 | # DELIM_CLOSE ::= ’}’
|
---|
81 | # INDEX_OPEN ::= ’[’
|
---|
82 | # INDEX_CLOSE ::= ’]’
|
---|
83 | # INDEX_MARK ::= ’#’
|
---|
84 | # NAME_CHARS ::= ’a’|...|’z’|’A’|...|’Z’|’0’|...|’9’
|
---|
85 |
|
---|