Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update the plan for the parser refactor

  • Loading branch information...
commit 1fa36915a09fe4b576d2f782d7a6212ae9be4a99 1 parent 2704312
@Whiteknight authored
Showing with 30 additions and 2 deletions.
  1. +30 −2 src/parser/grammar-plan.txt
View
32 src/parser/grammar-plan.txt
@@ -1,5 +1,11 @@
rule statement {
| <matrix_literal> = <accessor>
+ # [a, b, c] = foo(x)
+ # [a, b, c] = foo
+ # BUT NOT
+ # [1, 2, 3] = foo(x) <-- Probably a runtime error
+ # [a, b, 3] = foo(x) <-- Probably a runtime error
+ # --------------------------------------------------
# _matrix_literal = !build_matrix_literal(elements)
# _nargsout = _matrix_literal.'get_nargs'()
# _accessor = !build_accessor(args)
@@ -7,6 +13,10 @@ rule statement {
# _matrix_literal.'assign_result'(_result)
| <accessor> = <accessor>
+ # foo(x) = bar(y)
+ # foo = bar(y)
+ # foo(x) = bar
+ # --------------------------------------------------
# _accessor1 = !build_accessor(args1)
# _nargsout = _accessor1.'get_nargs'() # always == 1
# _accessor2 = !build_accessor(args2)
@@ -14,13 +24,21 @@ rule statement {
# _accessor.'assign_result'(_result)
| <accessor> = <matrix_literal>
- # _accessor = !build_access(args)
+ # foo(x) = [a, b, c]
+ # foo(x) = [1, 2, 3]
+ # foo = [a, b, c]
+ # foo = [1, 2, 3]
+ # --------------------------------------------------
+ # _accessor = !build_accessor(args)
# _nargsout = accessor.'get_nargs'() # always == 1
# _matrix_literal = !build_matrix_literal(elements)
# _result = _matrix_literal.'get_result'(_nargsout)
# _accessor.'assign_result'(_result)
| <matrix_literal>
+ # [a, b, c] <-- SAME AS ans = [a, b, c]
+ # [1, 2, 3] <-- SAME AS ans = [1, 2, 3]
+ # --------------------------------------------------
# _ans = !get_ans()
# _nargsout = _ans.'get_nargs'() # always 1
# _matrix_literal = !build_matrix_literal(elements)
@@ -28,18 +46,28 @@ rule statement {
# _ans.'assign_result'(_result)
| <accessor>
+ # foo <-- SAME AS ans = foo
+ # foo x <-- SAME AS ans = foo x
+ # foo(x) <-- SAME AS ans = foo(x)
+ # --------------------------------------------------
# _ans = !get_ans()
# _nargsout = _ans.'get_nargs'()
# _matrix_literal = !build_matrix_literal(elements)
# _result = _matrix_literal.'get_result'(_nargsout)
# _ans.'assign_result'(_result)
}
+# Steps in performing an assignment
+# 1) Build the left-hand accessor object
+# 2) Get nargout from left-hand accesor
+# 3) Build the right-hand accessor object
+# 4) Call right-hand accessor with nargout. Produce result object
+# 5) Unpack result object into left-hand accessor object
rule accessor {
| <name> '(' <args> ')'
| <name>
}
-_accessor = !build_accessor(args)
+#_accessor = !build_accessor(args)
rule matrix_literal {
'[' <elements> ']'
Please sign in to comment.
Something went wrong with that request. Please try again.