
|
An Unbounded Character Sequence Reader for Parsing?
An Unbounded Character Sequence Reader for Parsing?
All,
Networked Insights had a need to use the Scala parsing API using System.in as a sources as well as from file input streams. The solution built involved extending scala.util.parsing.input.Reader[Char] so that it would dynamically read and build a list of character segments and detect the end-of-sequence by checking that the input stream is closed instead of attempting to read the next character which, if the stream is not closed and no other characters are available, will block.
This solution works very well for us with the caveat that if your grammar relies heavily on look-ahead you will inevitably end up waiting for user input on the console. Also, because we can make no assumptions about when the user is done with previously read characters (that is, the parser will not re-wind to them) we keep all read characters currently, though the underlying data structures may be pruned by user intervention. Regardless, Networked Insights would like to share the Reader[Char] implementation we have if there is an interest. There is a little packaging work that will be done and I would like to build a file simple unit tests separate from the codebase this lives in currently so we hand off something easy to maintain.
Your thoughts??
Sam Baskinger
Software Engineer
Networked Insights, Inc. <http://www.networkedinsights.com/>

Office: 608.237.1867
Fax: 608.216.9848
Delighting our customers is our top priority. The Networked Insights team welcomes your comments and suggestions about how we can improve the quality of our products and services. Please email us at: Feedback@...
This e-mail message and any attachments are for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, duplication or distribution is prohibited. If you received this message in error, please notify me by phone or return email, do not forward to any other person and permanently delete the foregoing message, all attachments and all copies immediately.
|