You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The supported parsers are exported from PureScript.CST. The parsers support
some error recovery, which is reflected in the RecoveredParserResult type.
The CST types in PureScript.CST.Types are indexed by an error type, which
is fixed to RecoveredError in the case of failures. Parses that succeed
without failures have the error type fixed to Void.
importPureScript.CST (RecoveredParserResult(..), parseModule)
example = case parseModule myModuleSource ofParseSucceeded cst ->-- `cst` is type `Module Void` to indicate no errorsParseSucceededWithErrors cst errors ->-- `cst is type `Module RecoveredError` and contains error nodes at points of failure.ParseFailed error ->-- An unrecoverable error was encountered.
Traversals
PureScript.CST.Traversal contains traversals for analyzing and rewriting
the CST. These folds take a language visitor record with functions for
handling the primary types in the CST. Default records are provided that do
nothing for the cases you don't care about.
For example, if you wanted to quickly gather all the identifiers used in the
expressions of a module along with locations, you might use foldMapModule
and only provide a case for onExpr.
The provided integration test attempts to parse a provided package set, and
will report any errors it encounters as well as listing the fastest and
slowest parse times along with the mean parse time for the set.
npm run parse-package-set
You can also benchmark or parse a single file:
npm run bench-file MyModule.purs
npm run parse-file -- MyModule.purs --tokens