Skip to content

Allow multi-char keys #3

@gabejohnson

Description

@gabejohnson

Motivation:

The sweet.js table-driven reader uses simple tries to do determine value or the value property on KeywordTokens and PunctuatorTokens. It's fast and it works, but it would be more user-friendly to allow:

const tEntries = [{
  key: 'this',
  action(stream) {
    return KeywordToken({ value: stream.readString(4); });
  }
}, {
  key: 'throw',
  action(stream) {
    return KeywordToken({ value: stream.readString(5); });
  }
}];

As stated in #2 this would be done procedurally but for user defined reader macros this could be a huge usability win.

This could potentially also do away with the idea of dispatch macros.

const hashEntries = [{
  key: '#',
  action: readPrivateVars
}, {
  key: '#`',
  action: readSyntaxTemplate
}]

@disnet any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions