lib/zenlish/lang/zenlish_grammar.rb in zenlish-0.2.05 vs lib/zenlish/lang/zenlish_grammar.rb in zenlish-0.2.06
- old
+ new
@@ -1,14 +1,16 @@
+# frozen_string_literal: true
+
# Grammar for a simple subset of English language
# It is called Zenlish
require 'rley' # Load the Rley parsing library
require_relative 'dictionary'
########################################
# Define a grammar for a highly English-like language
-builder = Rley::Syntax::GrammarBuilder.new do
+builder = Rley::grammar_builder do
add_terminals(*Zenlish::Lang::Dictionary.terminals)
rule 'zenlish' => 'prose'
rule 'prose' => 'sentence Period'
rule 'prose' => 'prose sentence Period'
@@ -17,11 +19,11 @@
rule 'sentence' => 'complex_sentence'
#################
# Simple sentence
#################
- rule 'simple_sentence' => 'front_adverb simple_sentence'
+ rule 'simple_sentence' => 'front_adverb simple_sentence'
rule 'front_adverb' => 'AdverbMaybe'
rule 'front_adverb' => 'Adverb'
rule 'simple_sentence' => 'declarative_simple_sentence'
rule 'declarative_simple_sentence' => 'affirmative_sentence'
rule 'declarative_simple_sentence' => 'existential_sentence'
@@ -105,11 +107,11 @@
# rule 'comparative_clause' => 'comparative_start DefiniteArticle Adjective Cardinal'
rule 'comparative_start' => 'PrepositionThan'
rule 'comparative_start' => 'ComparativeParticle'
rule 'conjunctive_prefix' => 'ConjunctivePronoun noun_phrase verb_phrase'
rule 'identifying_clause' => 'RelativePronoun tense_verb_phrase'
- rule 'relative_clause_opt' => 'relative_clause'
+ rule 'relative_clause_opt' => 'relative_clause'
rule 'relative_clause_opt' => []
rule 'relative_clause' => 'RelativePronoun tense_phrase'
# Sentence 3-Bxa 'Lisa sees a living thing that is very big.
# Sentence 3-18b: something that was not here before.
rule 'relative_clause' => 'RelativePronoun assertion'
@@ -292,10 +294,10 @@
rule 'preposition_object' => 'noun_phrase' # (noun and pronoun)
# complementation by a verb: gerund -ing form...
rule 'preposition_object' => 'noun_phrase_opt lexical_verb post_head_vp'
# preposition_object => "a gerund (a verb form ending in "-ing") that acts as a noun # Example: He beat Lee without overly trying.
- rule 'preposition_object' => 'conjunctive_prefix' # It's obvious from _what he said_.
+ rule 'preposition_object' => 'conjunctive_prefix' # It's obvious from _what he said_.
rule 'preposition_object' => []
######################
# REMAINING RULES
######################