expr: add 'ident' value to ExprDef union

This distinguishes between an identifier expression and a string
expression in the union.

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: add constructors for more expression types

This makes the parser a bit more declarative. But really it might make
error handling easier.

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: add constructor for boolean expressions

Also add a 'bool set' to the ExprDef union, instead of using 'ival' as a
bool.

Signed-off-by: Ran Benita <ran234@gmail.com>
parser: remove 'uval' yylval type

We don't care about DoodadType.

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: use ExprCreate in more places

Signed-off-by: Ran Benita <ran234@gmail.com>
parser, symbols: drop unnecessary casts

It's casted into ExprDef and then uncasted for no reason.

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: split expression types and allocate them separately

Currently, we have one ExprDef type, which contains a tagged union with
the value of all expression types. Turns out, this union is quite
wasteful memory-wise. Instead, create separate types for all expressions
(e.g ExprBinary, ExprInteger) which embed the common fields
(ExprCommon), and malloc them per their size; ExprDef then becomes a
union of all these types, but is just used as a generic pointer.

[Instead of making ExprDef a union, another option is to use
ExprCommon as the generic pointer type and then do up-castings, like we
do with ParseCommon. But this makes the code much uglier.]

The diff is mostly straightforward mechanical adaptations. It could have
been much smaller with the help of C11 anonymous structs (which were
previously a gnu extension). This will have saved all of the 'op' ->
'expr->op', etc changes. But if we can be a bit more portable for a
little effort, we should.

Before (./test/rulescomp, x86 32 bit, -O2):
==12974==   total heap usage: 145,217 allocs, 145,217 frees, 10,476,238 bytes allocated

After:
==11145==   total heap usage: 145,217 allocs, 145,217 frees, 8,270,358 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: add wrapper macro for ExprCreate

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: make Expr creation naming and file location consistent

Signed-off-by: Ran Benita <ran234@gmail.com>
atom: drop {xkb_,}atom_strdup

Even though in 112cccb18ad1bc877b3c4a87fa536ea085c761b5 I said it might
be useful, it's not. So remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
atom: allow interning empty string

Which is different than XKB_ATOM_NONE, as in "" != NULL.

Signed-off-by: Ran Benita <ran234@gmail.com>
atom: allow passing NULLs to find_node_pointer()

Signed-off-by: Ran Benita <ran234@gmail.com>
atom: tiny style fixes

Signed-off-by: Ran Benita <ran234@gmail.com>
test/atom: add test for atom table

Mostly a random test.

Signed-off-by: Ran Benita <ran234@gmail.com>
atom: don't malloc every node separately

Instead of having a darray of pointers to malloc'ed atom_node's, make it
a darray of atom_node's directly.

This makes the code a bit simpler, saves on some malloc's, and the
memory gain/loss even out.

Unfortunately, we are no longer Three Star Programmers ;(
http://c2.com/cgi/wiki?ThreeStarProgrammer

Signed-off-by: Ran Benita <ran234@gmail.com>