From 8f881602bd88d5cc6cac14d4de583e9625241c24 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Thu, 17 Oct 2019 13:15:07 -0300 Subject: rust grammar: expanded use_declarataion to include {} and * --- grammar/rust.lm | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'grammar') diff --git a/grammar/rust.lm b/grammar/rust.lm index f7474a2d..fbe7b578 100644 --- a/grammar/rust.lm +++ b/grammar/rust.lm @@ -1,7 +1,7 @@ lex literal `fn `use `let `mut `if `else `struct `for `in literal `true `false - literal `ref `match + literal `ref `match `as `impl literal `; `:: `( `) `{ `} `. `, literal `[ `] `: @@ -37,8 +37,34 @@ end # Use statments # +def sp_tail + [sp_tail `:: id] +| [] + +def simple_path + [id sp_tail] + +def use_list_tail + [use_list_tail `, use_tree] +| [] + +def use_path_opt + [simple_path `::] +| [`::] +| [] + +def use_as_opt + [`as id] +| [`as `_] +| [] + +def use_tree + [use_path_opt `*] +| [use_path_opt `{ use_tree use_list_tail `}] +| [simple_path use_as_opt] + def use_declaration - [`use qual_id `;] + [`use use_tree `;] # # Patterns @@ -467,14 +493,32 @@ def structure | [`struct id opt_generics `;] | [`struct id opt_generics `( tuple_field_list `) `; ] +# +# Implementation +# + +def inherent_impl_item + [function] + +def inherent_impl + [`impl opt_generics type `{ inherent_impl_item* `}] + +def trait_impl + [] + +def implementation + [inherent_impl] +#| [trait_impl] + # # All Items. # def item - [function] -| [structure] -| [use_declaration] + [function] commit +| [structure] commit +| [implementation] commit +| [use_declaration] commit def program [item*] -- cgit v1.2.1