cjheath / treetop

A Ruby-based parsing DSL based on parsing expression grammars.

Home Page:https://cjheath.github.io/treetop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When two similar expression get selected, not working.

senyan opened this issue · comments

grammar AgencyCompany

  rule expression
    find_agency / find_company
  end

  rule find_agency
    agency space that space concrete_company space work_with
  end

  rule find_company
    company space that concrete_agency space work_with
  end

  rule work_with
    ("has" / "have") space ("partnered" / "partner" / "worked" / "work") space "with"
  end

  rule that
    "that" / "which"
  end

  rule company
    "companies" / "vendors" / "company" / "vendor"
  end

  rule agency
    "agency" / "agencies"
  end

  rule my_company
    "my company"
  end

  rule concrete_company
    entity_name
  end

  rule concrete_agency
    entity_name
  end

  rule entity_name
    word space entity_name
  end

  rule word
    [a-zA-Z]+
  end

  rule space
    [\s]+
  end

end
`` `
Not sure why this simple grammar is failing, if I parse a string start with "company", the ``failure_reason`` shows it is expecting ``agency``, but for a string start with "company" it is expecting "agency". 

This is more like a problem of the code rather than Treetop. I will post it in the mailing list for stack overflow.

Please don't post support questions as github issues. I don't track stack overflow frequently either. The documented support forum is the google group - please always ask there first.

Sorry about this.