Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Issues
  • #289
Closed
Open
Issue created Mar 24, 2014 by Administrator@rootContributor

Error parsing JS that contains an identifier `macro`

Created by: BinaryMuse

I have been working on integrating Sweet.js into part of our build workflow and ran into an issue where the parser throws due to encountering an identifier macro that doesn't define a macro. (A macro is a first-class business entity in our system.) Is there a good way to work around this issue?

Here's a small reproducible test case:

macro id {
  rule {
    ($x)
  } => {
    $x
  }
}

function printMacro(macro) {
  if (!macro) console.log('not defined');
  else console.log(macro);
}
$ sjs file.js

/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:99
                    throw new SyntaxError(syn.printSyntaxError(source, err));
                          ^
SyntaxError: [enforest] Macro declaration must include body
    at expand$2 (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:99:27)
    at parse (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:113:29)
    at Object.compile (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:121:19)
    at Object.exports.run (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sjs.js:70:27)
    at Object.<anonymous> (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/bin/sjs:7:23)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Using Sweet.js version 0.5.0.

Thanks!

Assignee
Assign to
Time tracking