From 90bb1822c1242e19c6b6f64ff932bc8d0708e7a0 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Thu, 8 Dec 2022 02:04:36 +0300 Subject: [PATCH] fix comment in string --- grammar.js | 2 +- src/grammar.json | 26 +++++++++++++++----------- src/parser.c | Bin 188039 -> 187167 bytes test/corpus/attributes.txt | 11 +++++++++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/grammar.js b/grammar.js index ca21f25..5cded53 100644 --- a/grammar.js +++ b/grammar.js @@ -188,7 +188,7 @@ module.exports = grammar({ seq("`", repeat(token.immediate(/[^`\n]+/)), "`") ), - line_comment: ($) => token(seq("#", /.*/)), + line_comment: ($) => token(prec(-2, seq("#", /.*/))), _word: ($) => /[\w\d]+/, diff --git a/src/grammar.json b/src/grammar.json index 7c743d0..308cb58 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1122,17 +1122,21 @@ "line_comment": { "type": "TOKEN", "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "#" - }, - { - "type": "PATTERN", - "value": ".*" - } - ] + "type": "PREC", + "value": -2, + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "#" + }, + { + "type": "PATTERN", + "value": ".*" + } + ] + } } }, "_word": { diff --git a/src/parser.c b/src/parser.c index d8233ffbdcc81d63e44a7872fc22e7b2598c794f..50a318ee739a5e83a172970874109e0bce90e92a 100644 GIT binary patch delta 4827 zcma)Ad014}760A=3CqlYfC7p-m>`QRZ{F;TvZygeMMT666^zxi5(N^qX%hEZw>F?B za8zQ1XcLVa6b*?hs0bAoAjXJIBBsrkwAsvNQ%z#edv6xBkfSQ~MnDBNW-pJBn@dUeI!|K9F{9=XuAE{+%?f|~Y)UXjPmaTTGqw2BgaKGHSA(1O1SvLIQ#H8nkh;!4 zti#L(9Tw&2u=I!)XTBb&tP3t_@Uu69@KB)+1E19j7Q8tn63eo0;QKWJ_}rvnzlgIt z#-gmr4*Q;!N5d5Xzmdb*~0$g;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