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
  • Merge requests
  • !404

Allow # in readtable

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/r3m0t/readtable_hash into master Oct 16, 2014
  • Overview 4
  • Commits 2
  • Pipelines 0
  • Changes 3

Created by: r3m0t

The command line script reads stxcase.js with a user-provided readtable which makes it impossible to define a # behaviour and use it from the sjs command.

Example:

var sweetjs = require('sweet.js');
var recursed = false;
module.exports = sweetjs.currentReadtable().extend({
    '#': function (ch, reader, toks, source, index) {
        if (recursed) return null;
        var start = reader.index;
        var tok;
        recursed = true;
        reader.readToken(); // read the #
        tok = reader.suppressReadError(reader.readDelimiter);
        recursed = false;
        if (tok !== null && tok.value == '{}') {
            // looks like #{ } form
            return null;
        }
        return [reader.makePunctuator('+', { start: start })];
    }
});
macro m {
  case {_ $x } => {
    var y = makeValue(42, #{$x});
    return [y]
  }
}
m foo # 5

Invocation: bin/sjs -l ./readtable.js -s < ./a.js

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/r3m0t/readtable_hash