[erlang-questions] Are newlines significant in Erlang grammar?
Tue Dec 20 19:33:18 CET 2011
Actually that's an interesting point. Is there really no other place in the
Erlang grammar where whitespace is required? My gut instinct tells me there
must be a few, because every language has a few right? I mean, if nothing
else to separate two identifiers? But thinking a little more, I realize
Erlang doesn't have "identifiers" in the sense most other languages do and
even then, there's always some sort of punctuation. Is this period business
the only exception?
On Tue, Dec 20, 2011 at 12:33 PM, Ryan Molden <ryanmolden@REDACTED> wrote:
> Sure, but I was trying to avoid sprinking [\t\r\n ]* tokens everywhere
> throughout my grammar. My lexer currently ignores whitespace outside of
> comments and string literals and my parser works off the tokens my lexer
> If what you are saying is correct it sounds like I can't do that, which
> means my parser's grammar explodes with tons of 'oh and there can be
> whitespace here, or needs to be whitespace here' kind of tokens :(
> On Tue, Dec 20, 2011 at 9:04 AM, Fred Hebert <mononcqc@REDACTED> wrote:
>> It can be any whitespace, not necessarily new lines.
>> On Tue, Dec 20, 2011 at 11:45 AM, Ryan Molden <ryanmolden@REDACTED>wrote:
>>> I have been playing around with making a lexer/parser for Erlang using
>>> boost::spirit and using the YRL from lib\stdlib-1.17.5\src\erl_parse.yrl as
>>> my grammar. It isn't specifically called out there (or anywhere else I can
>>> find), but I assume that newlines are significant and implied as input
>>> For instance the following is accepted by the compiler (ignore the
>>> meaninglessness/infinite recursion of blah)
>>> -module .foo.
>>> However, if I put it all on one line, like so:
>>> -module .foo.blah(F)->blah(F-1).
>>> it is not accepted. It seems to be because .foo.blah is being parsed as
>>> a single instance of expr_900, which is defined as
>>> expr_900 -> '.' atom
>>> expr_900 -> expr_900 '.' atom
>>> expr_900 -> expr_max
>>> I am fine treating newlines as input terminators but it isn't clear
>>> which non-terminals require the presence of a newline and which don't.
>>> erlang-questions mailing list
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions