ChildsplayOSU / bogl

Haskell implementation of the BoGL language
https://bogl.engr.oregonstate.edu
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

closes #103, report parse error for mismatched equation names #147

Closed montymxb closed 4 years ago

montymxb commented 4 years ago

Closes #103. This PR fixes up a previously observed bug where signatures and equations that did not match names were not caught at the parser level. This resulted in bad error reporting from the type checker instead, and was misleading as it would only trip when the type checker was invoked to verify that value or function equation. An example of an offending statement would be:

game Test

b2 : Int -> Int
b(x) = x+1

-- or
b : Int
a = 2

These are now both reported correctly as parse errors (Language errors in the online tool), and are caught even if one name is a sub-string of the other name (which was not the case before).

In my local environment, this patch now correctly fails this program to parse no matter what is typed in, and reports:

Language Error: "Code" (line 4, column 2):
unexpected "("
expecting letter or digit or 'b2' but got b'

The expecting letter or digit part could be slightly improved, but this is vastly improved over the prior message.

alexgrejuc commented 4 years ago

This is a good fix. I did make two changes, however:

  1. I changed the parsing so it reports the identifier name only
    • expecting letter or digit or 'b2' but got b' => unexpected "(" expecting "b2"
  2. I changed the parser names to camelCase since that's our convention and the Haskell convention

I think it can be merged; I'll let you do it after you review my changes.