@@ -17,6 +17,10 @@ function caseInsensitive(keyword) {
1717module . exports = grammar ( {
1818 name : 'ggsql' ,
1919
20+ inline : $ => [
21+ $ . source_ref ,
22+ ] ,
23+
2024 conflicts : $ => [
2125 [ $ . sql_portion ] ,
2226 ] ,
@@ -480,9 +484,16 @@ module.exports = grammar({
480484 repeat ( seq ( '.' , $ . identifier ) )
481485 ) ) ,
482486
487+ source_ref : $ => choice (
488+ $ . qualified_name ,
489+ $ . string ,
490+ $ . namespaced_identifier ,
491+ $ . jinja_template
492+ ) ,
493+
483494 table_ref : $ => prec . right ( seq (
484495 choice (
485- field ( 'table' , choice ( $ . qualified_name , $ . string , $ . namespaced_identifier , $ . jinja_template ) ) ,
496+ field ( 'table' , $ . source_ref ) ,
486497 $ . subquery ,
487498 ) ,
488499 optional ( seq (
@@ -601,14 +612,14 @@ module.exports = grammar({
601612 // Option 1: Just FROM (inherit global mappings)
602613 seq (
603614 caseInsensitive ( 'FROM' ) ,
604- field ( 'layer_source' , choice ( $ . qualified_name , $ . string , $ . namespaced_identifier ) )
615+ field ( 'layer_source' , $ . source_ref )
605616 ) ,
606617 // Option 2: Mapping list (uses shared structure), optionally followed by FROM
607618 seq (
608619 $ . mapping_list ,
609620 optional ( seq (
610621 caseInsensitive ( 'FROM' ) ,
611- field ( 'layer_source' , choice ( $ . qualified_name , $ . string , $ . namespaced_identifier ) )
622+ field ( 'layer_source' , $ . source_ref )
612623 ) )
613624 )
614625 )
@@ -942,9 +953,9 @@ module.exports = grammar({
942953 // before ggsql executes SQL, but the parser must preserve them while
943954 // splitting SQL from VISUALISE.
944955 jinja_template : $ => token ( choice (
945- / \{ \{ [ ^ } ] * \} \} / ,
946- / \{ % [ ^ % ] * % \} / ,
947- / \{ # [ ^ # ] * # \} /
956+ seq ( '{{' , repeat ( choice ( / [ ^ } ] + / , / } [ ^ } ] / ) ) , '}}' ) ,
957+ seq ( '{%' , repeat ( choice ( / [ ^ % ] + / , / % [ ^ % ] / ) ) , '%}' ) ,
958+ seq ( '{#' , repeat ( choice ( / [ ^ # ] + / , / # [ ^ # ] / ) ) , '#}' )
948959 ) ) ,
949960
950961 // Identifier for use in filter expressions - uses lower precedence so that
0 commit comments