Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
… an
A
BNF
P
arser
G
enerator
Main Page
Related Pages
Packages
Packages
Package Functions
All
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
x
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
x
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
Classes
Class List
Class Index
Class Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
Functions
_
a
c
d
e
f
g
h
i
o
p
r
s
t
u
w
Variables
a
b
c
e
f
g
h
i
l
m
n
o
p
r
s
t
u
Files
File List
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
examples
grammar_object
main.py
Go to the documentation of this file.
1
''' @file examples/grammar_object/main.py
2
@brief The main function for the save and use grammar object demonstratons.
3
@dir examples/grammar_object
4
@brief An example of saving a grammar object and using it at a future time.
5
'''
6
import
sys
7
import
os
8
# add the current working directory to the path
9
# DO NOT MOVE THE FOLLOWING STATEMENT
10
# if using autopep8 formatter, for example, set argument '--ignore=E402'
11
sys.path.append(os.getcwd())
12
from
examples.grammar_object.save
import
save_grammar
13
from
examples.grammar_object.use
import
use_grammar
14
15
16
def
usage
():
17
display =
'usage: examples/grammar_object/main.py [--save | --use]\n'
18
display +=
' --save save the grammar object (default)\n'
19
display +=
' --use use the previously used grammar object\n'
20
return
display
21
22
23
test =
'save'
24
if(
len
(sys.argv) > 1):
25
if(sys.argv[1] ==
'--use'
):
26
# use the previously saved grammar object
27
use_grammar
()
28
exit()
29
if(sys.argv[1] !=
'--save'
):
30
print(
usage
())
31
exit()
32
33
# default is to save the grammar object for future use
34
save_grammar
()
examples.basics.substrings.len
int len
Definition:
substrings.py:27
examples.grammar_object.main.usage
def usage()
Definition:
main.py:16
examples.grammar_object.save
Definition:
save.py:1
examples.grammar_object.save.save_grammar
def save_grammar()
Definition:
save.py:20
examples.grammar_object.use
Definition:
use.py:1
examples.grammar_object.use.use_grammar
def use_grammar()
Definition:
use.py:21
Generated by
1.9.1
Python APG, Version 1.0, is licensed under the
2-Clause BSD License
,
an
Open Source Initiative
Approved License.