Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #354, Added support for negating expressions #371

Merged
merged 1 commit into from
Apr 12, 2016
Merged

Fix #354, Added support for negating expressions #371

merged 1 commit into from
Apr 12, 2016

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Apr 11, 2016

Before we could write -1 (due to the parser library handling negation
of integers), but not -1.0 or -x or -1 + (-(1+2) + 3). This commit
adds support for arbitrary negation.

Before we could write `-1` (due to the parser library handling negation
of integers), but not `-1.0` or `-x` or `-1 + (-(1+2) + 3)`. This commit
adds support for arbitrary negation.
@PhucVH888
Copy link
Contributor

I have checked with some more testcases such as tuple, pattern matching, and option type.
They are all passed.

class Main 
  def main() : void {
    let x = -(-42.0);
    let y = -(-(-x));
    let z = -y + (-(1+2) + 3);
    let t1 = match y with {
      -42.0   => print "-42.0"
      other => print "Nothing"
    };
    let t2 = match (y,y) with {
      (-42.0,-42.0)   => print "(-42.0,-42.0)"
      other => print "Nothing"
    };
    let mb1 = Just (-42.0);
    let t2 = match mb1 with {
      Just 42.0   => print "Just 42.0"
      Just something => print "Just something"
      --Just (-42.0)   => print "Just (-42.0)"
      Nothing => print "Nothing"
    };
    let f = \(i:real) -> {i = -9.0; print i};
    let rf = f(-9.0);
    print -z*2.0;
   }

@albertnetymk
Copy link
Contributor

      print -3 - -1; -- -2
      print - -1; -- Unbound variable print
      let x = 3 in {print - - -x;}; -- unexpected "i"

The latter two cases don't work, but I think it's fine. Can be merged.

@PhucVH888 PhucVH888 merged commit beec0a4 into parapluu:development Apr 12, 2016
@EliasC EliasC deleted the features/negative branch April 12, 2016 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants