From 5b401847a179d37ff81066687a087c3b5ed20008 Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sat, 7 Mar 2020 14:05:20 -0500 Subject: script useful for debugging --- grammar.rb | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100755 grammar.rb (limited to 'grammar.rb') diff --git a/grammar.rb b/grammar.rb new file mode 100755 index 0000000..eb4aa07 --- /dev/null +++ b/grammar.rb @@ -0,0 +1,241 @@ +#! env ruby + +# something to help examine the possible variations of a sub-pattern +# run without arguments to see usage +# mind the expontential complexity! + +raw = <<-END.gsub %r{//.*$}, '' + TOP -> r(r"\A") r(r"\z") + + // non-terminal patterns + // these are roughly ordered by dependency + + time_expression => | + + particular => | + + one_time => + + two_times -> ("from")? + + to => | + + moment_or_period => | + + period => | + + specific_period => | | | + + modified_period -> ? + + // replacing [["week", "month", "year", "pay period", "payperiod", "pp", "weekend"]] with + // because this script doesn't have handling for the [...] pattern + modifiable_period => | | + + month_and_year -> + + year => | ("-")? + year -> + + year_suffix => | + + relative_period -> + + count => r(r"[1-9][0-9]*") | + + named_period => | + + moment -> ? + + adjustment -> // two minutes before + + amount -> + + point_in_time -> ? ? | |