@@ -34,7 +34,7 @@ import org.herb.Token;
3434String source = " <p>Hello <%= user.name %></p>" ;
3535LexResult result = Herb . lex(source);
3636
37- for (Token token : result. getTokens() ) {
37+ for (Token token : result. tokens ) {
3838 System . out. println(token. inspect());
3939}
4040// Output:
@@ -51,8 +51,8 @@ The `LexResult` class provides access to the lexed tokens:
5151
5252``` java
5353public class LexResult {
54- public List<Token > getTokens () ;
55- public String getSource () ;
54+ public List<Token > tokens ;
55+ public String source ;
5656 public int getTokenCount ();
5757 public boolean isEmpty ();
5858}
@@ -73,9 +73,7 @@ String source = "<p>Hello <%= user.name %></p>";
7373
7474ParseResult result = Herb . parse(source);
7575
76- if (result. getValue() != null ) {
77- System . out. println(result. getValue(). treeInspect());
78- }
76+ System . out. println(result. inspect();
7977// Output:
8078// @ DocumentNode (location: (1:0)-(1:29))
8179// └── children: (1 item)
@@ -133,12 +131,12 @@ The `ParseResult` class provides access to the parsed AST and any errors:
133131
134132```java
135133public class ParseResult {
136- public Node getValue () ;
137- public List<Node > getErrors () ;
138- public String getSource () ;
134+ public Node value ;
135+ public List<Node > errors ;
136+ public String source ;
139137 public boolean hasErrors ();
140138 public int getErrorCount ();
141- public boolean isSuccess ();
139+ public boolean isSuccessful ();
142140}
143141```
144142
@@ -278,7 +276,7 @@ public interface Node {
278276 String getNodeType ();
279277 Location getLocation ();
280278 List<Node > getErrors ();
281- String treeInspect ();
279+ String inspect ();
282280 <T > T accept (Visitor<T > visitor );
283281}
284282```
@@ -291,8 +289,8 @@ Parse errors are accessible through the `ParseResult`:
291289ParseResult result = Herb . parse(source);
292290
293291if (result. hasErrors()) {
294- for (Node error : result. getErrors ()) {
295- System . out. println(error. treeInspect ());
292+ for (Node error : result. recursiveErrors ()) {
293+ System . out. println(error. inspect ());
296294 }
297295}
298296```
0 commit comments