ascii_tree | Parses a usable tree from ASCII art | Parser library
kandi X-RAY | ascii_tree Summary
kandi X-RAY | ascii_tree Summary
Parses a usable tree from ASCII art.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ascii_tree
ascii_tree Key Features
ascii_tree Examples and Code Snippets
Community Discussions
Trending Discussions on ascii_tree
QUESTION
I have a Flexlm/Flexnet licenses service and I want parse the outputs of this service. All output are structured block of multi-lines. My first step is to parse the output of lmutil lmstat -c -a
to have the usage of licences and increments.
I try to use Ruby and Parslet. All lines are individually well parsed. I have a rule to parse a repetition of a specific type of line, but I can't parse a structured block of lines.
I'm looking for the law (best word in this context than 'rule') that define where to put the 'newline' statement in a multi-line structured block.
I working with Debian Jessie (stable/x86_64) and Ruby 2.1.5p273 and Parslet 1.6.1-1.
I've contacted the author, he is sorry but he haven't enough time to help me. The webpages seen are :
- URL: www.viget.com/articles/write-you-a-parser-for-fun-and-win
- URL: jmettraux.wordpress.com/2011/05/11/parslet-and-json/
- Recursive Descent Parsers (Calle) - Video
- Wicked Good Ruby 2013 - Writing DSL's with Parslet by Jason Garber - Video
- Proper Ruby style for multi-line method chaining containing blocks - StackOverFlow
- Ruby parslet: parsing multiple lines - StackOverFlow
- How do I handle C-style comments in Ruby using Parslet? - StackOverFlow
I passed many hours to try to understand how to construct the rules of a multi-line structured block. Below you have my source code with all test strings and the output.
My approach is to build:
- the elementary rule to parse a fragment of line
- the rule to parse a complete line without the 'newline' statement;
- a rule to parse the repetition of an information of the same type, like the line for the used tokens;
- the rule to parse a group of data : header + repetition of lines;
- the rule to parse a repetition of groups.
I'm not sure of the point 3, and I'm completely lost with '4' and '5'.
Thanks in advance for any help. [ 07/14/2017 : some parts of code was removed ]
...ANSWER
Answered 2017-Oct-24 at 09:24It seems you are having trouble with "newline"s.
A good guideline is... * consume them at the end of a rule (as a terminating character) * if they are not symantically part of the token, then let the parent rule consume them.
Say I had a document:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ascii_tree
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page