Working C grammar in ixml

I have created a grammar for C which can be found here:
https://github.com/libxmq/xmq/blob/master/grammars/languages/c.ixml

Here is a test example
https://github.com/libxmq/xmq/blob/master/grammars/languages/c-tests/test.c

The grammar contains a single =< that means that the rule

type_identifier =< IDENTIFIER.

has a cost factor of 1, which is worse than the default cost factor of 0.
So, if VOID matches then the type_identifier is discarded.

You can test this with:
xmq --ixml=grammars/languages/c.ixml grammars/languages/c-tests/test.c

If you replace =<  with just =, then you can parse with coffeepot and
markup-blitz as well. Markup-blitz accidentally produces the same output as
xmq with =<
whereas coffepot illustrates the fact that int can be "in" "t" etc. This is
where the ! not operator at the end of IDENTIFIER would be nice.

Please test! There is undoubtedly more work that needs to be done for this
grammar, but hey it is parsing. :-)

//Fredrik

Received on Saturday, 22 March 2025 17:07:57 UTC