~rockorager/tree-sitter-scfg

6deae0cbb458c849a4d1e2985093e9c9c32d7fd0 — Tim Culverhouse 10 months ago 02712d3 main
export dquote_word and squote_word, update tests

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2 files changed, 26 insertions(+), 15 deletions(-)

M corpus/scfg.txt
M grammar.js
M corpus/scfg.txt => corpus/scfg.txt +23 -12
@@ 56,9 56,11 @@ name param1 "param2 " 'param3 '
        (directive_name
          (word))
        (directive_params
          (word)
          (word)
          (word))))
	  (word)
          (word
	    (dquote_word))
          (word
	    (squote_word)))))

================================================================================
Block


@@ 74,7 76,8 @@ name "param" {
        (directive_name
          (word))
        (directive_params
          (word))
          (word
	    (dquote_word)))
        (block
          (directive
            (directive_name


@@ 95,7 98,8 @@ name "par\xam"
          (word))
        (directive_params
          (word
            (esc_pair)))))
	    (dquote_word
	      (esc_pair))))))

================================================================================
Example


@@ 122,13 126,15 @@ train "Shinkansen" {
        (directive_name
          (word))
        (directive_params
          (word))
          (word
	    (dquote_word)))
        (block
          (directive
            (directive_name
              (word))
            (directive_params
              (word))
              (word
		(dquote_word)))
            (block
              (directive
                (directive_name


@@ 144,13 150,16 @@ train "Shinkansen" {
                (directive_name
                  (word))
                (directive_params
                  (word)
                  (word)))))
                  (word
		    (dquote_word))
                  (word
		    (dquote_word))))))
          (directive
            (directive_name
              (word))
            (directive_params
              (word))
              (word
		(dquote_word)))
            (block
              (directive
                (directive_name


@@ 166,5 175,7 @@ train "Shinkansen" {
                (directive_name
                  (word))
                (directive_params
                  (word)
                  (word))))))))
                  (word
		    (dquote_word))
                  (word
		    (dquote_word)))))))))

M grammar.js => grammar.js +3 -3
@@ 34,13 34,13 @@ module.exports = grammar({

    block: ($) => seq("{", $._newline, repeat1($._line), "}"),

    word: ($) => choice($._atom, $._dquote_word, $._squote_word),
    word: ($) => choice($._atom, $.dquote_word, $.squote_word),

    _atom: ($) => token(repeat1(choice(ACHAR, seq("\\", VCHAR)))),

    _dquote_word: ($) => seq('"', repeat(choice(DQCHAR, $.esc_pair)), '"'),
    dquote_word: ($) => seq('"', repeat(choice(DQCHAR, $.esc_pair)), '"'),

    _squote_word: ($) => seq("'", repeat(SQCHAR), "'"),
    squote_word: ($) => seq("'", repeat(SQCHAR), "'"),

    esc_pair: ($) => seq("\\", VCHAR),