I'm currently pretty busy, so this has to stay short, but hopefully this
will get you on the right track.
Alastair Rankine writes:
> I'm using the bovine parser generator, and my language grammar is
> given below. However, it's not really working on a trivial example
> file, despite my attempt to follow some of the example language
> grammars and doco.
> Here is the simple test file:
> cmake_minimum_required(VERSION 2.6)
> If I call semantic-lex on this, I get the following results:
> ((symbol 1 . 23) (semantic-list 23 . 36))
> I would have expected a punctuation or an open-parens lexical token in
> there somewhere, or am I mistaken?
That depends on the depth parameter of semantic-lex. By default, it will
not expand expressions in brackets, so it simply returns a
semantic-list, which you can then expand to parse its contents. The
documentation for this is in
Semantic Language Writer's guide > Writing Lexers > Lexer Output
The docs are a bit sparse on that issue, but if you look at other
grammars like c.by you might get a better idea of how it works. For
example, parsing casting expressions:
( EXPAND $1 type-cast-list )
: open-paren typeformbase close-paren
So the lexer will first see a c-style cast like "(int)" as
'(semantic-list)'. The 'type-cast' rule will then EXPAND that
semantic-list using the rule 'type-cast-list', which will call the lexer
with a depth+1, so that it returns the actual punctuation characters.
I hope this helps,