aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-06-12 18:03:07 +0100
committerAkshay <[email protected]>2021-06-12 18:03:07 +0100
commit6be61101caeb6c46ac74cb9944106e18727b1e77 (patch)
tree86e6e9ecb041beccfecfae10ecadde27b3013238 /src
parent73177af78f61975a0eaef9a88758d59db4ccc473 (diff)
accessor for token text
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a1e085f..7385d66 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -61,10 +61,17 @@ impl SynNode {
61 (r.start().into(), r.end().into()).into() 61 (r.start().into(), r.end().into()).into()
62 } 62 }
63 63
64 pub fn text(&self) -> String { 64 pub fn kind(&self) -> String {
65 format!("{:?}", self.node.kind()) 65 format!("{:?}", self.node.kind())
66 } 66 }
67 67
68 pub fn text(&self) -> String {
69 match &self.node {
70 NodeOrToken::Node(_) => "".into(),
71 NodeOrToken::Token(t) => format!("{:?}", t.text()),
72 }
73 }
74
68 pub fn from_str(s: &str) -> Result<JsValue, JsValue> { 75 pub fn from_str(s: &str) -> Result<JsValue, JsValue> {
69 FromStr::from_str(s) 76 FromStr::from_str(s)
70 .map(|p: SynNode| JsValue::from(p)) 77 .map(|p: SynNode| JsValue::from(p))