forked from j-mie6/parsley
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* enforced deprecation >:) * removed old docs * More enforced deprecation * Removed deprecation folder from sbt * removed a couple more things, moved withFilter to a 2.12 specific file * Inverted a predicate in Lexer * Removed deprecated folder from code climate yaml * Parser API Changes (j-mie6#81) * modified the parser API, breaking into IO and non-IO, as well as adding a Try wrapper to parseFromFile. runParser -> parse. * Added missing io file * Changing higher-arity `map` to a `zipped` (j-mie6#82) * Broke up implicits module into submodules, ignored lift and zipped * fixed typo in the codeclimate.yaml * Shuffled the ignores a little * Renamed to zipped and added the tupled form * Fixed laziness of zipped, and added lazyZip for Zipped2 and Zipped3, which can't be lazy due to a conflict with scala Tuple2 and Tuple3 .zipped * Moved io into JVM specific code, we can't use Source in scala-js * Parsley 3 debug (j-mie6#83) * Parser API Changes (j-mie6#81) * Added ascii flag to combinator, just needs to be hooked in * Added ability to disable colours through to the instruction level * Added the native IO binding * Updated tests for native * Parsley 3 expr (j-mie6#88) * Changed the API for precedence * Added postfix1 and prefix1 * Generalised the type of postfix1 and prefix1 * Added tests and fixed type of prefix1 * Disabled coverage for debug * Updated documentation * Fixed test coverage * Parsley 3 errors (j-mie6#90) * Fixed token error for unclosed bracket to be an explain * Split errors up and moved caret completion * Added build phase to CI * Moved error combinators into the errors package * Added the ErrorBuilder typeclass * Fixed the filename in io from error builder, because scala-js doesn't support it * Removed some lines in context... really?! * Parsley 3 Precedence Enhancements (j-mie6#91) * Changed the Levels datatype so that the atom is incorporated in, can now be written either way round * Fixed name for Atoms * Added documentation, removed unneeded implicit class, improved identity wrapping detection * Added SOps * removed redundant code * Added a prefix * Added NonAssoc, with basic error explain for it * Added reversed precedence operator * Removed build phase, it seems to cause coverage to skip? * Turned on push coverage runs again * Made notFollowedBy's error stretch as long as there were characters consumed * Added a default error builder which the user can extend * Added documentation to the error builder * Added revision 0 bound to the default error builder * Removed references to additional contextual information in the ErrorBuilder API, these can be added in a revision when the functionality appears * Added in a missing future implementation * Removed releases for parsley-3 * Updated all the documentation
- Loading branch information
Showing
55 changed files
with
2,034 additions
and
2,081 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package parsley | ||
|
||
import scala.io.{Source, Codec} | ||
import scala.util.Try | ||
import java.io.File | ||
|
||
import parsley.internal.machine.Context | ||
|
||
import scala.language.{higherKinds, implicitConversions} | ||
import parsley.errors.ErrorBuilder | ||
|
||
/** This module contains utilities to have parsers interact with IO, including the very useful `parseFromFile` method (exposed by `ParseFromIO`) | ||
* @since 3.0.0 | ||
*/ | ||
object io { | ||
/** | ||
* This class exposes a method of running parsers from a file. | ||
* | ||
* @param p The parser which serves as the method receiver | ||
* @param con A conversion (if required) to turn `p` into a parser | ||
* @version 3.0.0 | ||
*/ | ||
implicit final class ParseFromIO[P, +A](p: P)(implicit con: P => Parsley[A]) { | ||
/** This method executes a parser, but collects the input to the parser from the given file. | ||
* The file name is used to annotate any error messages. The result of this method handles | ||
* exceptions and ensures the file has been properly closed. | ||
* @param file The file to load and run against | ||
* @param codec The encoding of the file | ||
* @return a `Try` containing a result of either a success with a value of type `A` or a failure with error message on success, | ||
* and a failure if an IOException occured | ||
* @since 3.0.0 | ||
*/ | ||
def parseFromFile[Err: ErrorBuilder](file: File)(implicit codec: Codec): Try[Result[Err, A]] = { | ||
for { | ||
src <- Try(Source.fromFile(file)) | ||
input <- Try(src.mkString).recoverWith { | ||
case err: Throwable => | ||
src.close() | ||
scala.util.Failure(err) | ||
} | ||
} yield { | ||
src.close() | ||
new Context(p.internal.threadSafeInstrs, input, Some(file.getName)).runParser() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package parsley | ||
|
||
import scala.io.{Source, Codec} | ||
import scala.util.Try | ||
import java.io.File | ||
|
||
import parsley.internal.machine.Context | ||
|
||
import scala.language.{higherKinds, implicitConversions} | ||
import parsley.errors.ErrorBuilder | ||
|
||
/** This module contains utilities to have parsers interact with IO, including the very useful `parseFromFile` method (exposed by `ParseFromIO`) | ||
* @since 3.0.0 | ||
*/ | ||
object io { | ||
/** | ||
* This class exposes a method of running parsers from a file. | ||
* | ||
* @param p The parser which serves as the method receiver | ||
* @param con A conversion (if required) to turn `p` into a parser | ||
* @version 3.0.0 | ||
*/ | ||
implicit final class ParseFromIO[P, +A](p: P)(implicit con: P => Parsley[A]) { | ||
/** This method executes a parser, but collects the input to the parser from the given file. | ||
* The file name is used to annotate any error messages. The result of this method handles | ||
* exceptions and ensures the file has been properly closed. | ||
* @param file The file to load and run against | ||
* @param codec The encoding of the file | ||
* @return a `Try` containing a result of either a success with a value of type `A` or a failure with error message on success, | ||
* and a failure if an IOException occured | ||
* @since 3.0.0 | ||
*/ | ||
def parseFromFile[Err: ErrorBuilder](file: File)(implicit codec: Codec): Try[Result[Err, A]] = { | ||
for { | ||
src <- Try(Source.fromFile(file)) | ||
input <- Try(src.mkString).recoverWith { | ||
case err: Throwable => | ||
src.close() | ||
scala.util.Failure(err) | ||
} | ||
} yield { | ||
src.close() | ||
new Context(p.internal.threadSafeInstrs, input, Some(file.getName)).runParser() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.