diff --git a/src/value/README.md b/src/value/README.md index 6920b93c..c2b26e01 100644 --- a/src/value/README.md +++ b/src/value/README.md @@ -30,3 +30,11 @@ This is how Tokay builtin values are converted during binary operations. | **str** | str | str | str | str | str | str | str | dict | list | **dict** | dict | dict | dict | dict | dict | dict | dict | dict | list | **list** | list | list | list | list | list | list | list | list | list + +# Token severity + +| Severity | Used by | +| -------- | ----------------------------------------------------------------------- | +| 0 | `_`, `__`, `Touch` | +| 5 | Any token (`Char`, `Match`, `Int`, `Float`, `Number`), parselet default | +| 10 | Any explicitly pushed value | diff --git a/src/value/list.rs b/src/value/list.rs index da9ca8a7..9ae8ee95 100644 --- a/src/value/list.rs +++ b/src/value/list.rs @@ -161,7 +161,7 @@ impl List { tokay_method!("list_iadd : @list, append", { // Don't append void if append.is_void() { - return Ok(list) + return Ok(list); } // In case list is not a list, make it a list. @@ -199,7 +199,7 @@ impl List { tokay_method!("list_add : @list, append", { // Don't append void if append.is_void() { - return Ok(list) + return Ok(list); } // In case list is not a list, make it a list. @@ -227,7 +227,7 @@ impl List { tokay_method!("list_push : @list, item, index=void", { // Don't push void if item.is_void() { - return Ok(list) + return Ok(list); } // In case list is not a list, make it a list. diff --git a/src/value/token.rs b/src/value/token.rs index b44acffe..d3a6abfb 100644 --- a/src/value/token.rs +++ b/src/value/token.rs @@ -158,7 +158,7 @@ impl Token { range, None, if matches!(self, Token::Touch(_)) { - 1 + 0 } else { 5 }, diff --git a/src/vm/context.rs b/src/vm/context.rs index 0e5c1451..bf8248c4 100644 --- a/src/vm/context.rs +++ b/src/vm/context.rs @@ -311,7 +311,7 @@ impl<'program, 'reader, 'thread, 'parselet> Context<'program, 'reader, 'thread, let mut list = List::new(); // List collector let mut dict = Dict::new(); // Dict collector - let mut max = 0; // Maximum severity + let mut max = self.parselet.severity; // Require at least parselet severity level let mut idx = 0; // Keep the order for dicts // Collect any significant captures and values diff --git a/tests/parselet_leftrec.tok b/tests/parselet_leftrec.tok index 95703a07..584bec55 100644 --- a/tests/parselet_leftrec.tok +++ b/tests/parselet_leftrec.tok @@ -1,13 +1,13 @@ # direct1 D1: @{ - D1? ''a'' + D1? Char } 'D1' print(D1) # direct2 D2: @{ - D2 'b' - 'a' + D2 Char + Char } 'D2' print(D2) diff --git a/tests/token_modifiers.tok b/tests/token_modifiers.tok index 5365b202..bd63862d 100644 --- a/tests/token_modifiers.tok +++ b/tests/token_modifiers.tok @@ -24,7 +24,6 @@ Int #abcbcd ad #Hello, World, Beta, Test #--- -#(("a", "b"), ("a", "b"), ("a", "b")) #("b", "b", "b") #("b", ("b", "b", "b"), "b") #(("a", "b"), ("a", ("b", "b", "b")), ("b", "b"), ("a", "b"), "b")