mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-07 16:18:49 +00:00
[grammar test] Some incomplete test grammars.
This commit is contained in:
+79
-17
@@ -1,3 +1,60 @@
|
|||||||
|
// Arbitrarily deep tree, possibly empty
|
||||||
|
// file : [@child set]
|
||||||
|
// set : '{' [@child set] '}' | set [' ' @sibling set]
|
||||||
|
|
||||||
|
// Labeled leaves
|
||||||
|
// file : [@child set]
|
||||||
|
// set : @fill 'A' | '{' [@child set] '}' | set [' ' @sibling set]
|
||||||
|
|
||||||
|
// Labels also on internal nodes ('iset' is an implicitly separated set)
|
||||||
|
// file : [@child set]
|
||||||
|
// set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] curly_set | set [' ' @sibling set]
|
||||||
|
// iset /* implicit separator */ : @fill 'A' [':' @child iset] | @fill 'A'[':' curly_set] | @fill 'A' [' ' @sibling iset] | @fill 'A' [' ' @sibling curly_set]
|
||||||
|
// curly_set : '{' [@child set] '}'
|
||||||
|
|
||||||
|
// Labels also on internal nodes (v2) ('iset' is an implicitly separated set)
|
||||||
|
// file : [@child set]
|
||||||
|
// set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] curly_set | set [' ' @sibling set]
|
||||||
|
// iset /* implicit separator */ : @fill 'A' [iset_tail]
|
||||||
|
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' curly_set | ' ' @sibling curly_set
|
||||||
|
// curly_set : '{' [@child set] '}'
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
// file : [@child set]
|
||||||
|
// set : {[tag_list] untagged_set}
|
||||||
|
// iset : {[tag_list] untagged_iset}
|
||||||
|
// tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
|
// tag : 'T'
|
||||||
|
// untagged_set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] curly_set | set [' ' @sibling set]
|
||||||
|
// untagged_iset : @fill 'A' [iset_tail]
|
||||||
|
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' curly_set | ' ' @sibling curly_set
|
||||||
|
// curly_set : '{' [@child set] '}'
|
||||||
|
|
||||||
|
// Tag parameters
|
||||||
|
file : [@child set]
|
||||||
|
set : {[tag_list] untagged_set}
|
||||||
|
iset : {[tag_list] untagged_iset}
|
||||||
|
tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
|
tag : @fill 'T'['(' [@child set] ')']
|
||||||
|
untagged_set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] curly_set | set [' ' @sibling set]
|
||||||
|
untagged_iset : @fill 'A' [iset_tail]
|
||||||
|
iset_tail : ':' @child iset | ' ' @sibling iset | ':' curly_set | ' ' @sibling curly_set
|
||||||
|
curly_set : '{' [@child set] '}'
|
||||||
|
|
||||||
|
|
||||||
|
// top-level and set separators
|
||||||
|
// file : [@child file_set_list]
|
||||||
|
// file_set_list : set [file_set_separator @sibling file_set_list]
|
||||||
|
// file_set_separator : ' ' | '\n'
|
||||||
|
// set : '{' [@child set] '}' | set [separator @sibling set]
|
||||||
|
// separator : ' ' | ','
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////// REFERENCE ///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
/* MetaDesk grammar with semantic annotations
|
/* MetaDesk grammar with semantic annotations
|
||||||
*
|
*
|
||||||
* Each line represents a BNF-esque production:
|
* Each line represents a BNF-esque production:
|
||||||
@@ -13,17 +70,30 @@ file : [@child file_set_list]
|
|||||||
file_set_list : { [tag_list] set [file_set_separator @sibling file_set_list] }
|
file_set_list : { [tag_list] set [file_set_separator @sibling file_set_list] }
|
||||||
file_set_separator : ' ' | '\n'
|
file_set_separator : ' ' | '\n'
|
||||||
|
|
||||||
// TODO(mal): Unify file_set_separator and set_separator by allowing ',' and ';' everywhere
|
// TODO(mal): Unify file_set_separator and set_separator by allowing ',' and ';' everywhere ?
|
||||||
set_list : { [tag_list] set [set_separator @sibling file_set_list] }
|
set_list : { [tag_list] set [set_separator @sibling set_list] }
|
||||||
set_separator : ' ' | '\n' | ',' | ';'
|
set_separator : ' ' | '\n' // TODO(mal): | ',' | ';'
|
||||||
// TODO(mal): Accept other open/close tokens
|
|
||||||
tag_list : '@' @tag tag ' ' [tag_list]
|
tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
tag : identifier [@markup '(' [@child set_list] @markup ')']
|
|
||||||
set : @fill leaf | @fill identifier ':' @child @fill leaf | [@fill identifier ':'] set_open [@child set_list] set_close
|
/*
|
||||||
set_open : '{' | '[' | '('
|
tag : identifier [@markup '(' [@child set_list] @markup ')']
|
||||||
set_close : '}' | ']' | ')'
|
set : @fill leaf | @fill identifier ':' @child @fill leaf | [@fill identifier ':'] '{' [@child set_list] '}' | [@fill identifier ':'] set_open [@child set_list] set_close
|
||||||
|
set : @fill leaf | @fill identifier ':' @child space_separated_set_list | [@fill identifier ':'] set_open [@child set_list] set_close
|
||||||
|
*/
|
||||||
|
|
||||||
|
tag : identifier
|
||||||
|
set : @fill leaf [':' @child space_separated_set_list '\n'] | @fill leaf [':' '{' [@child set_list] '}'] | space_separated_set_list '\n' | '{' [@child set_list] '}'
|
||||||
|
|
||||||
|
space_separated_set_list : { [tag_list] set [' ' @sibling space_separated_set_list] }
|
||||||
|
|
||||||
|
|
||||||
|
// set_open : '[' | '('
|
||||||
|
// set_close : ']' | ')'
|
||||||
|
set_open : '[' // TODO(mal): Should also accept '('
|
||||||
|
set_close : ']' // TODO(mal): Should also accept ')'
|
||||||
leaf : identifier | integer_literal | char_literal | string_literal // TODO(mal): Also symbol_label
|
leaf : identifier | integer_literal | char_literal | string_literal // TODO(mal): Also symbol_label
|
||||||
identifier : alpha [alphanumeric] | '_' [alphanumeric]
|
identifier : alpha [alphanumeric]
|
||||||
|
name_identifier : alpha [alphanumeric]
|
||||||
alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
||||||
|
|
||||||
integer_literal : { ['-'] natural_literal }
|
integer_literal : { ['-'] natural_literal }
|
||||||
@@ -64,13 +134,5 @@ escaped_char : '\\' '\\' | '\\' '\'' | '\\' '\"'
|
|||||||
symbol_colon : ':'
|
symbol_colon : ':'
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// NOTE(mal): This is the simplest subset of the grammar that works
|
|
||||||
file : [@child set_list]
|
|
||||||
set_list : set ['\n' @sibling set_list]
|
|
||||||
set : @fill element | '{' [@child set_list] '}'
|
|
||||||
element : 'A'
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user