I. Oppenheim wrote:
> On Mon, 7 Jul 2003, Bert Van Vreckem wrote:
>
>
>> I. Oppenheim wrote:
>>
>>> If the ABC community as a whole could provide a standard
>>> complying parser, not every developer that wishes to use ABC
>>> would have to reinvent the wheel again and again. The current
>>> situation is in nobody's interest.
>>
>> We're already there: using Henrik's BNF spec, a developer can
>> generate a parser with tools like lex and yacc.
>
>
> Unfortunately, it is not trivial at all to convert a BNF definition
> into a working parser.
>
> 1/ the parser should be able to ignore future ABC extentions in a
> graceful way, whatever they may be; 2/ the parser should be able to
> understand (rather than ignore) non-standard legacy code;

It should also have an option that would disallow anything non-standard,
such as gcc's -ansi switch.

> 1/ How can Lex know whether a "C" it scans is a note name, or the
> first letter of a staff label? Maybe it's even the beginning of the
> composer field!
>
> 2/ How can Yacc know whether "||" is one double bar symbol, or two
> single bar symbols next to each other?
>
> 3/ How can Lex/Yacc know whether "E:|" is a (mid-tune) field that
> starts with a pipe, or a note with a repeat sign next to it?
>
> I do not know whether Lex and Yacc are the proper tools to deal with
> ABC.

These are not problems with lex and yacc specifically; any program
parsing abc will have to face them.  They are ambiguities, or potential
ambiguities, in the language itself.

In the first case above, there should be no problem: the composer field
is only in the header and starts a line, and the staff labels are in the
V field also in the header.

In the second case (which is really a lexing issue), either disallow two
single bars next to each other (does such a construct even make sense?),
or require whitespace between them.

In the third case, if "E:|" makes sense as a body field, then whitespace
 would be required to distinguish it from a note followed by a repeat,
or perhaps better, do not allow a-g and A-G as body fields.




To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html

Reply via email to