lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Further to my message about the re module self-test failure, I note a discrepancy between the grammar given on the page (link below) and the actual grammar implemented in re.lua.

Grammar from web page:

  pattern         <- exp !.
  exp             <- S (alternative / grammar)
  alternative     <- seq ('/' S seq)*

Grammar from re.lua:

  local exp = m.P{ "Exp",
    Exp = S * ( m.V"Grammar"
              + m.Cf(m.V"Seq" * ("/" * S * m.V"Seq")^0, mt.__add) );

Note that the rule for "Exp" has "Grammar" first followed by: Seq * ( "/" + S " Seq)^0

This agrees with the fact that the grammar self-tests OK if you reverse the line:

 exp <- S (alternative / grammar)

to read:

 exp <- S (grammar / alternative)