How specify that whitespace should not count?

109 views
Skip to first unread message

Anders Eriksson

unread,
Dec 9, 2014, 6:50:18 PM12/9/14
to gold-pars...@googlegroups.com
I am doing my first try with GOLD and I'm trying to parse abc music notation.
The grammar has been accepted but when I try to test it with an data file I get an error when the parser finds a space.

In the data file I have this line
X: 1

The grammar for this looks like this (This is just a snippet of the grammar file)
Whitespace    = {WS}+
NewLine       = {CR}{LF} | {CR} | {LF}
StringLiteral = '"' {String Chars}* '"'

Digits        = {digit}+
<comment> ::= '%' StringLiteral NewLine
<end-of-line> ::= <comment> | NewLine 
<field-number> ::= 'X:' Digits <end-of-line>

The test log
FAIL : danny_boy.abc
   Result      : Syntax Error
   Column      : 2
   Line        : 0
   Parse Value : {space}
   Description : Expecting one of the following tokens: Digits

How do I make the parser to ignore whitespace between tokens?

// Anders

Dave Dolan

unread,
Dec 18, 2014, 10:55:01 PM12/18/14
to gold-pars...@googlegroups.com
Since it's just a snippet, I can only speak to the bits I can see. Don't define a white space terminal. Then white space won't be recognized as a token, and spaces will be ignored. It's the default behavior.

--dave


--
You received this message because you are subscribed to the Google Groups "GOLD Parsing System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gold-parsing-sy...@googlegroups.com.
To post to this group, send email to gold-pars...@googlegroups.com.
Visit this group at http://groups.google.com/group/gold-parsing-system.
For more options, visit https://groups.google.com/d/optout.


--
---------------------------------------------------------------
Dave Dolan
http://davedolan.com/blog
Reply all
Reply to author
Forward
0 new messages