Comments (7)
parboiled sets the value field of a parse tree node to the top element of the value stack at the time of the node construction. Does your parser contain action code that pushes custom objects onto the value stack? Only then will you see non-null values in your parse tree nodes...
from parboiled.
Yes, you are right. When I am pushing values in the stack they are showing up. Will it not be good if we can get values of the child nodes??
from parboiled.
I'm not quite sure I get what you are asking for..
You can traverse the parse tree in any way you seem fit and, of course, also get to all members of potentially existing child nodes.
from parboiled.
Sorry Sirthias, I was little confused. I got it working now. You may see such (may be silly) questions form me as this is the first time I am working with parsers. Thanks a lot for this wonderful library. One seggestion : If possible include a tutorial on "How to use ParseTree".
from parboiled.
No problem, just go ahead and ask questions if you think that I or other users might be able to help. But probably the parboiled user mailing list is a better place for such things...
from parboiled.
Hi Mathias,
The Node.getValue() is still not working. I have the following parse tree:
[top_vars] 'def i\n <f c="dfdf">dfdfdf</f>\nend'
[key] 'i\n '
[value] '<f c="dfdf">dfdfdf</f>\n'
[top_vars] '\n\ndef j\n kfgfdgjdfg\nend'
[key] 'j\n '
[value] 'kfgfdgjdfg\n'
[top_vars] '\n\ndef k\n format = "mm-dd-yyyy"\nend'
[key] 'k\n '
[value] 'format = "mm-dd-yyyy"\n'
I am finding a node by using following Java code:
Node key = findNodeByLabel(n,"key");
Node value = findNodeByLabel(n,"value");
When I try to print the value of the node using
key.getValue().toString() it gives me null pointer exception. But If I try to print using the following code it works absolutely fine.
System.out.println("Key: "+ result.inputBuffer.extract(key.getStartIndex(),key.getEndIndex()).toString());
I am not sure what the problem is.
Thanks & Regards,
Abhishek
from parboiled.
I'm not sure I get what you are trying to do.
The "value" of a node is a custom object that you create! If you do not create anything the value will always be null. Could it be that you confuse the "value" of the node with its matched input text?
And: Please let's move these discussions to the user mailing list.
from parboiled.
Related Issues (20)
- How to get source mapping for successfully parsed nodes HOT 2
- [JDK9] Illegal reflective access by org.parboiled.transform.AsmUtils to method java.lang.ClassLoader.findLoadedClass(java.lang.String) HOT 6
- Does parboiled support adding rules for detection errors?
- 2.13 support? HOT 2
- Special Emoji Support
- enable travis-ci HOT 1
- SimpleErrorRecoveryTest.testRecoveryTimeout unstable
- JDK11 reporting illegal reflective access HOT 25
- Can parboiled actually produce The Rule Tree ("tree") automatically? HOT 1
- Link to the wiki broken in the README
- Matched values for erroneous input HOT 2
- publish for Scala 2.13 HOT 1
- How to represent a) 2 digits b) 1 to 10 times in Parboiled?
- Is the project still active ? HOT 20
- Parboiled stopped working in Java 16 due to enforcement of encapsulation HOT 35
- Broken links in Wiki docs (http://www.decodified.com)
- "illegal writes to a local variable or parameter" in kotlin
- problem with string concatenation with parboiled java 1.4.1 HOT 2
- any clues on why this error
- Doc instructions for using JDK 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parboiled.