From c4e07b481cc03d48245aa71593eef77d6277b675 Mon Sep 17 00:00:00 2001 From: Niclas Axelsson Date: Sat, 11 Dec 2021 14:00:11 +0100 Subject: [PATCH] Comply with RFC 3986 --- src/routing_tree_leex.xrl | 6 ++---- src/routing_tree_parser.yrl | 17 ++--------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/routing_tree_leex.xrl b/src/routing_tree_leex.xrl index 9f39981..a344ef7 100644 --- a/src/routing_tree_leex.xrl +++ b/src/routing_tree_leex.xrl @@ -1,14 +1,12 @@ Definitions. -PathSegment = (_|[a-zA-Z]|[0-9])* +PathSegment = (_|-|\.|~|:|/|\[|\]|@|!|\$|\'|\(|\)|\*|\+|,|;|\%|[a-zA-Z]|[0-9])* Divider = (\/) Rules. {Divider}+ : {token, {'divider', TokenLine}}. -\:{PathSegment} : {token, {'binding', TokenLine, strip(TokenChars)}}. \[\.\.\.\] : {token, {'wildcard', TokenLine, '...'}}. -\[ : {token, {'optional_left', TokenLine}}. -\] : {token, {'optional_right', TokenLine}}. +\:{PathSegment} : {token, {'binding', TokenLine, strip(TokenChars)}}. \? : {token, {'query_start', TokenLine}}. \& : {token, {'ampersand', TokenLine}}. \= : {token, {'equals', TokenLine}}. diff --git a/src/routing_tree_parser.yrl b/src/routing_tree_parser.yrl index f7e07e5..a2149a9 100644 --- a/src/routing_tree_parser.yrl +++ b/src/routing_tree_parser.yrl @@ -1,6 +1,6 @@ -Nonterminals url_path path_segment query optional_segment basic_element. +Nonterminals url_path path_segment query basic_element. -Terminals 'divider' 'binding' 'wildcard' 'optional_left' 'optional_right' 'segment' 'query_start' 'ampersand' 'equals'. +Terminals 'divider' 'binding' 'wildcard' 'segment' 'query_start' 'ampersand' 'equals'. Rootsymbol url_path. @@ -10,14 +10,6 @@ basic_element -> basic_element -> 'segment': '$1'. -%% Optional segments can only be at the end of this -optional_segment -> - 'divider' 'optional_left' basic_element 'optional_right': [optional('$3')]. -optional_segment -> - 'divider' 'optional_left' basic_element 'optional_right' query: [optional('$3')|'$5']. -optional_segment -> - 'divider' 'optional_left' basic_element 'optional_right' optional_segment: [optional('$3')|'$5']. - query -> 'segment' 'equals' 'segment': [{'query', '$1', '$3'}]. query -> @@ -29,8 +21,6 @@ path_segment -> 'divider': [{'segment', 1, ""}]. path_segment -> 'divider' 'wildcard': ['$2']. -path_segment -> - optional_segment: '$1'. path_segment -> 'divider' basic_element: ['$2']. path_segment -> @@ -44,6 +34,3 @@ url_path -> Erlang code. - -optional(X) -> - {optional, X}.