English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/common-nfo/tools/nfotiser/parser.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3448 by tg, Wed Aug 8 14:55:33 2007 UTC revision 3449 by tg, Wed Aug 8 16:51:04 2007 UTC
# Line 43  Line 43 
43    
44  #include "nfotiser.h"  #include "nfotiser.h"
45    
46    /*
47     * Parsing works as follows:
48     *
49     * - strip completely empty line
50     * - strip line beginning with hash mark
51     * - if line ends with backslash, get next line that is not
52     *   + empty
53     *   + beginning with a hash mark
54     *   and look if it begins with a tab (if not: syntax error)
55     *   if so, strip backslash + newline + tab and repeat
56     * - if line begins with a tab, strip it and append line to
57     *   the last line, including the newline separator
58     * - match line with '([A-Za-z_][A-Za-z0-9_]*)\t(.*)$' and
59     *   call \1 the key and \2 the value (else: syntax error)
60     * - uppercase the key
61     * - enter the key/value pair in the system
62     *
63     * The following is also part of parsing, but left to the caller:
64     * - replace ${foo} with the value of key "foo"
65     * - undouble all backslashes
66     *
67     * We enter the key into the system up to three-fold:
68     * - KWT_NORMAL => ([A-Za-z_][A-Za-z0-9_]*)
69     *   + \1 = keyword (toupper'd)
70     * - KWT_MULTI => ([A-Za-z_][A-Za-z0-9_]*)_([A-Za-z0-9_]*)
71     *   + \1 = keyword (toupper'd)
72     *   + \2 = kw_multi (case preserving)
73     * - KWT_ITERATED => ([A-Za-z_][A-Za-z0-9_]*)_([0-9]*)
74     *   + \1 = keyword (toupper'd)
75     *   + \2 = kw_iter (unsigned integer value)
76     * - KWT_MULTITER => ([A-Za-z_][A-Za-z0-9_]*)_([0-9]*)_([A-Za-z0-9_]*)
77     *   + \1 = keyword (toupper'd)
78     *   + \2 = kw_iter (unsigned integer value)
79     *   + \3 = kw_multi (case preserving)
80     *
81     * Cf. https://www.freewrt.org/trac/wiki/Documentation/Specs/Freewrt_info_files
82     * for more examples and a more human-readable version of this specification.
83     */
84    
85  struct parser_result *  struct parser_result *
86  nfo_parse(int fd, const struct parser_keywords *kws)  nfo_parse(int fd, const struct parser_keywords *kws)
87  {  {

Legend:
Removed from v.3448  
changed lines
  Added in v.3449

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20