This commit tries to add support for the
[section]
first line
second line
syntax, i.e. non-assignments, without equal sign. Half-baked, but
still better than before. Also support some more Python 3, i.e.
dict.items() instead of iteritems()
Signed-off-by: Jan Lindemann <jan@janware.com>
Changes in Python 3 that made the code choke:
o basestring is merged into str
o print() needs parentesis
o Class inheritance syntax changed
o Abstract baseclass (ABCMeta) syntax changed
o map.iteritems() is replaced by map.items()
o Inconsistent use of tabs and spaces are no longer tolerated
Signed-off-by: Jan Lindemann <jan@janware.com>
run_sub_commands() was the only way to access subcommands up to now,
Cmds.run() adds another interface, an object as a place to add
customizations affecting all commands, e.g. global command line
options.
Signed-off-by: Jan Lindemann <jan@janware.com>
This replaces the mechanism to always construct lists with a leading
empty rule. This leads to many RR-conflicts, so this empty rule is omitted
and later added conditionally by grammar_fix_list_recursion(). Sadly,
the condition is bollocks, since it's always true.
Signed-off-by: Jan Lindemann <jan@janware.com>
- unroll_lists() sometimes introduced identical lists into a rule set
- unroll_options() sometimes chopped off a production's last rule
Signed-off-by: Jan Lindemann <jan@janware.com>
Add function grammar_add_configured_types() and keep configured types as
symbols as part of the grammar like all the others
Signed-off-by: Jan Lindemann <jan@janware.com>
Line numbers of parsed input are now automatically maintained. More
needed data structures are now automatically created in the API header
file.
Signed-off-by: Jan Lindemann <jan@janware.com>
First time parsing doesn't error out with a syntax error. No usable AST
is produced, strings are not returned from lexer, and AST lists aren't
lists, really.
TEXT:="Hello world!"; had to be excluded from the example, because I
don't get how this could be parsed with the given syntax. There's a
special sequence "all visible characters", but any lexer regex I could
think of will also match the types defining "alphabetic character" and
return the respective tokens (e.g. T_A) or vice-versa, depending on the
order in the lexer input file. I suppose, the only sensible way to
handle this, is to define "all visible characters" by defining the
tokens for the missing characters, and then use them along T_A ... T_Z
or their derived types.
Signed-off-by: Jan Lindemann <jan@janware.com>
Doesn't successfully parse grammartest.code, yet, it errors out with a
syntax error on whitespace. But at least it compiles and starts.
Signed-off-by: Jan Lindemann <jan@janware.com>
Arguments to --irrelevant-symbols are not meant to be represented in the
AST resulting from parsing.
Also, add pad() to misc.py.
Signed-off-by: Jan Lindemann <jan@janware.com>
More code is removed from the special parser directories and centralized
into grammar.py, Cmd.py, and generate-flex-bison.mk.
Signed-off-by: Jan Lindemann <jan@janware.com>
grammar.py is meant as a compiler compiler compiler, taking in a grammar
structure and returning flex and bison files. It can also parse EBNF.
Currently there are still remnants of VHDL-specific stuff in the code,
because parsing VHDL was what it was initially about.
Signed-off-by: Jan Lindemann <jan@janware.com>
Quoted arguments were not grouped into one token, firstly, because the
parser didn't pay any attention to them, and secondly, because the data
structure carrying the postfixed string converted it back to being a
string, not a list, in column 2 of the result table.
Signed-off-by: Jan Lindemann <jan@janware.com>
This was a namedtuple before, but I couldn't figure out how to ex-/import it
over module boundaries, so I've made it a class.
Signed-off-by: Jan Lindemann <jan@janware.com>