Skip to content

Commit

Permalink
remove commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
hoosierEE committed Apr 15, 2024
1 parent a5d744b commit 17e7428
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions src/misc/Parser.py
Original file line number Diff line number Diff line change
@@ -1,77 +1,3 @@
'''
(ab) ⇒ (a b) apply function a to argument b
(+b) ⇒ (+ b) apply function + to argument b
(a+) ⇒ (+ a ∅) + projection waiting for argument ∅
(f/) ⇒ ((/ f) ∅) (/ f) projection awaiting ∅
((a;b)1) ⇒ ((lst a b) 1) apply/index 1 to list
And adverbs:
f/y ⇒ ((/ f) y) 1-argument form
x f/y ⇒ ((/ f) x y) 2-argument form
x f/'y ⇒ ((' (/ f)) x y) multiple adverbs bind together
When parsing "x f/y" left-to-right, "x f" could be (apply x f).
However, once you see "/" it must be the 2-argument adverb ((/ f) x …).
Finally, there are "compositions" and "projections":
(+-) ⇒ (+ (- … …)) (unary + applied to binary - which is waiting on both args)
(1+) ⇒ (+ 2 …) (binary + waiting on an arg (first arg bound to 1))
Compositions can't be just names like (p q) because that's already parsed as (apply p q).
Example: "x y + - z h + g" ⇒ (x (+ y (- (z (+ h g)))))
(∴) t ⇒ [s] [d]
(u) x ⇒ [] [x]
(b) y ⇒ [x:] [y]
(b) + ⇒ [x: +] [y]
(u) - ⇒ [x: + -:] [y]
(u) z ⇒ [x: + -:] [y z]
(b) h ⇒ [x: + -: z:] [y h]
(b) + ⇒ [x: + -: z: +] [y h]
(u) g ⇒ [x: + -: z: +] [y h g]
r ⇐ [x: + -: z:] [y (+ h g)]
r ⇐ [x: + -:] [y (z (+ h g))]
r ⇐ [x: +] [y (- (z (+ h g)))]
r ⇐ [x:] [(+ y (- (z (+ h g))))]
r ⇐ [] [(x (+ y (- (z (+ h g)))))]
Example: "xyz" ⇒ (x (y z))
(u) x ⇒ [] [x]
(b) y ⇒ [x:] [y]
(b) z ⇒ [x: y:] [z]
r ⇐ [x:] [(y z)]
r ⇐ [] [(x (y z))]
Example: "a(w+x)-b" ⇒ (a (- (+ w x) b))
(u) a ⇒ [] [a]
(b) ( ⇒ [a: ()] []
(u) w ⇒ [a: ()] [w]
(b) + ⇒ [a: () +] [w]
(u) x ⇒ [a: () +] [w x]
rp ) ⇐ [a:] [(+ w x)]
(b) - ⇒ [a: -] [(+ w x)]
(u) b ⇒ [a: -] [(+ w x) b]
r ⇐ [a:] [(- (+ w x) b)]
r ⇐ [] [(a (- (+ w x) b))]
Example: "x(f)/y" ⇒ ((/ f) x y)
(u) x ⇒ [] [x]
(b) ( ⇒ [x: ()] []
(u) f ⇒ [x: ()] [f]
rp ) ⇒ [x:] [f]
(b) / ⇒ [(/ f)] [x] SWAP s d; s.push(Ast(/,s.pop()))
(u) y ⇒ [(/ f)] [x y]
r ⇐ [] [((/ f) x y)]
Example: "f/y" ⇒ ((/ f) y)
(u) f ⇒ [] [f]
(b) / ⇒ [(/ f)] [] SWAP s d; s.push(Ast(/,s.pop()))
Example: "xf/y" ⇒ ((/ f) x y)
(u) x ⇒ [] [x]
(b) f ⇒ [x:] [f]
(b) / ⇒ [(/ f)] [x]
(u) y ⇒ [(/ f)] [x y]
r ⇐ [] [((/ f) x y)]
'''

from Ast import Ast
from Parser_test import unit
import collections as C
Expand Down

0 comments on commit 17e7428

Please sign in to comment.