Skip to content

How to proper prioritize a symbol that can be used for multiple goals? (hash symbol for arm assebly) #3190

Answered by maxcnunes
maxcnunes asked this question in Q&A
Discussion options

You must be logged in to vote

I got it to work by removing comment from extras, and properly configuring it on the parts it should be supported instead of automatically depending on the extras feature for that.

module.exports = grammar({
  name: "asm",

  extras: ($) => [/\s|\t|\r/],

  rules: {
    program: ($) => repeat(choice($._definition, $.comment)),

    _definition: ($) =>
      prec.left(
        1,
        seq(
          choice(
            $.mov_instruction,
            // TODO: other kinds of definitions
          ),
          optional($.comment),
        ),
      ),

    mov_instruction: ($) =>
      prec.left(1, seq("mov", $.arg_src, ",", $.arg_dst, optional($.comment))),

    arg_src: ($) => /X[0-9]+/,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by maxcnunes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant