BVB Source Codes

reactide Show index.js Source code

Return Download reactide: download index.js Source code - Download reactide Source code - Type:.js
  1. // Acorn: Loose parser
  2. //
  3. // This module provides an alternative parser (`parse_dammit`) that
  4. // exposes that same interface as `parse`, but will try to parse
  5. // anything as JavaScript, repairing syntax error the best it can.
  6. // There are circumstances in which it will raise an error and give
  7. // up, but they are very rare. The resulting AST will be a mostly
  8. // valid JavaScript AST (as per the [Mozilla parser API][api], except
  9. // that:
  10. //
  11. // - Return outside functions is allowed
  12. //
  13. // - Label consistency (no conflicts, break only to existing labels)
  14. //   is not enforced.
  15. //
  16. // - Bogus Identifier nodes with a name of `"鉁?` are inserted whenever
  17. //   the parser got too confused to return anything meaningful.
  18. //
  19. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  20. //
  21. // The expected use for this is to *first* try `acorn.parse`, and only
  22. // if that fails switch to `parse_dammit`. The loose parser might
  23. // parse badly indented code incorrectly, so **don't** use it as
  24. // your default parser.
  25. //
  26. // Quite a lot of acorn.js is duplicated here. The alternative was to
  27. // add a *lot* of extra cruft to that file, making it less readable
  28. // and slower. Copying and editing the code allowed me to make
  29. // invasive changes and simplifications without creating a complicated
  30. // tangle.
  31.  
  32. import acorn from "acorn"
  33. import {LooseParser, pluginsLoose} from "./state"
  34. import "./tokenize"
  35. import "./statement"
  36. import "./expression"
  37.  
  38. export {LooseParser, pluginsLoose} from "./state"
  39.  
  40. acorn.defaultOptions.tabSize = 4
  41.  
  42. export function parse_dammit(input, options) {
  43.   let p = new LooseParser(input, options)
  44.   p.next()
  45.   return p.parseTopLevel()
  46. }
  47.  
  48. acorn.parse_dammit = parse_dammit
  49. acorn.LooseParser = LooseParser
  50. acorn.pluginsLoose = pluginsLoose
  51.  
downloadindex.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top