Browse Source

move as many operator definitions to prelude.jl as possible, remove some ones I don't care about right now

pull/20/head
nisstyre56 11 years ago
parent
commit
64419eeb07
  1. 12
      example.jl
  2. 42
      prelude.jl
  3. 16
      representation.js

12
example.jl

@ -1,7 +1,3 @@
defop 2 Left (a ++ b)
(a - b)
def foo# 3 def foo# 3
deftype Foo (A -> B) deftype Foo (A -> B)
@ -40,9 +36,9 @@ def empty []
def getFile def getFile
(readFile "./parse.js") (readFile "./parse.js")
def fileLines ;;def fileLines
(getFile >>= ;; (getFile >>=
((mapM_ putStrLn) . lines)) ;; ((mapM_ putStrLn) . lines))
def (testUnary n) def (testUnary n)
((-n) + n) ((-n) + n)
@ -94,3 +90,5 @@ def main
(unary + (unary +
fileLines + fileLines +
(print splitted)) (print splitted))
def blah (3 / 4)

42
prelude.jl

@ -69,3 +69,45 @@ defop 4 Left (a * b)
defop 4 Left (a / b) defop 4 Left (a / b)
(div a b) (div a b)
defop 5 Right (a ^ b)
(pow a b)
defop 3 Left (a ++ b)
(listConcat a b)
defop 2 Left (a == b)
(eq a b)
defop 2 Left (a > b)
(gt a b)
defop 2 Left (a >= b)
(gte a b)
defop 2 Left (a < b)
(lt a b)
defop 2 Left (a <= b)
(lte a b)
defop 2 Left (a && b)
(and a b)
defop 2 Left (a || b)
(or a b)
defop 1 Left (x : xs)
(cons x xs)
defop 1 Left (f $ x)
(fapply f x)
defop 1 Left (f . g)
(compose f g)
defop 1 Left (a | b)
(bitwiseOr a b)
defop 1 Left (a & b)
(bitwiseAnd a b)

16
representation.js

@ -374,8 +374,8 @@ OPInfo = {
/*"+" : [3, "Left"], /*"+" : [3, "Left"],
"-" : [3, "Left"], "-" : [3, "Left"],
"*" : [4, "Left"], "*" : [4, "Left"],
"/" : [4, "Left"],*/ "/" : [4, "Left"],
"^" : [5, "Right"], "^" : [5, "Right"]
"++" : [3, "Left"], "++" : [3, "Left"],
"==" : [2, "Left"], "==" : [2, "Left"],
">" : [2, "Left"], ">" : [2, "Left"],
@ -383,17 +383,13 @@ OPInfo = {
"<" : [2, "Left"], "<" : [2, "Left"],
"<=" : [2, "Left"], "<=" : [2, "Left"],
"&&" : [2, "Left"], "&&" : [2, "Left"],
"||" : [2, "Left"], "||" : [2, "Left"],*/
"::" : [2, "Left"], "::" : [2, "Left"],
":" : [1, "Left"], /*":" : [1, "Left"],
"$" : [1, "Left"], "$" : [1, "Left"],
">>" : [1, "Left"], "." : [1, "Left"],*/
">>=" : [1, "Left"],
"<$>" : [1, "Left"],
"." : [1, "Left"],
"," : [1, "Left"], "," : [1, "Left"],
"->" : [1, "Right"], "->" : [1, "Right"]};
"|" : [1, "Left"]};
module.exports = module.exports =
{ {

Loading…
Cancel
Save