-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add content to statements. Change dep type from :Name -> :named.
To add content to statemnents, we annotate the AST with the source using instaparse's built-in functionality.
- Loading branch information
1 parent
c9c76dd
commit da18f0a
Showing
6 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns bean.value | ||
(:require [bean.parser :as parser])) | ||
|
||
(defn from-statement | ||
[content ast] | ||
{:content content | ||
:ast ast}) | ||
|
||
(defn from-cell [content] | ||
{:content content | ||
:ast (parser/parse content)}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns bean.value-test | ||
(:require [clojure.test :refer [deftest is testing]] | ||
[bean.value :as value])) | ||
|
||
(deftest new-test | ||
(testing "Returns a new value for a statement with given content & ast" | ||
(is (= {:ast [:Expression | ||
[:Expression [:CellRef "A" "8"]] | ||
[:Operation "+"] | ||
[:Expression [:CellRef "B" "9"]]] | ||
:content "A8+B9"} | ||
(value/from-statement "A8+B9" [:Expression | ||
[:Expression [:CellRef "A" "8"]] | ||
[:Operation "+"] | ||
[:Expression [:CellRef "B" "9"]]])))) | ||
(testing "Returns a value that parses given cell contents & uses that ast" | ||
(is (= {:ast [:CellContents [:Expression | ||
[:Expression [:CellRef "A" "8"]] | ||
[:Operation "+"] | ||
[:Expression [:CellRef "B" "9"]]]] | ||
:content "=A8+B9"} | ||
(value/from-cell "=A8+B9"))))) |