Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
parser_callbacks.py
Go to the documentation of this file.
1 ''' @file examples/ini_file/parser_callbacks.py
2 @brief The parser call back functions for the ini file class.
3 '''
4 import sys
5 import os
6 # add the current working directory to the path
7 # DO NOT MOVE THE FOLLOWING STATEMENT
8 # if using autopep8 formatter, for example, set argument '--ignore=E402'
9 sys.path.append(os.getcwd())
10 from apg_py.lib import identifiers as id
11 
12 
13 def line_end(cb):
14  if(cb['state'] == id.MATCH):
15  cb['user_data']['line_no'] += 1
16 
17 
19  if(cb['state'] == id.MATCH):
20  cb['user_data']['errors'].append({'line': cb['user_data']['line_no'],
21  'message': 'bad section definition'})
22 
23 
25  if(cb['state'] == id.MATCH):
26  cb['user_data']['errors'].append({'line': cb['user_data']['line_no'],
27  'message': 'bad key/value definition'})
28 
29 
31  if(cb['state'] == id.MATCH):
32  msg = 'invalid blank line, only white space and comments allowed'
33  cb['user_data']['errors'].append({'line': cb['user_data']['line_no'],
34  'message': msg})
Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.