summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--].gitignore0
-rwxr-xr-x[-rw-r--r--]data/misc/700000items.gram15
-rwxr-xr-x[-rw-r--r--]data/misc/nimble.gram27
-rwxr-xr-x[-rw-r--r--]data/new-sample-grammars/cbs.gram1387
-rw-r--r--data/new-sample-grammars/drakensang/armor.gram30
-rw-r--r--data/new-sample-grammars/drakensang/gems.gram39
-rw-r--r--data/new-sample-grammars/perchance/meal.gram33
-rwxr-xr-x[-rw-r--r--]data/new-sample-grammars/repinsult.gram13
-rwxr-xr-x[-rw-r--r--]data/rpg-tools-cd/wands.gram80
-rwxr-xr-xdata/sample-grammars/24hr-rpg.gram410
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/acronym.gram13
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/address.gram25
-rwxr-xr-xdata/sample-grammars/anime.gram23
-rwxr-xr-xdata/sample-grammars/art-objects.gram38
-rwxr-xr-xdata/sample-grammars/awe-names.gram10
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/buzzword.gram8
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/career.gram18
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/city.gram22
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/college.gram32
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/company.gram11
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/computer.gram6
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/congress.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dates.gram0
-rwxr-xr-xdata/sample-grammars/diablo-ii/diabloii.gram37
-rwxr-xr-xdata/sample-grammars/diablo-ii/diabloiiitems.gram24
-rwxr-xr-xdata/sample-grammars/diablo-ii/diabloiiperish.gram5
-rwxr-xr-xdata/sample-grammars/diablo-ii/diabloiiprefixes.gram13
-rwxr-xr-xdata/sample-grammars/diablo-ii/diabloiisuffixes.gram11
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dungeondressing/abandoned.gram2
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dungeondressing/bedroom.gram73
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dungeondressing/dragonencounter.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dungeondressing/kitchen.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/dungeondressing/monster.gram11
-rw-r--r--data/sample-grammars/eastern-sun/easternsunsocketing.gram5
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/elementals.gram46
-rwxr-xr-xdata/sample-grammars/fantasy-locations.gram42
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/fortune.gram0
-rw-r--r--data/sample-grammars/gemstones.gram48
-rwxr-xr-xdata/sample-grammars/genre-fiction.gram9
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/horror.gram54
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/insults.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/linux.gram101
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/animal.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/canada-province.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/cards.gram58
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/color.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/first-name-female.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/first-name-male.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/geographic-thing.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/last-name.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/letters.gram6
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/nation.gram436
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/numbers.gram19
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/planet.gram2
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/real-city.gram153
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/real-company.gram415
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/relative.gram2
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/roman-numeral.gram6
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/syllables.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/town-name.gram282
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/long-data/tree.gram2
-rwxr-xr-xdata/sample-grammars/martial-arts.gram68
-rwxr-xr-xdata/sample-grammars/mary-sue.gram20
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/media.gram17
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/mission.gram2
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/names.gram514
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/newspaper.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/numbers.gram14
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/ordinal.gram8
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/organization.gram9
-rwxr-xr-xdata/sample-grammars/part-creature.gram16
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/phone-number.gram14
-rwxr-xr-xdata/sample-grammars/pokeattacks.gram47
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/president.gram120
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/adjective.gram4
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/bodyparts.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/class.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/color.gram46
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/creature.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/death-cause.gram6
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/fantasy-name.gram17
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/favorite.gram8
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/guns.gram26
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/item.gram7
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/rtwiki/traits.gram0
-rwxr-xr-xdata/sample-grammars/rune.gram19
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/school.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/slashdot.gram0
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/states.gram100
-rwxr-xr-xdata/sample-grammars/superhero.gram62
-rwxr-xr-xdata/sample-grammars/tarotcard.gram10
-rwxr-xr-xdata/sample-grammars/technobabble.gram11
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/theory.gram9
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/trademark.gram4
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/vaultsofnagoh/turboghoul-hats.gram18
-rwxr-xr-x[-rw-r--r--]data/sample-grammars/web.gram35
-rwxr-xr-xdata/sample-grammars/zadrons-pouch.gram4
-rwxr-xr-x[-rw-r--r--]data/seniordesign/dbdata.gram26
-rw-r--r--data/server-config-sample.cfg119
-rwxr-xr-xdata/server-config-sample.gcfg127
-rwxr-xr-x[-rw-r--r--]data/todos.txt8
-rwxr-xr-xdotest.sh3
-rw-r--r--gram.txt1361
-rwxr-xr-x[-rw-r--r--]pom.xml9
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/ZadronsPouch.java0
-rw-r--r--src/main/java/bjc/rgens/parser/ConfigLoader.java242
-rw-r--r--src/main/java/bjc/rgens/parser/ConfigSet.java18
-rw-r--r--src/main/java/bjc/rgens/parser/FlatRuleCase.java23
-rw-r--r--src/main/java/bjc/rgens/parser/GenerationState.java104
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/GrammarException.java0
-rw-r--r--src/main/java/bjc/rgens/parser/NormalRuleCase.java26
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammar.java389
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammarBuilder.java226
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammarFormatter.java13
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammarParser.java261
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammarSet.java129
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammarTest.java124
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RGrammars.java29
-rw-r--r--src/main/java/bjc/rgens/parser/RecurLimitException.java35
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RegexRuleCase.java27
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/Rule.java132
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/RuleCase.java78
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/BlankCaseElement.java2
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/CaseElement.java143
-rw-r--r--src/main/java/bjc/rgens/parser/elements/ChanceCaseElement.java20
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/ExpVariableCaseElement.java37
-rw-r--r--src/main/java/bjc/rgens/parser/elements/InlineRuleCaseElement.java41
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/LitVariableCaseElement.java10
-rw-r--r--src/main/java/bjc/rgens/parser/elements/LiteralCaseElement.java16
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/RangeCaseElement.java11
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/RuleCaseElement.java100
-rw-r--r--src/main/java/bjc/rgens/parser/elements/RuleVariableCaseElement.java39
-rw-r--r--src/main/java/bjc/rgens/parser/elements/SerialCaseElement.java30
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/StringCaseElement.java6
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/elements/VariableDefCaseElement.java (renamed from src/main/java/bjc/rgens/parser/elements/VariableCaseElement.java)24
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/ARefVariableElement.java31
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/LiteralVariableElement.java17
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/RRefVariableElement.java31
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/TRefVariableElement.java42
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/VRefVariableElement.java27
-rw-r--r--src/main/java/bjc/rgens/parser/elements/vars/VariableElement.java71
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/parser/new-syntax.txt0
-rw-r--r--src/main/java/bjc/rgens/parser/templates/GrammarTemplate.java75
-rw-r--r--src/main/java/bjc/rgens/parser/templates/LiteralTemplateElement.java17
-rw-r--r--src/main/java/bjc/rgens/parser/templates/LiveTemplateElement.java60
-rw-r--r--src/main/java/bjc/rgens/parser/templates/TemplateElement.java15
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/text/markov/Markov.java0
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java0
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java0
-rwxr-xr-x[-rw-r--r--]src/main/java/bjc/rgens/text/markov/TextGenerator.java0
-rwxr-xr-x[-rw-r--r--]src/main/sql/db_schema.sql0
-rwxr-xr-x[-rw-r--r--]todos.txt15
152 files changed, 6751 insertions, 2975 deletions
diff --git a/.gitignore b/.gitignore
index 262500a..262500a 100644..100755
--- a/.gitignore
+++ b/.gitignore
diff --git a/data/misc/700000items.gram b/data/misc/700000items.gram
index 4158dcb..77bb6e7 100644..100755
--- a/data/misc/700000items.gram
+++ b/data/misc/700000items.gram
@@ -1,13 +1,14 @@
-[item-name] [noun]
+[isaac-item-name] {@adjs:=[adj]} [act-isaac-item-name]
-pragma prefix-with [item-name] [post]
-pragma prefix-with [item-name] [adj]
-pragma prefix-with [item-name] [adj]
-pragma prefix-with [item-name] [pre]
+[act-isaac-item-name] [noun]
-pragma suffix-with [item-name] [end]
+pragma prefix-with [act-isaac-item-name] [post]
+pragma prefix-with [act-isaac-item-name] <&1..2> [@adjs]
+pragma prefix-with [act-isaac-item-name] [pre]
-pragma initial-rule [item-name]
+pragma suffix-with [isaac-item-name] [end]
+
+pragma initial-rule [isaac-item-name]
[noun] Boy
Kid
diff --git a/data/misc/nimble.gram b/data/misc/nimble.gram
index 3567777..0408011 100644..100755
--- a/data/misc/nimble.gram
+++ b/data/misc/nimble.gram
@@ -1,18 +1,5 @@
-[nimble-bimble] [bimble]
-
-pragma prefix-with [nimble-bimble] [nimble-plural]
-pragma suffix-with [nimble-bimble] [nimble-plural]
-
-pragma initial-rule [nimble-bimble]
-
-[nimble-plural] [nimble-art] [nimble]
-
-[bimble] bimble
- nimble
- bimble
- nimble
- bimble
- nimble
+[bimble] <^4> bimble
+ <^4> nimble
dindle
symbol
frindle
@@ -27,4 +14,14 @@ pragma initial-rule [nimble-bimble]
while they
a
+[nimble-plural] [nimble-art] [nimble]
+
[nimble] [bimble]
+
+[nimble-bimble] [bimble]
+
+pragma prefix-with [nimble-bimble] [nimble-plural]
+pragma suffix-with [nimble-bimble] [nimble-plural]
+
+pragma initial-rule [nimble-bimble]
+pragma export-rule [nimble]
diff --git a/data/new-sample-grammars/cbs.gram b/data/new-sample-grammars/cbs.gram
index 8d05dd1..a72de3e 100644..100755
--- a/data/new-sample-grammars/cbs.gram
+++ b/data/new-sample-grammars/cbs.gram
@@ -1,58 +1,82 @@
-where
- [boss+codirector] → [boss-co] Director
- .
- [boss+cochief] → [boss-co] Chief
- .
- [boss+cohead] → [boss-co] Head
- .
- [boss+copresident] → [boss-co] President
- .
- [boss+comanager] → [boss-co] Manager
- .
- [boss-managing] → Managing
- Acting
- General
- .
- [boss-vice] → Vice
- Vice
- Vice
- Corporate Vice
- {empty}
- .
- [boss-co] → Co-
- {empty}
- .
-in
- [boss-title] → [boss-vice] [boss+codirector]
- [boss+cochief]
- [boss+cohead]
- [boss-vice] [boss+copresident]
- Supervisor
- [boss+comanager]
-end
-
-[boss-age] → Senior
- {empty}
+#
+# The Corporate Bullshit Generator (CBSG)
+#
+# Sources:
+#
+# - personal notes from long years of professional experience
+# - new words from the Internet by feeding a search
+# engine with sentences of the generator
+# - very valuable, appreciated and proactive contributions
+# from my colleagues and friends, especially:
+# Mili Eppler, Nigel Findlater, Emilio Nualart,
+# Bernhard Maertl, Paul Della Marta, Georges Modol,
+# Andrew Fox, Kurt Dickmann, Georg Bauhaus, Frederic Praca,
+# David Malinge
+# - high-level, responsive empowerments by Ludovic Brenta
+#
+# Legal licensing note:
+#
+# Copyright (c) Gautier de Montmollin 2006 .. 2016
+# CH-8810 Horgen
+# SWITZERLAND
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+# NB: this is the MIT License, as found 12-Sep-2007 on the site
+# http://www.opensource.org/licenses/mit-license.php
+#
+
+[boss-managing] Managing
+ Acting
+ General
+
+[boss-title-vice] Vice
+ Corporate Vice
+
+[boss-title-co] Co-
+
+[boss-title] Director
+ Chief
+ Head
+ President
+ Supervisor
+ Manager
-[boss-exec] → Executive
+pragma prefix-with [boss-title] [boss-title-co] [boss-title-vice]
+
+[boss-age] Senior
+
+[boss-exec] Executive
Principal
- {empty}
- {empty}
-[boss-groupal] → Group
+[boss-groupal] Group
Global
- {empty}
- {empty}
-[boss-department] → Human Resources
- Controlling
- Internal Audit
+[boss-department-1] Human Resources
+ Controllers
+ Internal Audits
Legal
Operations
- Management Office
+ Management Offices
Customer Relations
Client Leadership
- Client Relationship
+ Client Relationships
Business Planning
Business Operations
IT Strategy
@@ -63,24 +87,1267 @@ end
Innovation
Identity
Branding
- Diversity and Exclusion
-
-[boss-departmentrole] → [boss-department]
- [boss-department]
- [boss-department]
- [boss-department]
- [boss-department]
- Visionary
+ Diversity and Inclusion
+
+[boss-department-2] Visionary
Digital
Technical
Manifesto
-[boss-catalyst] → Catalyst
+[boss-department] <^4> [boss-department-1]
+ [boss-department-2]
+
+[boss-officer] Catalyst
Futurist
- Officer
- Officer
+ <^3> Officer
+
+[boss-dept-of] of [boss-department-1]
+
+[boss-type-1] [boss-title]
+
+pragma suffix-with [boss-type-1] [boss-dept-of]
+pragma prefix-with [boss-type-1] [boss-managing] [boss-exec]
+pragma prefix-with [boss-type-1] [boss-age]
+
+[boss-type-2] Chief
+
+pragma prefix-with [boss-type-2] [boss-groupal]
+pragma suffix-with [boss-type-2] [boss-department] [boss-officer]
+
+[boss] [boss-type-1]
+ [boss-type-2]
+
+pragma export-rule [boss]
+
+[thing-atom-inner] mission
+ vision
+ guideline
+ roadmap
+ timeline
+ [matrix-or-so]
+ win-win-solution
+ baseline starting point
+ sign-off
+ escalation
+ system
+ Management Information System
+ Quality Management System
+ planning
+ target
+ calibration
+ Control Information System
+ process
+ talent
+ execution
+ leadership
+ performance
+ solution provider
+ value
+ value creation
+ feedback
+ document
+ bottom line
+ momentum
+ opportunity
+ credibility
+ issue
+ core meeting
+ platform
+ niche
+ content
+ communication
+ goal
+ skill
+ alternative
+ culture
+ requirement
+ potential
+ challenge
+ empowerment
+ benchmarking
+ framework
+ benchmark
+ implication
+ integration
+ enabler
+ control
+ trend
+ business case
+ architecture
+ action plan
+ project
+ review cycle
+ trigger event
+ strategy formulation
+ decision
+ enhanced data capture
+ energy
+ plan
+ initiative
+ priority
+ synergy
+ incentive
+ dialogue
+ concept
+ time-phase
+ projection
+ 009:
+ blended approach
+ eak phrases
+ low hanging fruit
+ forward planning
+ pre-plan
+ pipeline
+ bandwidth
+ brand image
+ paradigm
+ paradigm shift
+ strategic staircase
+ cornerstone
+ executive talent
+ evolution
+ workflow
+ message
+ risk/return profile
+ efficient frontier
+ pillar
+ internal client
+ consistency
+ on-boarding process
+ dotted line
+ action item
+ cost efficiency
+ channel
+ convergence
+ infrastructure
+ metric
+ technology
+ relationship
+ partnership
+ supply-chain
+ portal
+ solution
+ business line
+ white paper
+ scalability
+ innovation
+ Strategic Management System
+ Balanced Scorecard
+ differentiator
+ case study
+ idiosyncrasy
+ benefit
+ say/do ratio
+ segmentation
+ image
+ realignment
+ business model
+ business philosophy
+ business platform
+ methodology
+ profile
+ measure
+ measurement
+ philosophy
+ branding strategy
+ efficiency
+ industry
+ commitment
+ perspective
+ risk appetite
+ best practice
+ brand identity
+ customer centricity
+ shareholder value
+ attitude
+ mindset
+ flexibility
+ granularity
+ engagement
+ pyramid
+ market
+ diversity
+ interdependency
+ scaling
+ asset
+ flow charting
+ value proposition
+ performance culture
+ change
+ reward
+ learning
+ next step
+ delivery framework
+ structure
+ support structure
+ standardization
+ objective
+ footprint
+ transformation process
+ policy
+ sales target
+ ecosystem
+ landscape
+ atmosphere
+ environment
+ core competency
+ market practice
+ operating strategy
+ insight
+ accomplishment
+ correlation
+ touchpoint
+ knowledge transfer
+ correlation
+ capability
+ gamification
+ smooth transition
+ leadership strategy
+ collaboration
+ success factor
+ lever
+ breakthrough
+ open-door policy
+ recalibration
+ wow factor
+ onboarding solution
+ brand pyramid
+ dashboard
+ branding
+ local-for-local strategy
+ cross-sell message
+ up-sell message
+ divisional structure
+ value chain
+ microsegment
+ rollout plan
+ leadership development system
+ architectural approach
+ brand value
+ milestone
+ co-innovation
+ speedup
+ validation
+
+[thing-atom-single] [timeless-event]
+ team building
+ focus
+ strategy
+ planning granularity
+ core business
+ implementation
+ intelligence
+ change management
+ ROE
+ EBITDA
+ enterprise content management
+ excellence
+ trust
+ respect
+ openness
+ transparency
+ Quality Research
+ decision making
+ risk management
+ enterprise risk management
+ leverage
+ diversification
+ successful execution
+ effective execution
+ selectivity
+ optionality
+ expertise
+ awareness
+ broader thinking
+ client focus
+ thought leadership
+ quest for quality
+ ak phrases
+ 360-degree thinking
+ drill-down
+ impetus
+ fairness
+ intellect
+ emotional impact
+ emotional intelligence
+ adaptability
+ stress management
+ self-awareness
+ strategic thinking
+ cross fertilization
+ cross-breeding
+ customer experience
+ centerpiece
+ SWOT analysis
+ responsibility
+ accountability
+ ROI
+ line of business
+ serviceability
+ responsiveness
+ simplicity
+ portfolio shaping
+ knowledge sharing
+ continuity
+ visual thinking
+ interoperability
+ compliance
+ teamwork
+ self-efficacy
+ decision-making
+ line-of-sight
+ scoping
+ line-up
+ predictability
+ recognition
+ investor confidence
+ competitive advantage
+ uniformity
+ connectivity
+ big picture
+ big-picture thinking
+ quality
+ upside focus
+ sustainability
+ resiliency
+ social sphere
+ intuitiveness
+ effectiveness
+ competitiveness
+ resourcefulness
+ informationalization
+ role building
+ talent retention
+ innovativeness
+ Economic Value Creation
+ intellectual capital
+ high quality
+ full range of products
+ technical strength
+ quality assurance
+ specification quality
+ market environment
+ client perspective
+ solution orientation
+ client satisfaction
+ integrity
+ reputation
+ time-to-market
+ innovative edge
+ book value growth
+ global network
+ ability to deliver
+ active differentiation
+ solid profitability
+ core capacity
+ digital economy
+ white-collar productivity
+ white-collar efficiency
+ governance
+ corporate governance
+ business development
+ corporate identity
+ attractiveness
+ design philosophy
+ global footprint
+ risk taking
+ focus on speed
+ business equation
+ edge
+ ownership
+ competitive success
+ discipline
+ knowledge management
+ ability to move fast
+ franchise
+ global reach
+ integrativeness
+ customer footprint
+ time-to-value
+ efficacy
+ DNA
+ dedication
+ ingenuity
+ [thing-atom-inner]
+
+[thing-atom-plural] key target markets
+ style guidelines
+ key performance indicators
+ market conditions
+ market forces
+ market opportunities
+ tactics
+ organizing principles
+ interpersonal skills
+ roles and responsibilities
+ cost savings
+ lessons learned
+ client needs
+ requests / solutions
+ mobile strategies
+ expectations and allocations
+ workshops
+ dynamics
+ options
+ aspirations
+ # @TODO
+ # Once we get plural support, add inner plurals
+
+[thing-atom] [thing-atom-single]
+ [thing-atom-plural]
+
+[matrix-or-so] organization
+ silo
+ matrix
+ cube
+ sphere
+
+[timeless-event] kick-off
+ roll-out
+ client event
+ quarter results
+
+[person-single-spec] steering comittee
+ group
+ project manager
+ [thing-atom] champion
+ community
+ sales manager
+ enabler
+ powerful champion
+ thought leader
+ gatekeeper
+ resource
+ senior support staff
+ brand manager
+ category manager
+ account executive
+ project leader
+ product manager
+ naming committee
+ executive comittee
+ white-collar workforce
+ innovator
+ game changer
+ visionary
+
+[person-single] <^2> [person-single-spec]
+ [boss]
+
+[person-plural] key people
+ human resources
+ customers
+ clients
+ resources
+ team players
+ enablers
+ stakeholders
+ standard-setters
+ partners
+ business leaders
+ thinkers/planners
+ white-collar workers
+ board-level executives
+ key representatives
+ innovators
+ policy makers
+ pioneers
+ game changers
+
+[person] [person-single]
+ [person-plural]
+
+[thing-adjective] efficient
+ strategic
+ constructive
+ proactive
+ strong
+ key
+ global
+ corporate
+ cost-effective
+ focused
+ top-line
+ credible
+ agile
+ holistic
+ new
+ adaptive
+ optimal
+ unique
+ core
+ compliant
+ goal-oriented
+ non-linear
+ problem-solving
+ prioritizing
+ cultural
+ future-oriented
+ potential
+ versatile
+ leading
+ dynamic
+ progressive
+ non-deterministic
+ informed
+ leveraged
+ challenging
+ intelligent
+ controlled
+ educated
+ non-standard
+ underlying
+ centralized
+ decentralized
+ reliable
+ consistent
+ competent
+ prospective
+ collateral
+ functional
+ tolerably expensive
+ organic
+ forward-looking
+ next-level
+ executive
+ seamless
+ spectral
+ balanced
+ effective
+ integrated
+ systematized
+ parallel
+ responsive
+ synchronized
+ compatible
+ carefully thought-out
+ cascading
+ high-level
+ siloed
+ operational
+ future-ready
+ flexible
+ movable
+ right
+ productive
+ evolutionary
+ overarching
+ documented
+ awesome
+ coordinated
+ aligned
+ enhanced
+ control-based
+ industry-standard
+ accepted
+ agreed-upon
+ target
+ customer-centric
+ wide-spectrum
+ well-communicated
+ cutting-edge
+ best-in-class
+ state-of-the-art
+ verifiable
+ solid
+ inspiring
+ growing
+ market-altering
+ vertical
+ emerging
+ differentiating
+ integrative
+ cross-functional
+ measurable
+ well-planned
+ accessible
+ actionable
+ accurate
+ insightful
+ relevant
+ long-term
+ top
+ tactical
+ best-of-breed
+ robust
+ targeted
+ personalized
+ interactive
+ streamlined
+ transparent
+ traceable
+ far-reaching
+ powerful
+ improved
+ executive-level
+ goal-based
+ top-level
+ value-added
+ value-adding
+ streamlining
+ time-honored
+ idiosyncratic
+ sustainable
+ in-depth
+ immersive
+ cross-industry
+ time-phased
+ day-to-day
+ present-day
+ medium-to-long-term
+ profit-maximizing
+ generic
+ granular
+ values-based
+ value-driven
+ well-defined
+ outward-looking
+ scalable
+ strategy-focused
+ promising
+ collaborative
+ scenario-based
+ principle-based
+ vision-setting
+ client-oriented
+ long-established
+ established
+ organizational
+ visionary
+ trusted
+ full-scale
+ firm-wide
+ fast-growth
+ performance-based
+ high-performing
+ high-performance
+ cross-enterprise
+ outsourced
+ situational
+ bottom-up
+ multidisciplinary
+ one-to-one
+ goal-directed
+ intra-organisational
+ high-performing
+ multi-source
+ 360-degree
+ motivational
+ differentiated
+ solutions-based
+ compelling
+ structural
+ go-to-market
+ on-message
+ adequate
+ value-enhancing
+ mission-critical
+ business enabling
+ transitional
+ future
+ game-changing
+ enterprise-wide
+ rock-solid
+ bullet-proof
+ superior
+ genuine
+ alert
+ nimble
+ phased
+ selective
+ macroscopic
+ low-risk high-yield
+ interconnected
+ high-margin
+ resilient
+ high-definition
+ well-crafted
+ fine-grained
+ context-aware
+ multi-tasked
+ feedback-based
+ analytics-based
+ fact-based
+ usage-based
+ multi-channel
+ omni-channel
+ pre-approved
+ specific
+ heart-of-the-business
+ responsible
+ socially conscious
+ results-centric
+ business-led
+ well-positioned
+ end-to-end
+ high-quality
+ siloed
+ modular
+ service-oriented
+ competitive
+ scale-as-you-grow
+ outside-in
+ hyper-hybrid
+ long-running
+ large-scale
+ wide-ranging
+ active
+ stellar
+ dramatic
+ aggressive
+ innovative
+ high-powered
+ above-average
+ result-driven
+ innovation-driven
+ customized
+ outstanding
+ non-mainstream
+ customer-facing
+ consumer-facing
+ unified
+ cooperative
+ laser-focused
+ well-implemented
+ diversifying
+ market-changing
+ metrics-driven
+ pre-integrated
+ solution-oriented
+ impactful
+ world-class
+ turn-key
+ leading-edge
+ next-generation
+ extensible
+ under-the-radar
+ high-grade
+ structured
+ trust-based
+ intra-company
+ inter-company
+ profit-oriented
+ sizeable
+ highly satisfactory
+ bi-face
+ tri-face
+ disruptive
+ technological
+ marketplace
+ fast-evolving
+ open
+ fully networked
+ adoptable
+ trustworthy
+ science-based
+ non-manufacturing
+ multi-divisional
+ controllable
+ high-priority
+ market-driven
+ market-driving
+ ingenious
+ business-for-business
+ inspirational
+ winning
+ boundaryless
+ reality-based
+ customer-focused
+ preemptive
+ location-specific
+ revealing
+ inventory-planning
+ ubiquitous
+ number-one
+ results-oriented
+ socially enabled
+ well-scoped
+ insight-based
+ high-impact
+ technology-driven
+ knowledge-based
+ information-age
+ technology-centered
+ critical
+ cognitive
+ acculturated
+ client-centric
+ comprehensive
+ ground-breaking
+ long-standing
+ accelerating
+ forward-thinking
+ mind-blowing
+ jaw-dropping
+ transformative
+ better-than-planned
+ vital
+ radical
+ expanding
+ fierce
+ single-minded
+ mindful
+ top-down
+ hands-on
+ one-on-one
+ analytic
+
+[growth-superlative] organic
+ double-digit
+ upper single-digit
+ breakout
+ unprecedented
+ unparalleled
+ proven
+ measured
+ xchange fads
+ sustained
+ sustainable
+ robust
+ solid
+ rock-solid
+ healthy
+ incremental
+ significant
+ recurring
+ sizeable
+ rapid
+ breakneck
+ profitable
+ disciplined
+ accelerated
+ impressive
+
+[growth-improvement] growth
+ improvement
+ throughput increase
+ efficency gain
+ yield enhancement
+ expansion
+ productivity improvement
+ gain in task efficency
+ shift in value
+ increase in margins
+ cost reduction
+
+[growth] [growth-superlative] [growth-improvement]
+
+pragma export-rule [growth]
+
+[thing-with-adj] <^3> [thing-adjective] , [thing-adjective] [thing-atom]
+ <^3> [thing-adjective] and [thing-adjective] [thing-atom]
+ <^4> [thing-adjective] [thing-atom]
+ <^2> [thing-adjective] and/or [thing-adjective] [thing-atom]
+ [growth]
+ <^2> [thing-adjective] [thing-adjective] [thing-adjective] [thing-atom]
+
+[thing] [thing-with-adj]
+ [thing-atom]
+
+pragma export-rule [thing]
+
+[bad-things] issues
+ intricacies
+ organizational diseconomies
+ black swans
+ challenging market conditions
+ inefficiencies
+ overlaps
+ known unknowns
+ unknown unknowns
+ soft cycle issues
+ obstacles
+ surprises
+ weaknesses
+ threats
+ barriers to success
+ barriers
+ shortcomings
+ problems
+ uncertainties
+ unfavorable developments
+ consumer/agent disconnects
+ underperforming areas
+ information overloads
+ concerns
+ shortfalls
+ limitations
+ downtimes
+ headwinds
+ subpar returns
+ gaps
+ market gaps
+
+[eventual-adverb-1] interactively
+ credibly
+ quickly
+ proactively
+ 200%
+ 24/7
+ globally
+ culturally
+ technically
+ strategically
+ swiftly
+ cautiously
+ expediently
+ organically
+ carefully
+ significantly
+ conservatively
+ adequately
+ genuinely
+ efficently
+ seamlessly
+ consistently
+ diligently
+ dramatically
+ straightforwardly
+ differentially
+ gradually
+ aggressively
+
+[eventual-adverb] <^3> {empty}
+ [eventual-adverb-1]
+
+[random-article] the
+ our
+ <^4> a
+ <^4> an
+ {empty}
+
+[eventual-postfix-adverb-1] going forward
+ within the industry
+ across the board
+ in this space
+ from the get-go
+ at the end of the day
+ throughout the organization
+ as part of the plan
+ by thinking outside the box
+ using [random-article] [thing]
+ by leveraging [random-article] [thing]
+ taking advantage of [random-article] [thing]
+ within the [matrix-or-so]
+ acroos the [matrix-or-so]
+ across and beyond the [matrix-or-so]
+ resulting in [random-article] [growth]
+ reaped from our [growth]
+ as a consequence of [random-article] [growth]
+ because [random-article] [thing] produce [growth]
+ ahead of schedule
+ , relative to our peers
+ on a transitional basis
+ by expanding boundaries
+ by nurturing talent
+ , as a tier 1 company
+ up-front
+ on-the-fly
+ across our portfolio
+ 50/50
+ up, down, and across the [matrix-or-so]
+ in the marketplace
+ by thinking and acting beyond boundaries
+ at the individual, team and organizational level
+ ensuring [random-article] [thing]
+ over the long term
+ across geographies
+ in the core
+ across industry sectors
+ across the wider Group
+ , paving the way for [random-article] [thing]
+
+[eventual-postfix-adverb] [eventual-postfix-adverb-1]
+ <^4> {empty}
+
+pragma export-rule [eventual-postfix-adverb-1]
+
+[person-verb-thing] manage
+ target
+ streamline
+ improve
+ optimize
+ achieve
+ secure
+ address
+ boost
+ deploy
+ innovate
+ right-scale
+ formulate
+ transition
+ leverage
+ focus on
+ synergize
+ generate
+ analyse
+ integrate
+ empower
+ benchmark
+ learn
+ adapt
+ enable
+ strategize
+ prioritize
+ eak phrases
+ pre-prepare
+ deliver
+ champion
+ embrace
+ enhance
+ engineer
+ envision
+ incentivize
+ maximize
+ visualize
+ whiteboard
+ institutionalize
+ promote
+ overdeliver
+ right-size
+ rebalance
+ re-imagine
+ influence
+ facilitate
+ drive
+ structure
+ standardize
+ accelerate
+ deepen
+ strengthen
+ broaden
+ enforce
+ establish
+ foster
+ build
+ differentiate
+ take a bite out of
+ table
+ flesh out
+ reach out
+ jump-start
+ co-create
+ capitalize on
+ calibrate
+ re-aggregate
+ articulate
+ iterate
+ reinvest in
+ potentiate
+
+[person-verb-badthing] address
+ identify
+ avoid
+ mitigate
+ minimize
+
+[thing-verb-thing] streamline
+ interact with
+ boost
+ generate
+ impact
+ enhance
+ leverage
+ synergize
+ generate
+ empower
+ enable
+ prioritize
+ transfer
+ drive
+ result in
+ promote
+ influence
+ facilitate
+ aggregate
+ architect
+ cultivate
+ engage
+ structure
+ standardize
+ accelerate
+ deepen
+ strengthen
+ enforce
+ foster
+ turbocharge
+ granularize
+ operationalize
+ reconceptualize
+ iterate
+ revolutionise
+
+[thing-verb-person] motivate
+ target
+ enable
+ drive
+ synergize
+ empower
+ prioritize
+ incentivise
+ inspire
+ transfer
+ promote
+ influence
+ strength
+ energize
+ invigorate
+
+[person-verb-def-ending] streamline the process
+ address the overarching issues
+ benchmark the portfolio
+ manage the cycle
+ figure out where we come from, where we are going to
+ maximize the value
+ execute the strategy
+ think out of the box
+ think differently
+ think across the full value chain
+ loop back
+ conversate
+ go forward together
+ achieve efficiencies
+ deliver
+ stay in the mix
+ stay in the zone
+ evolve
+ exceed expectations
+ develop the plan
+ develop the blue print for execution
+ grow and diversify
+ fuel changes
+ nurture talent
+ cultivate talent
+ make it possible
+ manage the portfolio
+ align resources
+ drive the business forward
+ make things happen
+ stay ahead
+ outperform peers
+ surge ahead
+ manage the downside
+ stay in the wings
+ come to a landing
+ shoot it over
+ move the needle
+ connect the dots
+ connect the dots to the end game
+ reset the benchmark
+ take it offline
+ peel the onion
+ drill down
+ get from here to here
+ do things differently
+ stretch the status quo
+ challenge the status quo
+ challenge established ideas
+ increase customer satisfaction
+ enable customer interaction
+ manage the balance
+ turn every stone
+ drive revenue
+ rise to the challenge
+ keep it on the radar
+ stay on trend
+ hunt the business down
+ push the envelope to the tilt
+ execute on priorities
+ stand out from the crowd
+ make the abstract concrete
+ manage the mix
+ grow
+ accelerate the strategy
+ enhance the strength
+ create long-term value
+ meet the challenges
+ move the progress forward
+ do the right projects
+ do the projects right
+ do more with less
+ build winning teams
+ deliver on commitments
+ execute
+ deliver
+ see around the corner
+ meet the surge
+ celebrate the success
+ circle back
+ action forward
+ move forward
+
+[thing-verb-def-ending] add value
+ deliver maximum impact
+
+[thing-verb-ending] <^4> [thing-verb-thing] [random-article] [thing]
+ <^4> [thing-verb-person] the [person]
+ [thing-verb-def-ending]
+
+[person-verb-ending] <^3> [person-verb-def-ending]
+ [person-verb-badthing] [random-article] [bad-things]
+ [person-verb-thing] [random-article] [thing]
+
+[verbphrase-coll-1] [person-verb-ending]
+ [thing-verb-ending]
+
+pragma prefix-with [verbphrase-coll-1] [faukon]
+pragma suffix-with [verbphrase-coll-1] [eventual-postfix-adverb]
+
+pragma export-rule [verbphrase-coll-1]
+
+[faukon] we need to
+ we've got to
+ the reporting unit should
+ controlling should
+ we must activate the [matrix-or-so] to
+ pursuing the route will enable us to
+ we will go the extra mile to
+ we are working hard to
+ we continue to work tirelessly and diligently to
+ we will execute to
+ we will sharpen our business models to
+
+[proposition] [faukon] [person-verb-ending] [eventual-postfix-adverb]
+ <^3> the [person] [eventual-adverb] [person-verb-ending]
+ <^3> [random-article] [thing] [eventual-adverb] [thing-verb-ending] [eventual-postfix-adverb]
+ [thing] and [thing] [eventual-adverb] [thing-verb-ending] [eventual-postfix-adverb]
+ [thing] , [thing] and [thing] [eventual-adverb] [thing-verb-ending] [eventual-postfix-adverb]
+ there can be no [growth] until we can achieve [random-article] [growth]
+ [thing] challenge us to [person-verb-ending]
+ [thing] is all about [thing]
+ there is no alternative to [thing-atom]
+ the key to [thing-atom-single] is [thing-atom-single]
+
+pragma export-rule [proposition]
+
+[articulate-proposition-1] [articulate-proposition] ; this is why [articulate-proposition]
+ [articulate-proposition] ; nevertheless [articulate-proposition]
+ [articulate-proposition] , whereas [articulate-proposition]
+ [articulate-proposition] , while [articulate-proposition]
+ [articulate-proposition] . In the same time, [articulate-proposition]
+ [articulate-proposition] . As a result, [articulate-proposition]
+ [articulate-proposition] , whilst [articulate-proposition]
+ [articulate-proposition-2]
+
+[articulate-proposition-2] our gut feeling is that [proposition]
+ the point is not merely to [person-verb-ending] . The point is to [person-verb-ending]
+ it's not about [random-article] [thing] . It's about [random-article] [thing]
+ our challenge is not to [person-verb-ending] . Our challenge is to [person-verb-ending]
+ going forward, [proposition]
+ actually, [proposition]
+
+[articulate-proposition] <^8> [proposition]
+ [articulate-proposition-1]
+
+pragma export-rule [articulate-proposition]
+
+[sentence] [articulate-proposition] .
+
+pragma export-rule [sentence]
-[boss] → [boss-managing] [boss-age] [boss-exec] [boss-title] of
-[boss-department]
- [boss-groupal] Chief [boss-departmentrole] [boss-catalyst]
+[sentences] <^2> <&1..4> [sentence]
+ <^4> <&4..8> [sentence]
+ <&8..12> [sentence]
+pragma export-rule [sentences]
+pragma initial-rule [sentences]
diff --git a/data/new-sample-grammars/drakensang/armor.gram b/data/new-sample-grammars/drakensang/armor.gram
index d559761..b36d93c 100644
--- a/data/new-sample-grammars/drakensang/armor.gram
+++ b/data/new-sample-grammars/drakensang/armor.gram
@@ -5,9 +5,7 @@
pragma initial-rule [ds-armor]
[dragonknight-armor] [dragonknight-armortype]
- [dragonknight-armorprefix] [dragonknight-armortype]
- [dragonknight-armorprefix] [dragonknight-armortype]
- [dragonknight-armorprefix] [dragonknight-armortype]
+ <^3> [dragonknight-armorprefix] [dragonknight-armortype]
[dragonknight-armortype] jackboots
cloak
@@ -41,9 +39,7 @@ pragma initial-rule [ds-armor]
obsidian steel
[ranger-armor] [ranger-armortype]
- [ranger-armorprefix] [ranger-armortype]
- [ranger-armorprefix] [ranger-armortype]
- [ranger-armorprefix] [ranger-armortype]
+ <^3> [ranger-armorprefix] [ranger-armortype]
[ranger-armortype] shoes
shirt
@@ -65,20 +61,16 @@ pragma initial-rule [ds-armor]
mitts
jerkin
-[ranger-armorprefix] [ranger-armorprefix-1]
- [ranger-armormaterial]
- [ranger-armorprefix-combo]
+[ranger-armorprefix] {empty}
+
+pragma prefix-with [ranger-armorprefix] [ranger-armormaterial] [ranger-armorprefix-1]
+pragma prefix-with [ranger-armorprefix] [ranger-armorprefix-prefix]
[ranger-armorprefix-prefix] grim
fearsome
spirit
cave
-pragma prefix-with [ranger-armorprefix] [ranger-armorprefix-prefix]
-
-[ranger-armorprefix-combo] [ranger-armormaterial] [ranger-armorprefix-1]
- [ranger-armorprefix-1] [ranger-armormaterial]
-
[ranger-armorprefix-1] stalkers
hunters
wolf
@@ -102,9 +94,7 @@ pragma prefix-with [ranger-armorprefix] [ranger-armorprefix-prefix]
sunleather
[spellweaver-armor] [spellweaver-armortype]
- [spellweaver-armorprefix] [spellweaver-armortype]
- [spellweaver-armorprefix] [spellweaver-armortype]
- [spellweaver-armorprefix] [spellweaver-armortype]
+ <^3> [spellweaver-armorprefix] [spellweaver-armortype]
[spellweaver-armortype] cloak
gloves
@@ -117,11 +107,9 @@ pragma prefix-with [ranger-armorprefix] [ranger-armorprefix-prefix]
fist
mask
-[spellweaver-armorprefix] [spellweaver-armorprefix-1]
- [spellweaver-armormaterial]
+[spellweaver-armorprefix] {empty}
-[spellweaver-armorprefix-combo] [spellweaver-armormaterial] [spellweaver-armorprefix-1]
- [spellweaver-armorprefix-1] [spellweaver-armormaterial]
+pragma prefix-with [spellweaver-armorprefix] [spellweaver-armormaterial] [spellweaver-armorprefix-1]
[spellweaver-armorprefix-1] apprentice
acolyte
diff --git a/data/new-sample-grammars/drakensang/gems.gram b/data/new-sample-grammars/drakensang/gems.gram
index 655bdcb..8ce0467 100644
--- a/data/new-sample-grammars/drakensang/gems.gram
+++ b/data/new-sample-grammars/drakensang/gems.gram
@@ -1,12 +1,13 @@
-[ds-gem] [gem-type]
- [gem-type]
+[ds-gem] <^2> [gem-type]
[gem-type] of qaizah
[unique-gem]
+pragma prefix-with [ds-gem] [gem-adjective]
+pragma prefix-with [ds-gem] [gem-quality]
+
pragma initial-rule [ds-gem]
-[gem-quality] [gem-quality-normal]
- [gem-quality-normal]
+[gem-quality] <^2> [gem-quality-normal]
[gem-quality-alt]
[gem-quality-normal] flawed
@@ -19,6 +20,7 @@ pragma initial-rule [ds-gem]
royal
[gem-quality-alt] [gem-quality-alt-1]
+ [gem-quality-alt-2]
[gem-quality-alt-1] lesser
cut
@@ -34,9 +36,6 @@ pragma initial-rule [ds-gem]
festive
solstice
-pragma prefix-with [ds-gem] [gem-adjective]
-pragma prefix-with [ds-gem] [gem-quality]
-
[gem-type] ruby
onyx
sapphire
@@ -45,6 +44,9 @@ pragma prefix-with [ds-gem] [gem-quality]
amethyst
peridot
+pragma prefix-with [gem-type] [gem-descr]
+pragma suffix-with [gem-type] [gem-category]
+
[gem-category] gem
jewel
star
@@ -59,24 +61,23 @@ pragma prefix-with [ds-gem] [gem-quality]
fortified
powerful
-pragma prefix-with [gem-type] [gem-descr]
-pragma suffix-with [gem-type] [gem-category]
-
-[unique-gem] [gem-category] of [unique-trail]
- [unique-lead] [gem-category]
- [unique-type]
- [gem-category] of [unique-trail]
- [unique-lead] [gem-category]
- [unique-type]
+[unique-gem] [unique-type]
[gem-category]
-[unique-trail] insight
+pragma suffix-with [unique-gem] [unique-trail]
+pragma prefix-with [unique-gem] [unique-lead]
+
+[unique-trail] of [unique-trail-1]
+
+[unique-trail-1] insight
immunity
rage
acceleration
shadows
willpower
+pragma prefix-with [unique-trail-1] [gem-descr]
+
[unique-lead] solstice
fluorite
shadow
@@ -86,6 +87,4 @@ pragma suffix-with [gem-type] [gem-category]
[unique-type] bloodstone
moonstone
-pragma prefix-with [unique-type] [gem-descr]
-pragma prefix-with [unique-lead] [gem-descr]
-pragma prefix-with [unique-trail] [gem-descr]
+pragma prefix-with [unique-type] [gem-descr] [gem-descr]
diff --git a/data/new-sample-grammars/perchance/meal.gram b/data/new-sample-grammars/perchance/meal.gram
new file mode 100644
index 0000000..fa73c23
--- /dev/null
+++ b/data/new-sample-grammars/perchance/meal.gram
@@ -0,0 +1,33 @@
+[meal] It's a [adjective] dish with [type] [main] .
+ The [adjective] [main] is paired with a [size] serving of [condiment] .
+ A [main] with with a bit of [condiment] and some [adjective] [side] on top .
+
+pragma export-rule [meal]
+
+[adjective] vegan
+ Indonesian
+ Italian
+ delicious
+
+[main] risotto
+ pie
+ stir-fry
+ curry
+
+[side] bowl of rice
+ salad
+ fries
+ fried mushrooms
+ pumpkin soup
+
+[type] a [size] serving of
+ well-cooked
+ unusually fresh
+ roasted
+
+[size] [(small||smol)||(large||hueg)||(tiny||teeny)]
+
+[condiment] <^2> pepper
+ salt
+ chili flakes
+ oregano
diff --git a/data/new-sample-grammars/repinsult.gram b/data/new-sample-grammars/repinsult.gram
index 30ac89d..efc4115 100644..100755
--- a/data/new-sample-grammars/repinsult.gram
+++ b/data/new-sample-grammars/repinsult.gram
@@ -181,16 +181,3 @@ pragma initial-rule [rep-insult]
whacko
wing nut
woman
-
-[rude-scapegoat] → AIDS carriers
- Arabs
- atheists
- Bill Clinton
- Bill
- Billary
- blacks
- baby-killer
- Bush-haters
- Canadians
- Canucks
- Can
diff --git a/data/rpg-tools-cd/wands.gram b/data/rpg-tools-cd/wands.gram
index 2bf7cd8..0acbbd4 100644..100755
--- a/data/rpg-tools-cd/wands.gram
+++ b/data/rpg-tools-cd/wands.gram
@@ -1,21 +1,21 @@
-[wand] a wand
- a [material] wand
- a [wand-tip] wand
+[wand] a [wand-tip] wand
a [material] [wand-tip] wand
+ <^2> [untipped-wand]
+
+[untipped-wand] a wand
+ a [material] wand
-pragma suffix-with [wand] [tipped]
-pragma suffix-with [wand] [ornament]
-pragma suffix-with [wand] [inscription]
+pragma suffix-with [untipped-wand] [tipped]
+pragma suffix-with [wand] [ornament] [inscription]
pragma initial-rule [wand]
-[material]
- ivory
+[material] ivory
glass
ash
bone
- [material-metal]
- [material-wood]
+ <^4> [material-metal]
+ <^4> [material-wood]
[tipped] tipped with a [tip]
@@ -24,9 +24,10 @@ pragma initial-rule [wand]
pragma despace-rule [wand-tip]
[ornament] decorated with [ornaments]
+ adorned with [ornaments]
[inscription] inscribed with [inscriptions]
- with a [inscriptions] inscribed on it
+ with [inscriptions] inscribed on it
[material-wood] teak
ironwood
@@ -54,8 +55,8 @@ pragma despace-rule [wand-tip]
dessicated eye
pentagram
crescent moon
- [tip-jewel]
- [tip-metal]
+ <^4> [tip-jewel]
+ <^4> [tip-metal]
[tip-jewel] diamond
amethyst
@@ -77,16 +78,8 @@ pragma despace-rule [wand-tip]
feathers
glitter
leather braids
- [ornaments-sigils]
- [ornaments-creatures]
- [ornaments-elements]
-
-[ornaments-sigils] lucky charms
- hieroglyphs
- alchemy signs
- holy symbols
- unholy symbols
- arcane sigils
+ <^3> [ornaments-creatures]
+ <^3> [ornaments-elements]
[ornaments-elements] waves
lightning
@@ -97,23 +90,50 @@ pragma despace-rule [wand-tip]
dragons
spiders and insects
-[inscriptions] unreadable
- gnomish
+[inscriptions] [inscribed-sigils]
+
+pragma prefix-with [inscriptions] [inscribed-language]
+
+[inscribed-sigils] lucky charms
+ hieroglyphs
+ alchemy signs
+ holy symbols
+ unholy symbols
+ arcane sigils
+ runes
+ scriptures
+ warnings
+
+[inscribed-language] [inscribed-language-mod]
+
+pragma suffix-with [inscribed-language] [inscribed-language-base]
+pragma prefix-with [inscribed-language] [inscribed-mod]
+
+[inscribed-language-base] gnomish
aboleth
- abyssal
aquan
dwarven
draconic
- lost tongue
sphinx
ignan
orcish
elven
dreemspeech
- celestial
- runes
auran
sylvan
terran
- druidic
+
+[inscribed-language-mod] unreadable
+ runic
+ script
infernal
+ celestial
+ abyssal
+ draconic
+ druidic
+
+[inscribed-mod] ancient
+ faint
+ illegible
+ glowing
+ eldritch
diff --git a/data/sample-grammars/24hr-rpg.gram b/data/sample-grammars/24hr-rpg.gram
index e372256..484aa17 100755
--- a/data/sample-grammars/24hr-rpg.gram
+++ b/data/sample-grammars/24hr-rpg.gram
@@ -1,9 +1,11 @@
-[rpg-name] → [rpg-part] , [rpg-part] and [rpg-part]
- [rpg-part] and [rpg-part]
- [rpg-part] / [rpg-part]
- [rpg-part] the [rpg-part]
- [rpg-part] : [rpg-part] the [rpg-part]
- [rpg-part] : [rpg-part] [rpg-part]
+[rpg-name] {@rpgparts:=[rpg-part]} [act-rpg-name]
+
+[act-rpg-name] [@rpgparts] and [@rpgparts]
+ [@rpgparts] / [@rpgparts]
+ [@rpgparts] the [@rpgparts]
+ [@rpgparts] : [@rpgparts] the [@rpgparts]
+ [@rpgparts] : [@rpgparts] [@rpgparts]
+ [@rpgparts] , [@rpgparts] and [@rpgparts]
[rpg-name-phrase] [quote-rpg-name] was just released
[quote-rpg-name] vs [quote-rpg-name] : which is better?
@@ -15,201 +17,201 @@
pragma initial-rule [rpg-name-phrase]
pragma export-rule [rpg-name]
-[rpg-part] → tits
- teeth
- claws
- fluff
- crunch
- tools
- guns
- treachery
- post-apocalyptic
- underwater
- terror
- fast food
- military
- fortress
- pirates
- metalhead
- genies
- insects
- environmentalism
- voodoo
- pitchforks
- inventors
- bomb technicians
- zombies
- vampires
- the 70s
- ninjas
- cards
- rebellion
- cannibals
- beast men
- dancing
- monty python
- energy crisis
- orchestra
- summer
- trolls
- medical
- time manipulation
- hitchhiking
- meteors
- the meaning of life
- literary figures
- wrestlers
- tournament
- imaginary friends
- world leaders
- exploration
- fish
- gods
- trading
- rap battles
- creation
- blurring boundaries
- animals
- bounty hunters
- organized crime
- high school
- cybernetics
- aliens
- contemporary world
- urban fantasy
- Nazis
- robots
- surfers
- gentlemen
- haberdashery
- zeppelins
- demons
- rapscallions
- memory loss
- repetition
- martial arts
- conquistadors
- winter
- mummies
- orcs
- reinterpreted myths
- machinery
- harmony
- motorcycles
- horses
- limited time
- ancient
- sleepovers
- submarines
- ambition
- colors
- marshmallows
- the 90s
- neckbeards
- unicorns
- clothing
- hunting
- world war I
- trees
- magical girls
- game show
- dragons
- recursion
- musicians
- construction
- plants
- cats
- drugs
- surgery
- politics
- cartoons
- athletics
- disease
- computers
- cowboys
- cars
- cooking
- samurai
- spaceships
- dinosaurs
- candy
- krakens
- chainsaws
- fists
- crowbars
- lava
- elf
- emperor
- loch ness monster
- knights
- celebrities
- video games
- elves
- the 2000s
- rush hour traffic
- spandex
- stand-up comedy
- nano-machines
- mutation
- dice
- soft drinks
- labyrinth
- totalitarianism
- prostitutes
- cell phones
- death
- the line at the DMV
- office
- mars
- the sun
- survival
- autumn
- portals
- world war II
- the internet
- brewing
- alternate universe
- tanks
- jewelry
- marketplace
- dungeon building
- business
- coins
- crustaceans
- plumbing
- parasites
- rockets
- electricity
- speed
- reincarnation
- theatrics
- storm chasers
- curiosity
- horror
- tragedy
- big damn heroes
- SCIENCE!
- transhumanism
- spring
- scandal
- desert
- laboratory
- hipsters
- obscure
- dwarves
- outer space
- trains
- religion
- espionage
- small scale
- unicycles
- airplanes
- werewolves
- fashion
- JUSTICE!
- suburbs
- art
- skies
- madness
- economy
- the 60s
+[rpg-part] Tits
+ Teeth
+ Claws
+ Fluff
+ Crunch
+ Tools
+ Guns
+ Treachery
+ Post-Apocalyptic
+ Underwater
+ Terror
+ Fast Food
+ Military
+ Fortress
+ Pirates
+ Metalhead
+ Genies
+ Insects
+ Environmentalism
+ Voodoo
+ Pitchforks
+ Inventors
+ Bomb Technicians
+ Zombies
+ Vampires
+ The 70s
+ Ninjas
+ Cards
+ Rebellion
+ Cannibals
+ Beast Men
+ Dancing
+ Monty Python
+ Energy Crisis
+ Orchestra
+ Summer
+ Trolls
+ Medical
+ Time Manipulation
+ Hitchhiking
+ Meteors
+ The Meaning Of Life
+ Literary Figures
+ Wrestlers
+ Tournament
+ Imaginary Friends
+ World Leaders
+ Exploration
+ Fish
+ Gods
+ Trading
+ Rap Battles
+ Creation
+ Blurring Boundaries
+ Animals
+ Bounty Hunters
+ Organized Crime
+ High School
+ Cybernetics
+ Aliens
+ Contemporary World
+ Urban Fantasy
+ Nazis
+ Robots
+ Surfers
+ Gentlemen
+ Haberdashery
+ Zeppelins
+ Demons
+ Rapscallions
+ Memory Loss
+ Repetition
+ Martial Arts
+ Conquistadors
+ Winter
+ Mummies
+ Orcs
+ Reinterpreted Myths
+ Machinery
+ Harmony
+ Motorcycles
+ Horses
+ Limited Time
+ Ancient
+ Sleepovers
+ Submarines
+ Ambition
+ Colors
+ Marshmallows
+ The 90s
+ Neckbeards
+ Unicorns
+ Clothing
+ Hunting
+ World War I
+ Trees
+ Magical Girls
+ Game Show
+ Dragons
+ Recursion
+ Musicians
+ Construction
+ Plants
+ Cats
+ Drugs
+ Surgery
+ Politics
+ Cartoons
+ Athletics
+ Disease
+ Computers
+ Cowboys
+ Cars
+ Cooking
+ Samurai
+ Spaceships
+ Dinosaurs
+ Candy
+ Krakens
+ Chainsaws
+ Fists
+ Crowbars
+ Lava
+ Elf
+ Emperor
+ Loch Ness Monster
+ Knights
+ Celebrities
+ Video Games
+ Elves
+ The 2000s
+ Rush Hour Traffic
+ Spandex
+ Stand-Up Comedy
+ Nano-Machines
+ Mutation
+ Dice
+ Soft Drinks
+ Labyrinth
+ Totalitarianism
+ Prostitutes
+ Cell Phones
+ Death
+ The Line At The DMV
+ Office
+ Mars
+ The Sun
+ Survival
+ Autumn
+ Portals
+ World War II
+ The Internet
+ Brewing
+ Alternate Universe
+ Tanks
+ Jewelry
+ Marketplace
+ Dungeon Building
+ Business
+ Coins
+ Crustaceans
+ Plumbing
+ Parasites
+ Rockets
+ Electricity
+ Speed
+ Reincarnation
+ Theatrics
+ Storm Chasers
+ Curiosity
+ Horror
+ Tragedy
+ Big Damn Heroes
+ SCIENCE!
+ Transhumanism
+ Spring
+ Scandal
+ Desert
+ Laboratory
+ Hipsters
+ Obscure
+ Dwarves
+ Outer Space
+ Trains
+ Religion
+ Espionage
+ Small Scale
+ Unicycles
+ Airplanes
+ Werewolves
+ Fashion
+ JUSTICE!
+ Suburbs
+ Art
+ Skies
+ Madness
+ Economy
+ The 60s
diff --git a/data/sample-grammars/acronym.gram b/data/sample-grammars/acronym.gram
index ed18cfc..1118732 100644..100755
--- a/data/sample-grammars/acronym.gram
+++ b/data/sample-grammars/acronym.gram
@@ -1,17 +1,16 @@
-[acronym] [acronym-part]
- [acronym-part]
- [acronym-part]
+[acronym] [acronym+1]
+
+[acronym+1] [acronym-phrase]
[acronym-part]
- [acronym-phrase]
pragma initial-rule [acronym]
-pragma despace-rule [acronym]
-
[acronym-phrase] [acronym-part] / [acronym-part]
[acronym-part] - [acronym-part]
-[acronym-part] [join-acronym]
+[acronym-part] [acronym+part]
+
+[acronym+part] [join-acronym]
[dot-acronym]
pragma export-rule [acronym-part]
diff --git a/data/sample-grammars/address.gram b/data/sample-grammars/address.gram
index 44475c4..3ccb738 100644..100755
--- a/data/sample-grammars/address.gram
+++ b/data/sample-grammars/address.gram
@@ -73,30 +73,23 @@ pragma suffix-with [street] [street-suffix]
s.
e.
w.
- [cardinal]
+ <^2> [cardinal]
-[street-suffix] street
- st.
- road
- rd.
+[street-suffix] [street||st.]
+ [road||rd.]
way
- boulevard
- blvd.
- avenue
- ave.
+ [boulevard||blvd.]
+ [avenue||ave.]
place
plaza
court
drive
- highway
- hwy.
- parkway
- pkwy.
+ [highway||hwy.]
+ [parkway||pkwy.]
pike
bypass
-[street-generic] main
- main
+[street-generic] <^2> main
high
independence
division
@@ -128,6 +121,6 @@ pragma suffix-with [street] [street-suffix]
[geographic-thing]
[street-generic-standalone] Broadway
- avenue of the Americas
+ Avenue of the Americas
Kingshighway
El Camino real
diff --git a/data/sample-grammars/anime.gram b/data/sample-grammars/anime.gram
index 85cc7db..887b687 100755
--- a/data/sample-grammars/anime.gram
+++ b/data/sample-grammars/anime.gram
@@ -1,22 +1,23 @@
-[anime-name] [short-anime-name]
- [short-anime-name]
+[anime-name] {@fname:=[first-name]} {@sname:=[second-name]} {@tname:=[third-name]} [act-anime-name]
+
+[act-anime-name] <^2> [short-anime-name]
[long-anime-name]
-[short-anime-name] [first-name]
- [second-name]
- [third-name]
+[short-anime-name] [@fname]
+ [@sname]
+ [@tname]
[long-anime-name] [short-anime-name]
pragma initial-rule [anime-name]
-pragma suffix-with [short-anime-name] [first-name]
-pragma suffix-with [short-anime-name] [second-name]
-pragma suffix-with [short-anime-name] [third-name]
+pragma suffix-with [short-anime-name] [@fname]
+pragma suffix-with [short-anime-name] [@sname]
+pragma suffix-with [short-anime-name] [@tname]
-pragma prefix-with [long-anime-name] [third-name]
-pragma prefix-with [long-anime-name] [second-name]
-pragma prefix-with [long-anime-name] [first-name]
+pragma prefix-with [long-anime-name] [@tname]
+pragma prefix-with [long-anime-name] [@sname]
+pragma prefix-with [long-anime-name] [@fname]
[first-name] Vampire
Cat
diff --git a/data/sample-grammars/art-objects.gram b/data/sample-grammars/art-objects.gram
index c824958..a9ed5af 100755
--- a/data/sample-grammars/art-objects.gram
+++ b/data/sample-grammars/art-objects.gram
@@ -1,24 +1,23 @@
-[art-treasure-group] [art-treasure]
- a choice between [art-treasure] and [art-treasure]
- a choice between [quote-treasure] , [quote-treasure] and [quote-treasure]
- [art-treasure] as well as [art-treasure]
- [quote-treasure] ; [quote-treasure] as well as [quote-treasure]
- [art-treasure] atop [art-treasure]
- [art-treasure] hidden under [art-treasure]
- [art-treasure] lying next to [art-treasure]
- [art-treasure] hiding in [art-treasure]
+[art-treasure-group] {@atreasure:=[art-treasure]} [act-art-treasure-group]
+
+[act-art-treasure-group] <^4> [@atreasure]
+ <^2> a choice between [@atreasure] and [@atreasure]
+ <^2> [@atreasure] as well as [@atreasure]
+ <^2> [@atreasure] atop [@atreasure]
+ <^2> [@atreasure] hidden under [@atreasure]
+ <^2> [@atreasure] lying next to [@atreasure]
+ <^2> [@atreasure] hiding in [@atreasure]
[quote-treasure] hidden among [quote-treasure] and [quote-treasure]
+ [quote-treasure] ; [quote-treasure] as well as [quote-treasure]
+ a choice between [quote-treasure] , [quote-treasure] and [quote-treasure]
pragma initial-rule [art-treasure-group]
-[quote-treasure] ( [art-treasure] )
+[quote-treasure] ( [@atreasure] )
pragma despace-rule [quote-treasure]
-[art-treasure] [unowned-art-treasure]
- [unowned-art-treasure]
- [unowned-art-treasure]
- [unowned-art-treasure]
+[art-treasure] <^4> [unowned-art-treasure]
[owned-art-treasure]
pragma export-rule [art-treasure]
@@ -34,8 +33,7 @@ pragma prefix-with [art-treasure] a(n)
[art-objects] [art-object]
pragma export-rule [art-objects]
-pragma prefix-with [art-objects] [art-object-pref]
-pragma prefix-with [art-objects] [size]
+pragma prefix-with [art-objects] [art-object-pref] [size]
[art-object-pref] counterfeit
ancient
@@ -53,6 +51,7 @@ pragma prefix-with [art-objects] [size]
[epic-art]
[mythic-art]
+pragma enable-descent [art-object] 2
pragma export-rule [art-object]
[size] tiny
@@ -74,7 +73,7 @@ pragma export-rule [art-object]
[statuette-mat] bone
ivory
-[common-goldring] gold ring
+[common-goldring] <^2> gold ring
gold ring with a [common-gem]
gold ring with [common-gem] inlay
gold ring with [common-gem] setting
@@ -83,16 +82,13 @@ pragma export-rule [art-object]
[necklace-mat] necklace
gold bracelet studded with [rare-gem]
gold necklace adorned with [common-gem]
- silver [tiaracrown] decorated with [common-gem]
+ silver [tiara||crown] decorated with [common-gem]
ivory comb with embedded [rare-gem]
gold vestments
[necklace-mat] gold
silver
-[tiaracrown] tiara
- crown
-
[uncommon-goldring] gold ring with [legendary-gem] inlay
gold ring with a [legendary-gem]
gold ring with [legendary-gem] setting
diff --git a/data/sample-grammars/awe-names.gram b/data/sample-grammars/awe-names.gram
index ea27ce1..d15e6b8 100755
--- a/data/sample-grammars/awe-names.gram
+++ b/data/sample-grammars/awe-names.gram
@@ -1,9 +1,9 @@
-[awesome-name] [part]
+[awesome-name] {@parts:=[part]} [act-awesome-name]
-pragma prefix-with [awesome-name] [part]
-pragma prefix-with [awesome-name] [part]
-pragma suffix-with [awesome-name] [part]
-pragma suffix-with [awesome-name] [part]
+[act-awesome-name] [@parts]
+
+pragma prefix-with [act-awesome-name] <&1..2> [@parts]
+pragma suffix-with [act-awesome-name] <&1..2> [@parts]
pragma initial-rule [awesome-name]
diff --git a/data/sample-grammars/buzzword.gram b/data/sample-grammars/buzzword.gram
index d25331f..3aaf2ad 100644..100755
--- a/data/sample-grammars/buzzword.gram
+++ b/data/sample-grammars/buzzword.gram
@@ -1,4 +1,4 @@
-[buzzword-phrase] [buzzwords]
+[buzzword-phrase] <^2> [buzzwords]
[buzzwords] to [buzzwords]
[buzzwords] while [buzzwords]
[buzzwords] in order to [buzzwords]
@@ -6,9 +6,9 @@
pragma initial-rule [buzzword-phrase]
-[buzzwords] [buzzword]
- [buzzword] [buzzword]
- [buzzword] and [buzzword]
+[buzzwords] <^4> [buzzword]
+ <^2> [buzzword] [buzzword]
+ <^2> [buzzword] and [buzzword]
[buzzword] , [buzzword] and [buzzword]
pragma export-rule [buzzwords]
diff --git a/data/sample-grammars/career.gram b/data/sample-grammars/career.gram
index 63142f5..3f527be 100644..100755
--- a/data/sample-grammars/career.gram
+++ b/data/sample-grammars/career.gram
@@ -4,9 +4,7 @@ pragma initial-rule [career-tech-desc]
pragma prefix-with [career-tech-desc] [career-tech-desc-pref]
-pragma suffix-with [career-tech-desc] [career-tech-descsuff]
-pragma suffix-with [career-tech-desc] [career-tech-descsuff]
-pragma suffix-with [career-tech-desc] [career-tech-descsuff]
+pragma suffix-with [career-tech-desc] <&1..2> [career-tech-descsuff]
[career-tech-desc-pref] [career-prefsuf] of the
@@ -22,13 +20,8 @@ pragma suffix-with [career-tech-desc] [career-tech-descsuff]
pragma export-rule [career-techname]
-[career-tech] [career-tech2]
- [career-tech2]
- [career-tech2]
- [career-tech2]
- [career-tech2]
- [career-tech2]
- [quote-career-tech] and [quote-career-tech]
+[career-tech] <^6> [career-tech2]
+ <^3> [quote-career-tech] and [quote-career-tech]
[quote-career-tech] , [quote-career-tech] and [quote-career-tech]
pragma prefix-with [career-tech] [career-tech-desc-pref]
@@ -39,7 +32,8 @@ pragma export-rule [career-tech]
pragma despace-rule [quote-career-tech]
-[career-tech2] [act-career-tech] (reports to the [career-tech] )
+[career-tech2] <^10> [act-career-tech]
+ [act-career-tech] (reports to the [career-tech] )
[act-career-tech] (reports to [full-name-and-title] )
[act-career-tech] paper pusher
@@ -87,7 +81,7 @@ pragma export-rule [act-career-tech]
publisher
publishing
-[career-prefsuf] [career-suffix]
+[career-prefsuf] <^2> [career-suffix]
[career-prefix] [career-suffix]
[career-sufsuf] , [career-prefsuf] of [career-department]
diff --git a/data/sample-grammars/city.gram b/data/sample-grammars/city.gram
index b344d3b..f4a765c 100644..100755
--- a/data/sample-grammars/city.gram
+++ b/data/sample-grammars/city.gram
@@ -31,17 +31,17 @@ pragma despace-rule [act-other-city]
[first-name]
[random-name]
-[town-prefix] [cardinal]
- new
- new
- old
- little
- fort
- lower
- upper
- san
- la
- van
+[town-prefix] <^2> [cardinal]
+ New
+ New
+ Old
+ Little
+ Fort
+ Lower
+ Upper
+ San
+ La
+ Van
[town-suffix] burg
ton
diff --git a/data/sample-grammars/college.gram b/data/sample-grammars/college.gram
index 33b45e3..65b7cb6 100644..100755
--- a/data/sample-grammars/college.gram
+++ b/data/sample-grammars/college.gram
@@ -15,13 +15,11 @@ pragma initial-rule [college-announcement]
[students] students
-pragma prefix-with [students] [course-level]
-pragma prefix-with [students] [course-adj]
+pragma prefix-with [students] [course-level] [course-adj]
[student] student
-pragma prefix-with [student] [course-level]
-pragma prefix-with [student] [course-adj]
+pragma prefix-with [student] [course-level] [course-adj]
[popularity] popularity
popularity among [students]
@@ -122,8 +120,7 @@ pragma suffix-with [course-level1] [class-year]
[course-event] as [course-explored] in [course-group] [course-medium]
[university-subject] as [course-explored] in [course-group] [course-medium]
[course-impactof]
- [course-static]
- [course-static]
+ <^2> [course-static]
[quote-buzzword] ( [course-buzzword2] )
@@ -133,24 +130,22 @@ pragma prefix-with [college-course] [course-prefix]
[course-colonending] : [course-ending]
-pragma suffix-with [college-course] [course-colonending]
-pragma suffix-with [college-course] [course-suffix]
+pragma suffix-with [college-course] [course-colonending] [course-suffix]
pragma export-rule [college-course]
-[course-adjnoun-group] [quote-adjnoun]
- [quote-adjnoun] and [quote-adjnoun]
+[course-adjnoun-group] <^4> [quote-adjnoun]
+ <^2> [quote-adjnoun] and [quote-adjnoun]
[quote-adjnoun] , [quote-adjnoun] and [quote-adjnoun]
-[course-disjoin-adjnoungroup] [quote-adjnoun] or [quote-adjnoun]
+[course-disjoin-adjnoungroup] <^2> [quote-adjnoun] or [quote-adjnoun]
[quote-adjnoun] , [quote-adjnoun] or [quote-adjnoun]
[quote-adjnoun] ( [course-adjnoun] )
[course-adjnoun] [course-prefixednoun]
-pragma prefix-with [course-adjnoun] [course-adj]
-pragma prefix-with [course-adjnoun] [course-adj]
+pragma prefix-with [course-adjnoun] [course-adj] [course-adj]
[condition] condition
experience
@@ -244,7 +239,7 @@ pragma prefix-with [course-adjnoun] [course-adj]
[experience] arts
experience
-[course-prefixednoun] [course-noun]
+[course-prefixednoun] <^2> [course-noun]
post- [course-noun]
pre- [course-noun]
@@ -386,10 +381,7 @@ pragma prefix-with [course-noun] [course-nounprefix]
[study] study
approach
-[course-group] [quote-groups]
- [quote-groups]
- [quote-groups]
- [quote-groups]
+[course-group] <^4> [quote-groups]
[quote-political]
[quote-political] " [org-political] "
@@ -495,8 +487,8 @@ pragma suffix-with [of-group] [course-adjnoun]
[course-life-influence] [course-event]
[course-adjnoun-group]
-[course-lives] [quote-life]
- [quote-life] and [quote-life]
+[course-lives] <^4> [quote-life]
+ <^2> [quote-life] and [quote-life]
[quote-life] , [quote-life] and [quote-life]
[quote-life] ( [course-life] )
diff --git a/data/sample-grammars/company.gram b/data/sample-grammars/company.gram
index 40ea83b..10befff 100644..100755
--- a/data/sample-grammars/company.gram
+++ b/data/sample-grammars/company.gram
@@ -43,15 +43,12 @@ pragma despace-rule [company-root-city]
pragma despace-rule [company-root-name]
-[letter+group] [letters]
- [letters] & [letters]
+[letter+group] <^4> [letters]
+ <^2> [letters] & [letters]
[letters] & [letters] & [letters]
-[letters] [letter]
- [letter]
- [letter]
- [letter] [letter]
- [letter] [letter]
+[letters] <^3> [letter]
+ <^2> [letter] [letter]
[letter] [letter] [letter]
pragma despace-rule [letters]
diff --git a/data/sample-grammars/computer.gram b/data/sample-grammars/computer.gram
index a3a7814..3a86e73 100644..100755
--- a/data/sample-grammars/computer.gram
+++ b/data/sample-grammars/computer.gram
@@ -29,8 +29,7 @@
apl
k
opencomal
- [esoteric-language]
- [esoteric-language]
+ <^2> [esoteric-language]
[esoteric-language] magenta
brainfuck
@@ -39,7 +38,6 @@
malbolge
pragma export-rule [computer-language]
-pragma export-rule [computer-skill]
[computer-skill] html
xml
@@ -51,3 +49,5 @@ pragma export-rule [computer-skill]
sql
asp
php
+
+pragma export-rule [computer-skill]
diff --git a/data/sample-grammars/congress.gram b/data/sample-grammars/congress.gram
index cffe469..cffe469 100644..100755
--- a/data/sample-grammars/congress.gram
+++ b/data/sample-grammars/congress.gram
diff --git a/data/sample-grammars/dates.gram b/data/sample-grammars/dates.gram
index 1ed0daa..1ed0daa 100644..100755
--- a/data/sample-grammars/dates.gram
+++ b/data/sample-grammars/dates.gram
diff --git a/data/sample-grammars/diablo-ii/diabloii.gram b/data/sample-grammars/diablo-ii/diabloii.gram
index df45482..2fcdf24 100755
--- a/data/sample-grammars/diablo-ii/diabloii.gram
+++ b/data/sample-grammars/diablo-ii/diabloii.gram
@@ -1,6 +1,6 @@
-[base-treasures] [base-treasure]
- [quote-treasure] as well as [quote-treasure]
- [quote-treasure] or [quote-treasure]
+[base-treasures] <^4> [base-treasure]
+ <^2> [quote-treasure] as well as [quote-treasure]
+ <^2> [quote-treasure] or [quote-treasure]
[quote-treasure] , and [quote-treasure] as well as [quote-treasure]
[quote-treasure] , [quote-treasure] or [quote-treasure]
@@ -10,29 +10,28 @@ pragma initial-rule [base-treasures]
pragma despace-rule [quote-treasure]
-[base-treasure] a [item]
- a [item]
- a [item]
+[base-treasure] <^3> a [item]
[non-item]
-[non-item] [money]
- [money]
- [money]
- [money]
+[non-item] <^4> [money]
nothing
[money] [diablo-amount] [money-type]
-[diablo-amount] 1
+[diablo-amount] 2
5
10
20
50
+ 50
100
200
500
1000
+# Try to advance with a two out of three chance, 10 attempts
+pragma enable-binomial [diablo-amount] 2 3 10
+
pragma export-rule [diablo-amount]
[money-type] coins
@@ -44,18 +43,14 @@ pragma prefix-with [money-type] [metal-type]
gold
platinum
-[item] [item-types]
- [item-types]
- [item-types]
- [item-types]
- [item-types] [d2-suffix]
- [item-types] [d2-suffix]
- [d2-prefix] [item-types]
- [d2-prefix] [item-types]
+pragma enable-descent [metal-type] 2
+
+[item] <^4> [item-types]
+ <^2> [item-types] [d2-suffix]
+ <^2> [d2-prefix] [item-types]
[d2-prefix] [item-types] [d2-suffix]
-[item-types] [d2-item-type]
- [d2-item-type]
+[item-types] <^2> [d2-item-type]
[ds-items]
[^item]
diff --git a/data/sample-grammars/diablo-ii/diabloiiitems.gram b/data/sample-grammars/diablo-ii/diabloiiitems.gram
index 5fa174b..e638f99 100755
--- a/data/sample-grammars/diablo-ii/diabloiiitems.gram
+++ b/data/sample-grammars/diablo-ii/diabloiiitems.gram
@@ -129,6 +129,7 @@ pragma prefix-with [clubs] [club-prefix]
[club-prefix] spiked
war
+ dire
[spears] javelin
spear
@@ -160,12 +161,9 @@ pragma prefix-with [axes] [axe-size]
hand
[bows] [act-arrow] [quote-count]
- [act-bow]
- [act-bow]
- [act-bow]
- [act-bow]
+ <^4> [act-bow]
-[act-arrow] arrow
+[act-arrow] <^2> arrow
[gem-type] -tipped arrow
[act-bow] bow
@@ -182,12 +180,9 @@ pragma prefix-with [act-bow] [bow-size]
war
[crossbows] [act-bolt] [quote-count]
- [act-crossbow]
- [act-crossbow]
- [act-crossbow]
- [act-crossbow]
+ <^4> [act-crossbow]
-[act-bolt] bolt
+[act-bolt] <^2> bolt
[gem-type] -tipped bolt
[act-crossbow] crossbow
@@ -213,8 +208,7 @@ pragma prefix-with [wands] [wand-type]
[staves] staff
-pragma prefix-with [staves] [staff-type]
-pragma prefix-with [staves] [tree]
+pragma prefix-with [staves] [staff-type] [tree]
pragma prefix-with [staves] [staff-length]
[staff-type] gnarled
@@ -223,6 +217,7 @@ pragma prefix-with [staves] [staff-length]
war
[staff-length] short
+ full
long
[accessories] charm
@@ -233,8 +228,7 @@ pragma prefix-with [staves] [staff-length]
[gems] [gem-type]
-pragma prefix-with [gems] [gem-size]
-pragma prefix-with [gems] [gem-quality]
+pragma prefix-with [gems] [gem-size] [gem-quality]
[gem-quality] chipped
flawed
@@ -258,5 +252,3 @@ pragma prefix-with [gems] [gem-quality]
book
[quote-count] ( [diablo-amount] count )
-
-pragma despace-rule [quote-count]
diff --git a/data/sample-grammars/diablo-ii/diabloiiperish.gram b/data/sample-grammars/diablo-ii/diabloiiperish.gram
index af6c9ec..9338b9c 100755
--- a/data/sample-grammars/diablo-ii/diabloiiperish.gram
+++ b/data/sample-grammars/diablo-ii/diabloiiperish.gram
@@ -39,10 +39,7 @@ pragma prefix-with [perishable-type] [bodypart]
medium
full
-[perishable-effect] [perishable-effect-1]
- [perishable-effect-1]
- [perishable-effect-1]
- [perishable-effect-1]
+[perishable-effect] <^4> [perishable-effect-1]
[perishable-degree] [perishable-effect-1]
[perishable-effect-1] [restore-effect]
diff --git a/data/sample-grammars/diablo-ii/diabloiiprefixes.gram b/data/sample-grammars/diablo-ii/diabloiiprefixes.gram
index 5157115..1a62829 100755
--- a/data/sample-grammars/diablo-ii/diabloiiprefixes.gram
+++ b/data/sample-grammars/diablo-ii/diabloiiprefixes.gram
@@ -1,15 +1,10 @@
-[d2-prefix] [d2-prefix-part]
- [d2-prefix-part]
- [d2-prefix-chain]
+[d2-prefix] <^4> [d2-prefix-part]
+ <^2> [d2-prefix-part] [d2-prefix-part]
+ <^2> [d2-prefix-part] and [d2-prefix-part]
+ [d2-prefix-part] [d2-prefix-part] [d2-prefix-part]
pragma export-rule [d2-prefix]
-[d2-prefix-chain] [d2-prefix-part] [d2-prefix-part]
- [d2-prefix-part] [d2-prefix-part]
- [d2-prefix-part] and [d2-prefix-part]
- [d2-prefix-part] and [d2-prefix-part]
- [d2-prefix-part] [d2-prefix-part] [d2-prefix-part]
-
[d2-prefix-part] [armor-class]
[saving-throw]
[foe-reaction]
diff --git a/data/sample-grammars/diablo-ii/diabloiisuffixes.gram b/data/sample-grammars/diablo-ii/diabloiisuffixes.gram
index f6deea0..7915f9d 100755
--- a/data/sample-grammars/diablo-ii/diabloiisuffixes.gram
+++ b/data/sample-grammars/diablo-ii/diabloiisuffixes.gram
@@ -1,11 +1,6 @@
-[d2-suffix] of [suffix-part]
- of [suffix-part]
- of [suffix-chain]
-
-[suffix-chain] [suffix-part] and [suffix-part]
- [suffix-part] and [suffix-part]
- [suffix-part] and of [suffix-part]
- [suffix-part] and of [suffix-part]
+[d2-suffix] <^4> of [suffix-part]
+ <^2> [suffix-part] and [suffix-part]
+ <^2> [suffix-part] and of [suffix-part]
[suffix-part] , [suffix-part] and [suffix-part]
pragma export-rule [d2-suffix]
diff --git a/data/sample-grammars/dungeondressing/abandoned.gram b/data/sample-grammars/dungeondressing/abandoned.gram
index c9ed653..aecbee4 100644..100755
--- a/data/sample-grammars/dungeondressing/abandoned.gram
+++ b/data/sample-grammars/dungeondressing/abandoned.gram
@@ -1,4 +1,4 @@
-[abandoned] while exploring the abandoned [abandon-place] , a [abandon-person] sneaks up on you [abandon-motion] .
+[abandoned] while exploring the [{empty}||abandoned] [abandon-place] , a [abandon-person] sneaks up on you [abandon-motion] .
pragma initial-rule [abandoned]
diff --git a/data/sample-grammars/dungeondressing/bedroom.gram b/data/sample-grammars/dungeondressing/bedroom.gram
index 8bb9449..1f182c5 100644..100755
--- a/data/sample-grammars/dungeondressing/bedroom.gram
+++ b/data/sample-grammars/dungeondressing/bedroom.gram
@@ -13,9 +13,7 @@ pragma initial-rule [bedroom]
deserted clearing
desert island
abandoned crypt
- [fantasy-location-name]
- [fantasy-location-name]
- [fantasy-location-name]
+ <^3> [fantasy-location-name]
[bedroom-bed] king bed with luxury sheets
messy pile of wet hay
@@ -26,8 +24,7 @@ pragma initial-rule [bedroom]
tropical rope hammock
altar
-pragma prefix-with [bedroom-bed] [bed-prefix]
-pragma prefix-with [bedroom-bed] [sacred-type]
+pragma prefix-with [bedroom-bed] [bed-prefix] [sacred-type]
[bed-prefix] ruined
ancient
@@ -46,21 +43,11 @@ pragma prefix-with [bedroom-bed] [sacred-type]
infernal
angelic
-[bedroom-person] [bed-bones]
- [bed-bones]
+[bedroom-person] <^2> [bed-bones]
jug of moonshine
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
- [bed-aliveperson]
-
-[bedroom-lying] lying [onin] it
+ <^8> [bed-aliveperson]
+
+[bedroom-lying] lying [on||in] it
draped atop it
prostrated before it
[tied] to it
@@ -84,17 +71,13 @@ pragma prefix-with [bed-aliveperson] [bed-name]
[bed-name] [full-name] , a(n)
[fantasy-name] , a(n)
-[bed-status] [bed-status1]
- [bed-status2]
- [bed-status1] [bed-status2]
- [bed-status2] [bed-status1]
+[bed-status] {empty}
+
+pragma prefix-with [bed-status] [bed-status1] [bed-status2]
[bed-status1] dead
decapitated
- [status-alive]
- [status-alive]
- [status-alive]
- [status-alive]
+ <^4> [status-alive]
[status-alive] unconcious
sleeping
@@ -119,13 +102,8 @@ pragma prefix-with [bed-aliveperson] [bed-name]
roped
shackled
-[onin] on
- in
-
-[bed-bones] [pile] of [bone-status] [bones]
- [pile] of [bone-status] [bones]
- [pile] of [bone-status] [part-human] [bones]
- [pile] of [bone-status] [part-human] [bones]
+[bed-bones] <^2> [pile] of [bone-status] [bones]
+ <^2> [pile] of [bone-status] [part-human] [bones]
[blood-puddle]
[pile] pair
@@ -187,11 +165,7 @@ pragma prefix-with [bed-arist] kidnapped
mannequin
puppet
-pragma prefix-with [bed-doll] [sex]
-pragma prefix-with [bed-doll] [realism]
-
-[sex] sex
- sexy
+pragma prefix-with [bed-doll] [sex||sexy] [realism]
[realism] realistic
unrealistic
@@ -224,20 +198,18 @@ pragma prefix-with [bed-slave] [part-human]
[bed-gender] male
female
-[part-human] [humanoids]
- [part-human2]
+[part-human] <^4> [humanoids]
+ <^2> [half-humans]
+ [quarter-humans]
pragma prefix-with [part-human] [bed-gender]
-[part-human2] [half-humans]
- [quarter-humans]
-
-[half-humans] [half-human]
+[half-humans] <^2> [half-human]
[half-human] , [half-human]
-[quarter-humans] [quarter-human]
- [quarter-human] , [half-human]
- [quarter-human] , [quarter-human]
+[quarter-humans] <^4> [quarter-human]
+ <^2> [quarter-human] , [half-human]
+ <^2> [quarter-human] , [quarter-human]
[quarter-human] , [quarter-human] , [quarter-human]
[quarter-human] , [quarter-human] , [quarter-human] , [quarter-human]
@@ -245,10 +217,7 @@ pragma prefix-with [part-human] [bed-gender]
[quarter-human] quarter- [humanoids]
-[humanoids] [humanoid]
- [humanoid]
- [humanoid]
- [humanoid]
+[humanoids] <^4> [humanoid]
[bed-inhuman]
pragma despace-rule [half-human]
diff --git a/data/sample-grammars/dungeondressing/dragonencounter.gram b/data/sample-grammars/dungeondressing/dragonencounter.gram
index 5c299c3..5c299c3 100644..100755
--- a/data/sample-grammars/dungeondressing/dragonencounter.gram
+++ b/data/sample-grammars/dungeondressing/dragonencounter.gram
diff --git a/data/sample-grammars/dungeondressing/kitchen.gram b/data/sample-grammars/dungeondressing/kitchen.gram
index 23abda4..23abda4 100644..100755
--- a/data/sample-grammars/dungeondressing/kitchen.gram
+++ b/data/sample-grammars/dungeondressing/kitchen.gram
diff --git a/data/sample-grammars/dungeondressing/monster.gram b/data/sample-grammars/dungeondressing/monster.gram
index 47e1417..d3a793e 100644..100755
--- a/data/sample-grammars/dungeondressing/monster.gram
+++ b/data/sample-grammars/dungeondressing/monster.gram
@@ -1,12 +1,17 @@
-[monster] [monster-kind]
+[monster] <^2> [monster-kind]
[monster-prefix] [monster-kind]
pragma initial-rule [monster]
-[monster-prefix] were-
+[monster-prefix] [monster-prefix-tail]
+
+pragma prefix-with [monster-prefix] <&1..3> [monster-prefix-head]
+
+[monster-prefix-tail] were-
half-
quarter-
- vampire
+
+[monster-prefix-head] vampire
giant
diseased
magic
diff --git a/data/sample-grammars/eastern-sun/easternsunsocketing.gram b/data/sample-grammars/eastern-sun/easternsunsocketing.gram
index 3585220..5041177 100644
--- a/data/sample-grammars/eastern-sun/easternsunsocketing.gram
+++ b/data/sample-grammars/eastern-sun/easternsunsocketing.gram
@@ -1,5 +1,4 @@
-[es-socketable] [es-gem]
- [es-gem]
+[es-socketable] <^2> [es-gem]
[es-rune]
[gem-quality] chipped
@@ -9,7 +8,7 @@
extraordinary
perfect
-[es-gem] [gem-1
+[es-gem] [gem-1]
[gem-1]
[gem-2]
[gem-2]
diff --git a/data/sample-grammars/elementals.gram b/data/sample-grammars/elementals.gram
index 30d256f..511f0ec 100644..100755
--- a/data/sample-grammars/elementals.gram
+++ b/data/sample-grammars/elementals.gram
@@ -1,12 +1,9 @@
-[elemental] elemental
- elemental
- elemental
+[elemental] <^3> elemental
[other-elementalcreatures]
[rs-elementype]
pragma prefix-with [elemental] [elemental-types]
-pragma prefix-with [elemental] [elemental-age]
-pragma prefix-with [elemental] [great-less]
+pragma prefix-with [elemental] [elemental-age] [great-less]
pragma suffix-with [elemental] [sgreat-less]
pragma initial-rule [elemental]
@@ -57,22 +54,16 @@ pragma initial-rule [elemental]
primal
eldritch
-[elemental-types] [nhelemental-types]
- [nhelemental-types]
- [nhelemental-types]
- [nhelemental-types]
- [nhelemental-types]
- [nhelemental-types]
+[elemental-types] <^6> [nhelemental-types]
[hybrid-type]
-[nhelemental-types] [quote-type]
- [quote-type]
- [quote-type] / [quote-type]
+[nhelemental-types] <^4> [quote-type]
+ <^2> [quote-type] / [quote-type]
[quote-type] / [quote-type] / [nhelemental-types]
pragma export-rule [elemental-types]
-[hybrid-type] hybrid [hybrid-open] and [hybrid-close]
+[hybrid-type] <^2> hybrid [hybrid-open] and [hybrid-close]
hybrid [hybrid-open] , [nhelemental-types] and [hybrid-close]
[hybrid-open] ( [nhelemental-types]
@@ -87,20 +78,13 @@ pragma despace-rule [hybrid-close]
pragma despace-rule [quote-type]
-[elemental-type] [bare-elemental-type]
- [bare-elemental-type]
- [bare-elemental-type]
- [bare-elemental-type]
- [elemental-adv] [bare-elemental-type]
- [elemental-adv] [bare-elemental-type]
+[elemental-type] <^4> [bare-elemental-type]
+ <^2> [elemental-adv] [bare-elemental-type]
[elemental-adv] [elemental-adv] [bare-elemental-type]
-[bare-elemental-type] [common-element]
- [common-element]
- [runescape-elemental]
- [runescape-elemental]
- [paraquasi-elemental]
- [paraquasi-elemental]
+[bare-elemental-type] <^2> [common-element]
+ <^2> [runescape-elemental]
+ <^2> [paraquasi-elemental]
[other-elemental]
pragma export-rule [elemental-type]
@@ -205,12 +189,8 @@ pragma export-rule [elemental-adv]
blood
soul
-[paraquasi-elemental] [para-elemental]
- [para-elemental]
- [quasi-elemental]
- [quasi-elemental]
- [quasi-elemental]
- [quasi-elemental]
+[paraquasi-elemental] <^2> [para-elemental]
+ <^4> [quasi-elemental]
[paraquasi-elemental]
[para-elemental] ice
diff --git a/data/sample-grammars/fantasy-locations.gram b/data/sample-grammars/fantasy-locations.gram
index 1190d68..95e31a8 100755
--- a/data/sample-grammars/fantasy-locations.gram
+++ b/data/sample-grammars/fantasy-locations.gram
@@ -1,7 +1,8 @@
-[fantasy-location-name] [name2]
+[fantasy-location-name] {@oname=[name1]} [act-fantasy-location-name]
-pragma prefix-with [fantasy-location-name] [name1]
-pragma prefix-with [fantasy-location-name] [name1]
+[act-fantasy-location-name] [name2]
+
+pragma prefix-with [act-fantasy-location-name] <&1..2> [@oname]
pragma initial-rule [fantasy-location-name]
@@ -27,11 +28,11 @@ pragma initial-rule [fantasy-location-name]
drowsy
dry
dusty
- [black-color]
+ [ebon||ebony]
emerald
fleet
fire
- [gold-color]
+ [gold||golden]
good
grace
grand
@@ -46,7 +47,7 @@ pragma initial-rule [fantasy-location-name]
holy
honey
hot
- [ice-type]
+ [ice||icy]
iron
ivory
lilac
@@ -55,16 +56,16 @@ pragma initial-rule [fantasy-location-name]
maple
mighty
night
- [oak-type]
+ [oak||oaken]
onyx
peaceful
pearl
prancing
quartz
queens
- [rain-type]
+ [rain||rainy]
red
- [rose-type]
+ [rose||rosy]
royal
ruby
sable
@@ -76,7 +77,7 @@ pragma initial-rule [fantasy-location-name]
shale
shining
short
- [silk-type]
+ [silk||silken]
silver
sleeping
small
@@ -207,24 +208,3 @@ pragma initial-rule [fantasy-location-name]
way
wolf
wood
-
-[silk-type] silk
- silken
-
-[rose-type] rose
- rosy
-
-[rain-type] rain
- rainy
-
-[oak-type] oak
- oaken
-
-[ice-type] ice
- icy
-
-[black-color] ebon
- ebony
-
-[gold-color] gold
- golden
diff --git a/data/sample-grammars/fortune.gram b/data/sample-grammars/fortune.gram
index 8bfce32..8bfce32 100644..100755
--- a/data/sample-grammars/fortune.gram
+++ b/data/sample-grammars/fortune.gram
diff --git a/data/sample-grammars/gemstones.gram b/data/sample-grammars/gemstones.gram
index 8f8a579..25fedf5 100644
--- a/data/sample-grammars/gemstones.gram
+++ b/data/sample-grammars/gemstones.gram
@@ -1,19 +1,18 @@
-[gemstones] [gemstone]
- [gemstone]
- [gemstone]
+[gemstones] [act-gemstones]
+
+[act-gemstones] <^3> [gemstone]
[gemstone-group]
[gemstone-group] pair of [gemstone]
- [gemstone-sizedesc] pile of [gemstone]
- [gemstone-sizedesc] hoard of [gemstone]
+ pile of [gemstone]
+ hoard of [gemstone]
+
+pragma prefix-with [gemstone-group] [gemstone-sizedesc]
pragma initial-rule [gemstones]
pragma suffix-with [gemstones] jewels
-[gemstone] [gemstone-1]
- [gemstone-1]
- [gemstone-1]
- [gemstone-1]
+[gemstone] <^4> [gemstone-1]
[ds-gem]
[gemstone-1] [common-gem]
@@ -21,14 +20,12 @@ pragma suffix-with [gemstones] jewels
[legendary-gem]
[epic-gem]
+pragma enable-descent [gemstone-1] 2
pragma export-rule [gemstone]
-[gemstone-sizedesc] [size]
- [gemstone-desc]
- [size] [gemstone-desc]
- [gemstone-desc] [size]
+[gemstone-sizedesc] {empty}
-pragma prefix-with [gemstone] [gemstone-sizedesc]
+pragma prefix-with [gemstone-sizedesc] [size] [gemstone-desc]
[size] tiny
miniscule
@@ -70,25 +67,17 @@ pragma export-rule [common-gem]
[quote-commongem] and [quote-commongem] fused together
[quote-legendarygem] of poor [extra-deficit]
-[extra-deficit] [extra-qualities]
- [extra-qualities]
- [extra-qualities]
- [extra-qualities]
+[extra-deficit] <^4> [extra-qualities]
[extra-qualities] but excellent [extra-qualities]
-[extra-quality] [extra-qualities]
- [extra-qualities]
- [extra-qualities]
- [extra-qualities]
+[extra-quality] <^4> [extra-qualities]
[extra-qualities] but poor [extra-qualities]
-[extra-qualities] [extra-quality-part]
- [extra-quality-part]
- [extra-quality-part]
+[extra-qualities] <^3> [extra-quality-part]
[extra-quality-phrase]
-[extra-quality-phrase] [extra-quality-part] and [extra-quality-part]
- [extra-quality-part] and [extra-quality-part]
+[extra-quality-phrase] <^2> [extra-quality-part] and [extra-quality-part]
+ <^2> [extra-quality-part] and [extra-quality-part]
[extra-quality-part] , [extra-quality-part] and [extra-quality-part]
[extra-quality-part] size
@@ -119,10 +108,7 @@ pragma export-rule [rare-gem]
pragma despace-rule [quote-raregem]
pragma export-rule [legendary-gem]
-[epic-gem] [epic-gem-1]
- [epic-gem-1]
- [epic-gem-1]
- [epic-gem-1]
+[epic-gem] <^4> [epic-gem-1]
[ds-gem]
[epic-gem-1] diamond
diff --git a/data/sample-grammars/genre-fiction.gram b/data/sample-grammars/genre-fiction.gram
index 92437d7..997b2af 100755
--- a/data/sample-grammars/genre-fiction.gram
+++ b/data/sample-grammars/genre-fiction.gram
@@ -1,9 +1,6 @@
[genre-fict] in a [setting] a young [person] stumbles across a(n) [place] [genre-fict2]
-# Uncomment me when we're done testing, because this rule takes a while to
-# generate
pragma initial-rule [genre-fict]
-pragma export-rule [genre-fict]
[genre-fict2] which spurs him into conflict with [antagonist] [genre-fict3]
@@ -91,9 +88,9 @@ pragma export-rule [genre-fict]
humanity’s selfish nature
his own insecurity vis-a-vis girls
-[female] [female]
- [female] [fem-suffix]
- [fem-prefix] [female]
+[female] <^4> [female]
+ <^2> [female] [fem-suffix]
+ <^2> [fem-prefix] [female]
[fem-prefix] [female] [fem-suffix]
[fem-prefix] sarcastic
diff --git a/data/sample-grammars/horror.gram b/data/sample-grammars/horror.gram
index 07d84de..d95b468 100644..100755
--- a/data/sample-grammars/horror.gram
+++ b/data/sample-grammars/horror.gram
@@ -2,32 +2,32 @@
pragma initial-rule [horror-movie]
-[first] attack of the
- invasion of the
- day of the
- beware! The
- terror of the
- death by
- curse of the
- earth vs. the
- return of the
+[first] Attack of the
+ Invasion of the
+ Day of the
+ Beware! The
+ Terror of the
+ Death by
+ Curse of the
+ Earth vs. the
+ Return of the
-[second] disco
- massive
- worrying
- flying
- flesh eating
- windy
- mutant
- hairy
- overly keen
+[second] Disco
+ Massive
+ Worrying
+ Flying
+ Flesh eating
+ Windy
+ Mutant
+ Hairy
+ Overly keen
-[third] vampires
- swamp beasts
- boy bands
- muffins
- werewolves
- zombies
- sock puppets
- death bots
- snuggle badgers
+[third] Vampires
+ Swamp Beasts
+ Boy Bands
+ Muffins
+ Werewolves
+ Zombies
+ Sock Puppets
+ Death Bots
+ Snuggle Badgers
diff --git a/data/sample-grammars/insults.gram b/data/sample-grammars/insults.gram
index 98a7a8e..98a7a8e 100644..100755
--- a/data/sample-grammars/insults.gram
+++ b/data/sample-grammars/insults.gram
diff --git a/data/sample-grammars/linux.gram b/data/sample-grammars/linux.gram
index ad18d65..7c6ca85 100644..100755
--- a/data/sample-grammars/linux.gram
+++ b/data/sample-grammars/linux.gram
@@ -4,11 +4,8 @@ pragma initial-rule [linux-domain]
[actual+linux-domain] [linux-domainname] . [big-tld]
-[linux-domainname] [linux-domain1] [linux-domain2]
- [linux-domain1] [linux-domain2]
- [linux-domain1] [linux-domain2]
- [linux-domain1] [linux-domain1]
- [linux-domain1] [linux-domain1]
+[linux-domainname] <^3> [linux-domain1] [linux-domain2]
+ <^2> [linux-domain1] [linux-domain1]
[linux-domain1] [linux-domain1] [linux-domain2]
[linux-domain1] [linux-domain1] - [linux-domain2]
[linux-domain1] - [linux-domain2]
@@ -583,8 +580,7 @@ pragma export-rule [geek-scifi-book]
[monitor] monitor
-pragma prefix-with [monitor] [monitor-resolution]
-pragma prefix-with [monitor] [monitor-type]
+pragma prefix-with [monitor] [monitor-resolution] [monitor-type]
[monitor-resolution] 4k
1080p
@@ -604,7 +600,7 @@ pragma prefix-with [monitor] [monitor-type]
[peripheral-interface] scsi
ide
parallel
- [usb]
+ <^3> [usb]
firewire 400
firewire 800
serial
@@ -663,11 +659,7 @@ pragma export-rule [peripheral]
pragma export-rule [freshmeat-url]
-[freshmeat+url] http://freshmeat.net/news/ [digit] / [digit] / [freshmeat-group1] / [freshmeat-group2] .html
-
-[freshmeat-group1] [digit] [digit] [digit] [digit]
-
-[freshmeat-group2] [digit] [digit] [digit] [digit] [digit] [digit] [digit] [digit] [digit]
+[freshmeat+url] http://freshmeat.net/news/ [0..9] / [0..9] / <&4> [0..9] / <&9> [0..9] .html
[freshmeat-desc] [app-type] [app-suffix]
[app-type] [app-suffix] for [freshmeat-for]
@@ -709,61 +701,58 @@ pragma export-rule [freshmeat-desc]
[freshmeat-app] [app-name] [app-version]
-[app-name] [app-name-simple]
- [app-name-simple]
- [app-name-simple]
+[app-name] <^3> [app-name-simple]
[app-name-complex]
pragma export-rule [app-name]
[app-name-simple] [app-name+simple]
-[app-name+simple] [acronym]
- [acronym]
- [acronym]
- [app-prefix] [acronym]
- [app-prefix] [syllable] [letter]
- [app-prefix] [syllable] 2 [syllable]
- [acronym]
+[app-name+simple] <^3> [acronym]
+ <^3> [letter-syll]
+ [syllable] 2 [syllable]
[letter] [acronym]
[random-name]
[last-name]
[syllable] [syllable]
- [letter] [syllable]
- [letter] [letter] [letter]
- [letter] [letter] [letter] [letter]
- [letter] [letter] [letter] [letter]
- [letter] [letter] [letter] [letter]
- [letter] [letter] [letter] [number-word]
- [app-prefix] [acronym]
- [app-prefix] [random-name]
- [app-prefix] [letter] [letter] [letter] [letter]
+ <&3> [letter]
+ <^4> <&4> [letter]
+ <&3> [letter] [number-word]
+ [random-name]
[app-common]
-[app-name-complex] [plural+first] [app-type] [app-suffix]
- [plural+first] [app-suffix]
+[letter-syll] {empty}
+
+pragma prefix-with [letter-syll] [syllable] [letter]
+
+pragma prefix-with [app-name+simple] [app-prefix]
+
+[app-name-complex] [plural+first] [app-type]
+ [plural+first]
+ <^2> [acronym] [app-type]
[acronym] [app-type]
- [acronym] [app-type] [app-suffix]
- [app-type] [app-suffix]
- [2+syllable] [app-type] [app-suffix]
- [random-name] [app-suffix]
- [app-prefix+letter] [app-suffix]
- [app-prefix+syllable] [app-type] [app-suffix]
- [app-common] [app-type] [app-suffix]
+ [app-type]
+ [2+syllable] [app-type]
+ [random-name]
+ [app-prefix+letter]
+ [app-prefix+syllable] [app-type]
+ [app-common] [app-type]
[tech-company] [peripheral] [device-type]
- [buzzword-adjective] [app-suffix]
+ [buzzword-adjective]
[plural+first] [buzzword-adjective] [buzzword-noun] [buzzword-job]
[acronym] [buzzword-noun]
- [app-prefix+name] [buzzword-adjective] [buzzword-job] [app-suffix]
+ [app-prefix+name] [buzzword-adjective] [buzzword-job]
[random-name] [buzzword-job]
- [buzzword-adjective] [buzzword-noun] [app-suffix]
+ [buzzword-adjective] [buzzword-noun]
[linux-distro]
+pragma suffix-with [app-name-complex] [app-suffix]
+
[device-type] 'WRITE ME'
[app-prefix+name] [app-prefix] [random-name]
-[app-prefix+letter] [app-prefix] [letter] [letter] [letter] [letter]
+[app-prefix+letter] [app-prefix] <&4> [letter]
[app-prefix+syllable] [app-prefix] [syllable] [syllable]
@@ -885,14 +874,14 @@ pragma export-rule [app-name]
[app-version] [app+version]
[app+version] 0.0. [1..20] [version-suffix]
- 0. [digit-nonzero] . [0..30]
+ 0. [1..9] . [0..30]
1.0. [0..30]
- 1. [digit-nonzero] . [0..30] [version-suffix]
- 2. [digit] . [0..30]
- 2. [digit] . [0..30] [version-suffix]
- [3..9] . [digit] . [0..30]
- 0.0 [digit] [version-suffix]
- 0. [digit]
+ 1. [1..9] . [0..30] [version-suffix]
+ 2. [0..9] . [0..30]
+ 2. [0..9] . [0..30] [version-suffix]
+ [3..9] . [0..9] . [0..30]
+ 0.0 [0..9] [version-suffix]
+ 0. [0..9]
0. [1..99]
1.0 [version-suffix]
1.00
@@ -900,13 +889,13 @@ pragma export-rule [app-name]
1. [1..99] [version-suffix]
[2..20] . [1..99] [version-suffix]
-[version-suffix] pl [digit]
+[version-suffix] pl [0..9]
alpha
beta
- [1..30]
[letter]
- -ac [digit]
- -pre [digit]
+ -ac [0..9]
+ -pre [0..9]
[linux-kernel-version] [linux-kernel+version]
@@ -914,7 +903,7 @@ pragma export-rule [app-name]
2.3. [50..99]
2.4.0-pre [1..30]
2.4.0-ac [1..30]
- 2.4. [digit]
+ 2.4. [0..9]
2.5. [0..99]
[2..4] . [6..9] . [0..99]
diff --git a/data/sample-grammars/long-data/animal.gram b/data/sample-grammars/long-data/animal.gram
index 8ce3b9d..8ce3b9d 100644..100755
--- a/data/sample-grammars/long-data/animal.gram
+++ b/data/sample-grammars/long-data/animal.gram
diff --git a/data/sample-grammars/long-data/canada-province.gram b/data/sample-grammars/long-data/canada-province.gram
index 8210d42..8210d42 100644..100755
--- a/data/sample-grammars/long-data/canada-province.gram
+++ b/data/sample-grammars/long-data/canada-province.gram
diff --git a/data/sample-grammars/long-data/cards.gram b/data/sample-grammars/long-data/cards.gram
index 51a86d4..1888be5 100644..100755
--- a/data/sample-grammars/long-data/cards.gram
+++ b/data/sample-grammars/long-data/cards.gram
@@ -2,6 +2,7 @@
[tarot-card]
[complete-many-things]
[harrowed-many-things]
+ [alt-tarot-card]
pragma initial-rule [card]
@@ -14,47 +15,21 @@ pragma export-rule [playing-card]
spades
diamonds
-[playing-rank] [rank-two]
- [rank-three]
- [rank-four]
- [rank-five]
- [rank-six]
- [rank-seven]
- [rank-eight]
- [rank-nine]
- [rank-ten]
+[playing-rank] <^8> [playing-rank-num]
jack
king
queen
ace
-[rank-two] 2
- deuce
- two
-
-[rank-three] 3
- three
-
-[rank-four] 4
- four
-
-[rank-five] 5
- five
-
-[rank-six] 6
- six
-
-[rank-seven] 7
- seven
-
-[rank-eight] 8
- eight
-
-[rank-nine] 9
- nine
-
-[rank-ten] 10
- ten
+[playing-rank-num] [2||deuce||two]
+ [3||three]
+ [4||four]
+ [5||five]
+ [6||six]
+ [7||seven]
+ [8||eight]
+ [9||nine]
+ [10||ten]
[tarot-card] [minor-arcana]
[major-arcana]
@@ -73,17 +48,10 @@ pragma export-rule [tarot-card]
[major-arcana2]
pragma export-rule [major-arcana]
+pragma export-rule [minor-arcana]
[minor-rank] ace
- [rank-two]
- [rank-three]
- [rank-four]
- [rank-five]
- [rank-six]
- [rank-seven]
- [rank-eight]
- [rank-nine]
- [rank-ten]
+ <^8> [playing-rank-num]
knave
page
jack
diff --git a/data/sample-grammars/long-data/color.gram b/data/sample-grammars/long-data/color.gram
index c71d04d..c71d04d 100644..100755
--- a/data/sample-grammars/long-data/color.gram
+++ b/data/sample-grammars/long-data/color.gram
diff --git a/data/sample-grammars/long-data/first-name-female.gram b/data/sample-grammars/long-data/first-name-female.gram
index 0bdfc8b..0bdfc8b 100644..100755
--- a/data/sample-grammars/long-data/first-name-female.gram
+++ b/data/sample-grammars/long-data/first-name-female.gram
diff --git a/data/sample-grammars/long-data/first-name-male.gram b/data/sample-grammars/long-data/first-name-male.gram
index 5642f9a..5642f9a 100644..100755
--- a/data/sample-grammars/long-data/first-name-male.gram
+++ b/data/sample-grammars/long-data/first-name-male.gram
diff --git a/data/sample-grammars/long-data/geographic-thing.gram b/data/sample-grammars/long-data/geographic-thing.gram
index 178bd7f..178bd7f 100644..100755
--- a/data/sample-grammars/long-data/geographic-thing.gram
+++ b/data/sample-grammars/long-data/geographic-thing.gram
diff --git a/data/sample-grammars/long-data/last-name.gram b/data/sample-grammars/long-data/last-name.gram
index b99a40c..b99a40c 100644..100755
--- a/data/sample-grammars/long-data/last-name.gram
+++ b/data/sample-grammars/long-data/last-name.gram
diff --git a/data/sample-grammars/long-data/letters.gram b/data/sample-grammars/long-data/letters.gram
index f561b99..3c1440a 100644..100755
--- a/data/sample-grammars/long-data/letters.gram
+++ b/data/sample-grammars/long-data/letters.gram
@@ -125,10 +125,6 @@ pragma export-rule [letter]
pragma export-rule [middle-initial]
-[vowel] a
- e
- i
- o
- u
+[vowel] [a||e||i||o||u]
pragma export-rule [vowel]
diff --git a/data/sample-grammars/long-data/nation.gram b/data/sample-grammars/long-data/nation.gram
index d15788d..14ef8e5 100644..100755
--- a/data/sample-grammars/long-data/nation.gram
+++ b/data/sample-grammars/long-data/nation.gram
@@ -1,220 +1,220 @@
-[nation] afghanistan
- albania
- algeria
- american samoa
- andorra
- angola
- anguilla
- antarctica
- antigua
- argentina
- armenia
- aruba
- australia
- austria
- azerbaijan
- bahamas
- bahrain
- bangladesh
- barbados
- belarus
- belgium
- belize
- benin
- bermuda
- bhutan
- bolivia
- bosnia and herzegovina
- botswana
- brazil
- brunei
- bulgaria
- burkina faso
- burma
- burundi
- cambodia
- cameroon
- canada
- cape verde
- central african republic
- chad
- chile
- china
- colombia
- comoros
- congo
- cook islands
- costa rica
- cote d'ivoire
- croatia
- cuba
- cyprus
- czech republic
- denmark
- djibouti
- dominica
- dominican republic
- ecuador
- egypt
- el salvador
- equatorial guinea
- eritrea
- estonia
- ethiopia
- falkland islands
- fiji
- finland
- france
- french guiana
- french polynesia
- gabon
- the gambia
- georgia
- germany
- ghana
- gibraltar
- greece
- greenland
- grenada
- guadeloupe
- guam
- guatemala
- guinea
- guinea-bissau
- guyana
- haiti
- the holy see
- honduras
- hong kong
- hungary
- iceland
- india
- indonesia
- iran
- iraq
- ireland
- israel
- italy
- jamaica
- japan
- jordan
- kazakhstan
- kenya
- kiribati
- kuwait
- kyrgyzstan
- laos
- latvia
- lebanon
- lesotho
- liberia
- libya
- liechtenstein
- lithuania
- luxembourg
- macau
- macedonia
- madagascar
- malawi
- malaysia
- maldives
- mali
- malta
- marshall islands
- martinique
- mauritania
- mauritius
- mayotte
- mexico
- federated states of micronesia
- moldova
- monaco
- mongolia
- montserrat
- morocco
- mozambique
- namibia
- nauru
- nepal
- netherlands
- netherlands antilles
- new caledonia
- new zealand
- nicaragua
- niger
- nigeria
- north korea
- northern mariana islands
- norway
- oman
- pakistan
- palau
- panama
- papua new guinea
- paraguay
- peru
- philippines
- pitcairn islands
- poland
- portugal
- puerto rico
- qatar
- reunion
- romania
- russia
- rwanda
- saint kitts and nevis
- saint lucia
- saint pierre and miquelon
- saint vincent and the grenadines
- samoa
- san marino
- sao tome and principe
- saudi arabia
- senegal
- seychelles
- sierra leone
- singapore
- slovakia
- slovenia
- solomon islands
- somalia
- south africa
- south korea
- spain
- sri lanka
- sudan
- suriname
- swaziland
- sweden
- switzerland
- syria
- taiwan
- tajikistan
- tanzania
- thailand
- togo
- tonga
- trinidad and tobago
- tunisia
- turkey
- turkmenistan
- turks and caicos islands
- tuvalu
- uganda
- ukraine
- united arab emirates
- united kingdom
- united states
- uruguay
- uzbekistan
- vanuatu
- venezuela
- vietnam
- western sahara
- yemen
- zaire
- zambia
- zimbabwe
+[nation] Afghanistan
+ Albania
+ Algeria
+ American samoa
+ Andorra
+ Angola
+ Anguilla
+ Antarctica
+ Antigua
+ Argentina
+ Armenia
+ Aruba
+ Australia
+ Austria
+ Azerbaijan
+ Bahamas
+ Bahrain
+ Bangladesh
+ Barbados
+ Belarus
+ Belgium
+ Belize
+ Benin
+ Bermuda
+ Bhutan
+ Bolivia
+ Bosnia and Herzegovina
+ Botswana
+ Brazil
+ Brunei
+ Bulgaria
+ Burkina faso
+ Burma
+ Burundi
+ Cambodia
+ Cameroon
+ Canada
+ Cape verde
+ Central African Republic
+ Chad
+ Chile
+ China
+ Colombia
+ Comoros
+ Congo
+ Cook Islands
+ Costa Rica
+ Cote d'Ivoire
+ Croatia
+ Cuba
+ Cyprus
+ Czech Republic
+ Denmark
+ Djibouti
+ Dominica
+ Dominican Republic
+ Ecuador
+ Egypt
+ El Salvador
+ Equatorial Guinea
+ Eritrea
+ Estonia
+ Ethiopia
+ Falkland Islands
+ Fiji
+ Finland
+ France
+ French Guiana
+ French Polynesia
+ Gabon
+ The Gambia
+ Georgia
+ Germany
+ Ghana
+ Gibraltar
+ Greece
+ Greenland
+ Grenada
+ Guadeloupe
+ Guam
+ Guatemala
+ Guinea
+ Guinea-Bissau
+ Guyana
+ Haiti
+ The Holy See
+ Honduras
+ Hong Kong
+ Hungary
+ Iceland
+ India
+ Indonesia
+ Iran
+ Iraq
+ Ireland
+ Israel
+ Italy
+ Jamaica
+ Japan
+ Jordan
+ Kazakhstan
+ Kenya
+ Kiribati
+ Kuwait
+ Kyrgyzstan
+ Laos
+ Latvia
+ Lebanon
+ Lesotho
+ Liberia
+ Libya
+ Liechtenstein
+ Lithuania
+ Luxembourg
+ Macau
+ Macedonia
+ Madagascar
+ Malawi
+ Malaysia
+ Maldives
+ Mali
+ Malta
+ Marshall Islands
+ Martinique
+ Mauritania
+ Mauritius
+ Mayotte
+ Mexico
+ Federated States Of Micronesia
+ Moldova
+ Monaco
+ Mongolia
+ Montserrat
+ Morocco
+ Mozambique
+ Namibia
+ Nauru
+ Nepal
+ Netherlands
+ Netherlands Antilles
+ New Caledonia
+ New Zealand
+ Nicaragua
+ Niger
+ Nigeria
+ North Korea
+ Northern Mariana Islands
+ Norway
+ Oman
+ Pakistan
+ Palau
+ Panama
+ Papua New Guinea
+ Paraguay
+ Peru
+ Philippines
+ Pitcairn Islands
+ Poland
+ Portugal
+ Puerto Rico
+ Qatar
+ Reunion
+ Romania
+ Russia
+ Rwanda
+ Saint Kitts and Nevis
+ Saint Lucia
+ Saint Pierre and Miquelon
+ Saint Vincent and The Grenadines
+ Samoa
+ San Marino
+ Sao Tome and Principe
+ Saudi Arabia
+ Senegal
+ Seychelles
+ Sierra Leone
+ Singapore
+ Slovakia
+ Slovenia
+ Solomon Islands
+ Somalia
+ South Africa
+ South Korea
+ Spain
+ Sri Lanka
+ Sudan
+ Suriname
+ Swaziland
+ Sweden
+ Switzerland
+ Syria
+ Taiwan
+ Tajikistan
+ Tanzania
+ Thailand
+ Togo
+ Tonga
+ Trinidad and Tobago
+ Tunisia
+ Turkey
+ Turkmenistan
+ Turks and Caicos Islands
+ Tuvalu
+ Uganda
+ Ukraine
+ United Arab Emirates
+ United Kingdom
+ United States
+ Uruguay
+ Uzbekistan
+ Vanuatu
+ Venezuela
+ Vietnam
+ Western Sahara
+ Yemen
+ Zaire
+ Zambia
+ Zimbabwe
pragma initial-rule [nation]
diff --git a/data/sample-grammars/long-data/numbers.gram b/data/sample-grammars/long-data/numbers.gram
index 8525102..f2aa0d4 100644..100755
--- a/data/sample-grammars/long-data/numbers.gram
+++ b/data/sample-grammars/long-data/numbers.gram
@@ -15,26 +15,11 @@ pragma export-rule [binary-digit]
pragma export-rule [digit-noone]
-[digit-nonzero] 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
+[digit-nonzero] [1..9]
pragma export-rule [digit-nonzero]
-[digit-twoup] 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
+[digit-twoup] [2..9]
pragma export-rule [digit-twoup]
diff --git a/data/sample-grammars/long-data/planet.gram b/data/sample-grammars/long-data/planet.gram
index 1da1678..6149a61 100644..100755
--- a/data/sample-grammars/long-data/planet.gram
+++ b/data/sample-grammars/long-data/planet.gram
@@ -1,4 +1,4 @@
-[planet] → Mercury
+[planet] Mercury
Venus
Mars
Jupiter
diff --git a/data/sample-grammars/long-data/real-city.gram b/data/sample-grammars/long-data/real-city.gram
index 7ca57b9..cea075d 100644..100755
--- a/data/sample-grammars/long-data/real-city.gram
+++ b/data/sample-grammars/long-data/real-city.gram
@@ -1,78 +1,79 @@
-[real-city] → birmingham
- anchorage
- mesa
- phoenix
- tucson
- anaheim
- fresno
- long beach
- los angeles
- oakland
- riverside
- sacramento
- san diego
- san francisco
- san jose
- santa ana
- stockton
- aurora
- colorado springs
- denver
- washington
- jacksonville
- miami
- st. petersburg
- tampa
- atlanta
- honolulu
- chicago
- indianapolis
- wichita
- lexington
- louisville
- baton rouge
- new orleans
- baltimore
- boston
- detroit
- minneapolis
- st. paul
- kansas city
- st. louis
- omaha
- las vegas
- jersey city
- newark
- albuquerque
- buffalo
- new york
- rochester
- charlotte
- raleigh
- akron
- cincinnati
- cleveland
- columbus
- toledo
- oklahoma city
- tulsa
- portland
- philadelphia
- pittsburgh
- memphis
- nashville
- arlington
- austin
- corpus christi
- dallas
- el paso
- fort worth
- houston
- san antonio
- norfolk
- richmond
- virginia beach
- seattle
- milwaukee
+[real-city]
+ Birmingham
+ Anchorage
+ Mesa
+ Phoenix
+ Tucson
+ Anaheim
+ Fresno
+ Long Beach
+ Los Angeles
+ Oakland
+ Riverside
+ Sacramento
+ San diego
+ San Francisco
+ San Jose
+ Santa Ana
+ Stockton
+ Aurora
+ Colorado Springs
+ Denver
+ Washington
+ Jacksonville
+ Miami
+ St. Petersburg
+ Tampa
+ Atlanta
+ Honolulu
+ Chicago
+ Indianapolis
+ Wichita
+ Lexington
+ Louisville
+ Baton Rouge
+ New Orleans
+ Baltimore
+ Boston
+ Detroit
+ Minneapolis
+ St. Paul
+ Kansas City
+ St. Louis
+ Omaha
+ Las Vegas
+ Jersey City
+ Newark
+ Albuquerque
+ Buffalo
+ New York
+ Rochester
+ Charlotte
+ Raleigh
+ Akron
+ Cincinnati
+ Cleveland
+ Columbus
+ Toledo
+ Oklahoma City
+ Tulsa
+ Portland
+ Philadelphia
+ Pittsburgh
+ Memphis
+ Nashville
+ Arlington
+ Austin
+ Corpus Christi
+ Dallas
+ El Paso
+ Fort Worth
+ Houston
+ San Antonio
+ Norfolk
+ Richmond
+ Virginia Beach
+ Seattle
+ Milwaukee
pragma initial-rule [real-city]
diff --git a/data/sample-grammars/long-data/real-company.gram b/data/sample-grammars/long-data/real-company.gram
index f81ec14..079b945 100644..100755
--- a/data/sample-grammars/long-data/real-company.gram
+++ b/data/sample-grammars/long-data/real-company.gram
@@ -1,209 +1,210 @@
-[real-company] 3com
- aflac
- at&t
- ace hardware
- aetna
- aid association for lutherans
- albertson's
- allstate
- alltel
- amerenue
- america online
- american express
- american general
- ames department stores
- anheuser-busch
- apple computer
- archer daniels midland
- autozone
- avis rent a car
- avon products
- b.f. goodrich
- bank of america corp.
- barnes & noble
- bell atlantic
- bellsouth
- berkshire hathaway
- best buy
- black & decker
- boeing
- bristol-myers squibb
- burlington northern santa fe
- cbs
- cvs
- cablevision systems
- campbell soup
- caterpillar
- cendant
- charles schwab
- chase manhattan corp.
- chevron
- cigna
- cinergy
- circuit city group
- cisco systems
- citigroup
- clorox
- coastal
- coca-cola
- colgate-palmolive
- columbia/hca healthcare
- comcast
- comerica
- compusa
- compaq computer
- computer associates intl.
- conagra
- conoco
- conseco
- continental airlines
- corning
- costco wholesale
- dana
- dell computer
- delta air lines
- dillard's
- dole food
- dollar general
- dow chemical
- eastman kodak
- eli lilly
- este lauder
- exxon mobil
- fannie mae
- farmland industries
- fedex
- firstar corp.
- fleetwood enterprises
- ford motor
- gte
- gannett
- gap
- gateway
- general electric
- general mills
- general motors
- gillette
- goldman sachs group
- goodyear tire & rubber
- h.j. heinz
- hartford financial services
- hasbro
- healthsouth
- hershey foods
- hewlett-packard
- home depot
- honeywell international
- hormel foods
- itt industries
- ikon office solutions
- ingersoll-rand
- intel
- ibm
- j.c. penney
- j.p. morgan & co.
- john hancock financial services
- johnson & johnson
- kellogg
- kimberly-clark
- kmart
- knight-ridder
- kroger
- lexmark international
- lockheed martin
- lowe's
- lucent technologies
- mci worldcom
- marriott international
- mattel
- maytag
- mcdonald's
- mcgraw-hill
- merck
- merrill lynch
- metropolitan life insurance
- micron technology
- microsoft
- monsanto
- morgan stanley dean witter
- motorola
- mutual of omaha insurance
- ncr
- nabisco group holdings
- new york life insurance
- new york times
- newell rubbermaid
- nextel communications
- nike
- nordstrom
- northwest airlines
- office depot
- officemax
- oracle
- owens corning
- paine webber group
- pepsico
- pfizer
- pharmacia & upjohn
- philip morris
- procter & gamble
- providian financial
- prudential ins. co. of america
- quaker oats
- qualcomm
- quantum
- qwest communications
- r. j. reynolds tobacco
- ralston purina
- raytheon
- rockwell international
- sbc communications
- safeway
- saks
- sara lee
- seagate technology
- sears roebuck
- servicemaster
- sherwin-williams
- shopko stores
- sodexho marriott services
- southwest airlines
- sprint
- staples
- state farm insurance cos.
- sun microsystems
- suntrust banks
- sunoco
- supervalu
- tandy
- target
- tenet healthcare
- texaco
- texas instruments
- time warner
- times mirror
- toys `r' us
- trans world airlines
- tyson foods
- u.s. bancorp
- us airways group
- us west
- ultramar diamond shamrock
- union carbide
- union pacific
- unisys
- united parcel service
- unitedhealth group
- universal
- viacom
- wal-mart stores
- walgreen
- walt disney
- warner-lambert
- wells fargo
- weyerhaeuser
- whirlpool
- winn-dixie stores
- xerox
+[real-company]
+ 3com
+ Aflac
+ At&T
+ Ace Hardware
+ Aetna
+ Aid Association For Lutherans
+ Albertson'S
+ Allstate
+ Alltel
+ Amerenue
+ America Online
+ American Express
+ American General
+ Ames Department Stores
+ Anheuser-Busch
+ Apple Computer
+ Archer Daniels Midland
+ Autozone
+ Avis Rent A Car
+ Avon Products
+ B.F. Goodrich
+ Bank Of America Corp.
+ Barnes & Noble
+ Bell Atlantic
+ Bellsouth
+ Berkshire Hathaway
+ Best Buy
+ Black & Decker
+ Boeing
+ Bristol-Myers Squibb
+ Burlington Northern Santa Fe
+ Cbs
+ Cvs
+ Cablevision Systems
+ Campbell Soup
+ Caterpillar
+ Cendant
+ Charles Schwab
+ Chase Manhattan Corp.
+ Chevron
+ Cigna
+ Cinergy
+ Circuit City Group
+ Cisco Systems
+ Citigroup
+ Clorox
+ Coastal
+ Coca-Cola
+ Colgate-Palmolive
+ Columbia/Hca Healthcare
+ Comcast
+ Comerica
+ Compusa
+ Compaq Computer
+ Computer Associates Intl.
+ Conagra
+ Conoco
+ Conseco
+ Continental Airlines
+ Corning
+ Costco Wholesale
+ Dana
+ Dell Computer
+ Delta Air Lines
+ Dillard'S
+ Dole Food
+ Dollar General
+ Dow Chemical
+ Eastman Kodak
+ Eli Lilly
+ Este Lauder
+ Exxon Mobil
+ Fannie Mae
+ Farmland Industries
+ Fedex
+ Firstar Corp.
+ Fleetwood Enterprises
+ Ford Motor
+ Gte
+ Gannett
+ Gap
+ Gateway
+ General Electric
+ General Mills
+ General Motors
+ Gillette
+ Goldman Sachs Group
+ Goodyear Tire & Rubber
+ H.J. Heinz
+ Hartford Financial Services
+ Hasbro
+ Healthsouth
+ Hershey Foods
+ Hewlett-Packard
+ Home Depot
+ Honeywell International
+ Hormel Foods
+ Itt Industries
+ Ikon Office Solutions
+ Ingersoll-Rand
+ Intel
+ Ibm
+ J.C. Penney
+ J.P. Morgan & Co.
+ John Hancock Financial Services
+ Johnson & Johnson
+ Kellogg
+ Kimberly-Clark
+ Kmart
+ Knight-Ridder
+ Kroger
+ Lexmark International
+ Lockheed Martin
+ Lowe'S
+ Lucent Technologies
+ Mci Worldcom
+ Marriott International
+ Mattel
+ Maytag
+ Mcdonald'S
+ Mcgraw-Hill
+ Merck
+ Merrill Lynch
+ Metropolitan Life Insurance
+ Micron Technology
+ Microsoft
+ Monsanto
+ Morgan Stanley Dean Witter
+ Motorola
+ Mutual Of Omaha Insurance
+ Ncr
+ Nabisco Group Holdings
+ New York Life Insurance
+ New York Times
+ Newell Rubbermaid
+ Nextel Communications
+ Nike
+ Nordstrom
+ Northwest Airlines
+ Office Depot
+ Officemax
+ Oracle
+ Owens Corning
+ Paine Webber Group
+ Pepsico
+ Pfizer
+ Pharmacia & Upjohn
+ Philip Morris
+ Procter & Gamble
+ Providian Financial
+ Prudential Ins. Co. Of America
+ Quaker Oats
+ Qualcomm
+ Quantum
+ Qwest Communications
+ R. J. Reynolds Tobacco
+ Ralston Purina
+ Raytheon
+ Rockwell International
+ Sbc Communications
+ Safeway
+ Saks
+ Sara Lee
+ Seagate Technology
+ Sears Roebuck
+ Servicemaster
+ Sherwin-Williams
+ Shopko Stores
+ Sodexho Marriott Services
+ Southwest Airlines
+ Sprint
+ Staples
+ State Farm Insurance Cos.
+ Sun Microsystems
+ Suntrust Banks
+ Sunoco
+ Supervalu
+ Tandy
+ Target
+ Tenet Healthcare
+ Texaco
+ Texas Instruments
+ Time Warner
+ Times Mirror
+ Toys `R' Us
+ Trans World Airlines
+ Tyson Foods
+ U.S. Bancorp
+ Us Airways Group
+ Us West
+ Ultramar Diamond Shamrock
+ Union Carbide
+ Union Pacific
+ Unisys
+ United Parcel Service
+ Unitedhealth Group
+ Universal
+ Viacom
+ Wal-Mart Stores
+ Walgreen
+ Walt Disney
+ Warner-Lambert
+ Wells Fargo
+ Weyerhaeuser
+ Whirlpool
+ Winn-Dixie Stores
+ Xerox
pragma initial-rule [real-company]
diff --git a/data/sample-grammars/long-data/relative.gram b/data/sample-grammars/long-data/relative.gram
index a18e015..d51a451 100644..100755
--- a/data/sample-grammars/long-data/relative.gram
+++ b/data/sample-grammars/long-data/relative.gram
@@ -1,4 +1,4 @@
-[relative] → father
+[relative] father
mother
uncle
aunt
diff --git a/data/sample-grammars/long-data/roman-numeral.gram b/data/sample-grammars/long-data/roman-numeral.gram
index 886d44c..9715036 100644..100755
--- a/data/sample-grammars/long-data/roman-numeral.gram
+++ b/data/sample-grammars/long-data/roman-numeral.gram
@@ -1,8 +1,8 @@
[roman-numeral-string] [roman-numeral-string+1]
-[roman-numeral-string+1] [roman-numeral]
- [roman-numeral]
- [roman-numeral] [roman-numeral-string]
+[roman-numeral-string+1] <^2> <&1..4> [roman-numeral]
+ <^4> <&5..10> [roman-numeral]
+ <&10..15> [roman-numeral]
pragma initial-rule [roman-numeral-string]
diff --git a/data/sample-grammars/long-data/syllables.gram b/data/sample-grammars/long-data/syllables.gram
index 925c2aa..925c2aa 100644..100755
--- a/data/sample-grammars/long-data/syllables.gram
+++ b/data/sample-grammars/long-data/syllables.gram
diff --git a/data/sample-grammars/long-data/town-name.gram b/data/sample-grammars/long-data/town-name.gram
index e176c7d..9a97fe4 100644..100755
--- a/data/sample-grammars/long-data/town-name.gram
+++ b/data/sample-grammars/long-data/town-name.gram
@@ -1,143 +1,143 @@
-[town-name] → sullivan
- jakin
- geneva
- coleharbor
- cadiz
- dawson
- turon
- salem
- pax
- dakota
- moorefield
- zenda
- mettawa
- orchard
- busby
- cloudcroft
- perla
- burlington
- morrison
- blackburn
- jerico
- skykomish
- dupree
- dawson
- bowers
- star
- dorrance
- roberts
- carbon
- hopedale
- croghan
- elgin
- holland
- berkley
- sherrill
- varna
- owen
- oxford
- drake
- notus
- hobgood
- thacker
- springfield
- fraser
- avon
- audubon
- waterloo
- windsor
- atoka
- cherry
- hudson
- kechi
- pickstown
- elizabeth
- holt
- stapleton
- kell
- gardena
- osceola
- moscow
- morrison
- mustang
- maxwell
- francis
- eureka
- darlington
- ely
- bancroft
- hanover
- milano
- cabery
- byars
- gully
- sherwood
- reklaw
- watkins
- heartwell
- dawson
- vermont
- goldville
- paxson
- potwin
- sherman
- glenbeulah
- sunset
- clearwater
- solen
- altamont
- dyer
- murray
- rathbun
- huntleigh
- poulan
- burlington
- jackson
- verndale
- cleveland
- josephine
- leland
- carrollton
- vance
- sumner
- tira
- mead
- gumbranch
- glenwood
- harrison
- hannibal
- carthage
- callao
- bussey
- coaldale
- chugwater
- andale
- adell
- farber
- carlton
- prue
- tenney
- walcott
- udall
- brighton
- minburn
- swan
- frazer
- menlo
- bassett
- massena
- trommald
- waynesfield
- lynd
- mendon
- hammond
- simsboro
- thornton
- crary
- reynolds
- turton
- perry
- penasco
- loami
+[town-name] Sullivan
+ Jakin
+ Geneva
+ Coleharbor
+ Cadiz
+ Dawson
+ Turon
+ Salem
+ Pax
+ Dakota
+ Moorefield
+ Zenda
+ Mettawa
+ Orchard
+ Busby
+ Cloudcroft
+ Perla
+ Burlington
+ Morrison
+ Blackburn
+ Jerico
+ Skykomish
+ Dupree
+ Dawson
+ Bowers
+ Star
+ Dorrance
+ Roberts
+ Carbon
+ Hopedale
+ Croghan
+ Elgin
+ Holland
+ Berkley
+ Sherrill
+ Varna
+ Owen
+ Oxford
+ Drake
+ Notus
+ Hobgood
+ Thacker
+ Springfield
+ Fraser
+ Avon
+ Audubon
+ Waterloo
+ Windsor
+ Atoka
+ Cherry
+ Hudson
+ Kechi
+ Pickstown
+ Elizabeth
+ Holt
+ Stapleton
+ Kell
+ Gardena
+ Osceola
+ Moscow
+ Morrison
+ Mustang
+ Maxwell
+ Francis
+ Eureka
+ Darlington
+ Ely
+ Bancroft
+ Hanover
+ Milano
+ Cabery
+ Byars
+ Gully
+ Sherwood
+ Reklaw
+ Watkins
+ Heartwell
+ Dawson
+ Vermont
+ Goldville
+ Paxson
+ Potwin
+ Sherman
+ Glenbeulah
+ Sunset
+ Clearwater
+ Solen
+ Altamont
+ Dyer
+ Murray
+ Rathbun
+ Huntleigh
+ Poulan
+ Burlington
+ Jackson
+ Verndale
+ Cleveland
+ Josephine
+ Leland
+ Carrollton
+ Vance
+ Sumner
+ Tira
+ Mead
+ Gumbranch
+ Glenwood
+ Harrison
+ Hannibal
+ Carthage
+ Callao
+ Bussey
+ Coaldale
+ Chugwater
+ Andale
+ Adell
+ Farber
+ Carlton
+ Prue
+ Tenney
+ Walcott
+ Udall
+ Brighton
+ Minburn
+ Swan
+ Frazer
+ Menlo
+ Bassett
+ Massena
+ Trommald
+ Waynesfield
+ Lynd
+ Mendon
+ Hammond
+ Simsboro
+ Thornton
+ Crary
+ Reynolds
+ Turton
+ Perry
+ Penasco
+ Loami
pragma initial-rule [town-name]
diff --git a/data/sample-grammars/long-data/tree.gram b/data/sample-grammars/long-data/tree.gram
index 6fd0f0e..6293ada 100644..100755
--- a/data/sample-grammars/long-data/tree.gram
+++ b/data/sample-grammars/long-data/tree.gram
@@ -1,4 +1,4 @@
-[tree] → pine
+[tree] pine
elm
maple
oak
diff --git a/data/sample-grammars/martial-arts.gram b/data/sample-grammars/martial-arts.gram
index 2f9f557..7907e02 100755
--- a/data/sample-grammars/martial-arts.gram
+++ b/data/sample-grammars/martial-arts.gram
@@ -1,39 +1,39 @@
-[martial-arts-name] → [art-1] [art-2]
- [art-1] [art-3]
- [art-2] [art-3]
- [art-1] [art-2] [art-3]
+[martial-arts-name] [art-1] [art-2]
+ [art-1] [art-3]
+ [art-2] [art-3]
+ [art-1] [art-2] [art-3]
pragma initial-rule [martial-arts-name]
-[art-1] → running
- hungry
- angry
- naked
- drunken
- fortunate
- lazy
- swift
- powerful
- enlightened
+[art-1] running
+ hungry
+ angry
+ naked
+ drunken
+ fortunate
+ lazy
+ swift
+ powerful
+ enlightened
-[art-2] → ox
- tiger
- dragon
- crane
- monkey
- turtle
- manticore
- serpent
- hummingbird
- demon
+[art-2] ox
+ tiger
+ dragon
+ crane
+ monkey
+ turtle
+ manticore
+ serpent
+ hummingbird
+ demon
-[art-3] → fist
- stance
- spinning kick
- attack
- technique
- style
- dance
- movement
- touch
- fu
+[art-3] fist
+ stance
+ spinning kick
+ attack
+ technique
+ style
+ dance
+ movement
+ touch
+ fu
diff --git a/data/sample-grammars/mary-sue.gram b/data/sample-grammars/mary-sue.gram
index cb39264..f97ce40 100755
--- a/data/sample-grammars/mary-sue.gram
+++ b/data/sample-grammars/mary-sue.gram
@@ -1,5 +1,5 @@
-[mary-sue] she appears to be a normal [normal-desc] . [mary-sue2]
- she appears to be a normal [normal-desc] [opt-dress] [mary-sue2]
+[mary-sue] She appears to be a normal [normal-desc] . [mary-sue2]
+ She appears to be a normal [normal-desc] [opt-dress] [mary-sue2]
[mary-sue2] She is [desc] and she will fight her enemies with her power to [power-desc] [mary-sue3]
@@ -177,7 +177,7 @@ pragma initial-rule [mary-sue]
cursed by god
traveling through time
-[power-desc] [power-1]
+[power-desc] <^2> [power-1]
[power-1] and [power-1]
[power-1] [power-p1] [power-p2]
@@ -300,10 +300,9 @@ pragma suffix-with [comp] [comp-weapon]
[comp-name] [comp-name1]
[comp-prefix] [comp-name1]
-[comp-prefix] [comp-prefix1]
- [comp-prefix2]
- [comp-prefix1] [comp-prefix2]
- [comp-prefix2] [comp-prefix1]
+[comp-prefix] {empty}
+
+pragma prefix-with [comp-prefix] [comp-prefix1] [comp-prefix2]
[comp-name1] dragon
mecha
@@ -437,10 +436,9 @@ pragma suffix-with [comp] [comp-weapon]
rapier
scissors
-[compweap-prefix] [compweap-1]
- [compweap-2]
- [compweap-1] [compweap-2]
- [compweap-2] [compweap-1]
+[compweap-prefix] {empty}
+
+pragma prefix-with [compweap-prefix] [compweap-1] [compweap-2]
[compweap-1] poisoned
blessed
diff --git a/data/sample-grammars/media.gram b/data/sample-grammars/media.gram
index f3a1c98..1a37118 100644..100755
--- a/data/sample-grammars/media.gram
+++ b/data/sample-grammars/media.gram
@@ -10,26 +10,26 @@ pragma initial-rule [media-company]
[chan+name] k [chan-name2]
w [chan-name2]
-[chan-name2] [letter] [letter] [letter] -tv
+[chan-name2] <&3> [letter] -tv
[radio-station] [radio+name] on frequency [radio+chan]
[radio+name] k [radio+name2]
w [radio+name2]
-[radio+name2] [letter] [letter] [letter] [chan-type]
+[radio+name2] <&3> [letter] [chan-type]
-[chan-type] -fm {chantype=fm}
- -am {chantype=am}
+[chan-type] -fm {$chantype=fm}
+ -am {$chantype=am}
[radio+chan] 9 [radio-9chan]
[$chantype-1chan]
-[radio-9chan] [digit] . [digit]
+[radio-9chan] [0..9] . [0..9]
-[fm-1chan] 1 [digit] [digit] . [digit]
+[fm-1chan] 1 [0..9] [0..9] . [0..9]
-[am-1chan] 10 [digit] [digit]
+[am-1chan] 10 [0..9] [0..9]
[newspaper] the [newspaper-pair1] - [newspaper-pair2]
the [newspaper-pair1] - [newspaper-pair2] - [newspaper-pair2]
@@ -112,8 +112,7 @@ pragma initial-rule [media-company]
pragma export-rule [newspaper-pair2]
-[cardinal] [act-cardinal]
- [act-cardinal]
+[cardinal] <^2> [act-cardinal]
[act-cardinal] by [act-cardinal]
[2+cardinal]
diff --git a/data/sample-grammars/mission.gram b/data/sample-grammars/mission.gram
index e474fcd..8fbe9ca 100644..100755
--- a/data/sample-grammars/mission.gram
+++ b/data/sample-grammars/mission.gram
@@ -211,7 +211,7 @@ pragma initial-rule [mission-statement]
supply-chains
synergies
technologies
- total {{empty}} quality {{empty}} management
+ total {empty} quality {empty} management
version control
vision
catalysts for [noun]
diff --git a/data/sample-grammars/names.gram b/data/sample-grammars/names.gram
index 104c136..a0c41c3 100644..100755
--- a/data/sample-grammars/names.gram
+++ b/data/sample-grammars/names.gram
@@ -30,17 +30,11 @@ pragma export-rule [random-name]
[female-title] [first-name-female] [middle-initial] . [last-name]
[gender-neutral-title] [full-name]
[generic-title] [full-name]
- [full-name]
- [full-name]
- [full-name]
- [full-name]
+ <^4> [full-name]
-[generic-title] [male-title]
- [female-title]
- [gender-neutral-title]
- [male-title]
- [female-title]
- [gender-neutral-title]
+[generic-title] <^2> [male-title]
+ <^2> [female-title]
+ <^2> [gender-neutral-title]
[career-tech]
# @TODO 10/23/17 Ben Culkin :TitleExpansion
@@ -54,52 +48,52 @@ pragma export-rule [random-name]
Uncle
Lord Mayor
Prince
- archduke
- grand duke
- duke
- marquis
- marquess
- count
- earl
- jarl
- viscount
- baron
- lord
- emperor
- king
- tsar
- imperator
- viceroy
- pope
- abbot
- brother
- friar
- bishop
- archbishob
- priest
- high priest
- father
- patriarch
- vicar
- chaplain
- pastor
- cardinal
- monsieur
- herr
- senor
- signor
- emir
- sultan
- maharajah
- lord protector
- king-emperor
- rex
- lord of the manor
- high king
- crown prince
- grand prince
- praetor
- headmaster
+ Archduke
+ Grand Duke
+ Duke
+ Marquis
+ Marquess
+ Count
+ Earl
+ Jarl
+ Viscount
+ Baron
+ Lord
+ Emperor
+ King
+ Tsar
+ Imperator
+ Viceroy
+ Pope
+ Abbot
+ Brother
+ Friar
+ Bishop
+ Archbishob
+ Priest
+ High Priest
+ Father
+ Patriarch
+ Vicar
+ Chaplain
+ Pastor
+ Cardinal
+ Monsieur
+ Herr
+ Senor
+ Signor
+ Emir
+ Sultan
+ Maharajah
+ Lord Protector
+ King-Emperor
+ Rex
+ Lord Of The Manor
+ High King
+ Crown Prince
+ Grand Prince
+ Praetor
+ Headmaster
[female-title] Ms.
Mrs.
@@ -107,51 +101,51 @@ pragma export-rule [random-name]
Mistress
Aunt
Lady Mayoress
- princess
- arch duchess
- grand duchess
- duchess
- marquise
- marchioness
- countess
- viscountess
- baroness
- lady
- empress
- queen
- tsarina
- imperatrix
- rex
- vicerine
- popess
- dame
- abbess
- sister
- mother superior
- mother
- reverend mother
- priestess
- high priestess
- matriarch
- madame
- mademoiselle
- frau
- fraulein
- senora
- senorita
- signora
- signorina
- emira
- sultana
- maharani
- lady protectoress
- queen-empress
- regina
- lady of the manor
- high queen
- crown princess
- grand princess
- headmistress
+ Princess
+ Arch Duchess
+ Grand Duchess
+ Duchess
+ Marquise
+ Marchioness
+ Countess
+ Viscountess
+ Baroness
+ Lady
+ Empress
+ Queen
+ Tsarina
+ Imperatrix
+ Rex
+ Vicerine
+ Popess
+ Dame
+ Abbess
+ Sister
+ Mother Superior
+ Mother
+ Reverend Mother
+ Priestess
+ High Priestess
+ Matriarch
+ Madame
+ Mademoiselle
+ Frau
+ Fraulein
+ Senora
+ Senorita
+ Signora
+ Signorina
+ Emira
+ Sultana
+ Maharani
+ Lady Protectoress
+ Queen-Empress
+ Regina
+ Lady Of The Manor
+ High Queen
+ Crown Princess
+ Grand Princess
+ Headmistress
[gender-neutral-title] Dr.
Professor
@@ -172,188 +166,186 @@ pragma export-rule [random-name]
[ambassador]
[envoy]
[secretary]
- attache
- attache ( to [full-name-and-title] )
- provost
- chevalier
+ Attache
+ Attache ( to [full-name-and-title] )
+ Provost
+ Chevalier
[judicial-title]
[religious-title]
[military-title]
- coach
- wizard
- grand wizard
- imperial wizard
- principal
- comrade
- docent
- lama
- druid
- archdruid
- rabbi
- ayatollah
- bodhisattva
- saoshyant
- sheikh
- archon
- legate
- satrap
- consul
- doge
- pharaoh
- caliph
- khagan
- khan
- shah
- shogun
- despot
- kaiser
- don
- comissioner
- comptroller
- courtier
+ Coach
+ Wizard
+ Grand Wizard
+ Imperial Wizard
+ Principal
+ Comrade
+ Docent
+ Lama
+ Druid
+ Archdruid
+ Rabbi
+ Ayatollah
+ Bodhisattva
+ Saoshyant
+ Sheikh
+ Archon
+ Legate
+ Satrap
+ Consul
+ Doge
+ Pharaoh
+ Caliph
+ Khagan
+ Khan
+ Shah
+ Shogun
+ Despot
+ Kaiser
+ Don
+ Comissioner
+ Comptroller
+ Courtier
courtier (to [full-name-and-title] )
- curator
- intendant
- superindentent
- sheriff
- treasurer
- warden
- lord warden
- apprentice
+ Curator
+ Intendant
+ Superindentent
+ Sheriff
+ Treasurer
+ Warden
+ Lord Warden
+ Apprentice
apprentice (to a [generic-title] )
apprentice (to [full-name-and-title] )
- journeyman
- adept
- centurion
- daimyo
- elector
- inquisitor
- grand inquisitor
- pontiff
- knight
- squire
+ Journeyman
+ Adept
+ Centurion
+ Daimyo
+ Elector
+ Inquisitor
+ Grand Inquisitor
+ Pontiff
+ Knight
+ Squire
squire (to [full-name-and-title] )
-[military-title] admiral
- grand admiral
- lord high admiral
- rear admiral
- vice admiral
- brigadier
- captain
- group captain
- colonel
- lieutenant colonel
- commander
- commander-in-chief
- lieutenant commander
- wing commander
- commodore
- air commodore
- corporal
- lance corporal
- staff corporal
- general
- first lieutenant
- flight lieutenant
- major
- marshal
- air marshal
- field marshal
- mate
- chief mate
- first mate
+[military-title] mdmiral
+ Grand Admiral
+ Lord High Admiral
+ Rear Admiral
+ Vice Admiral
+ Brigadier
+ Captain
+ Group Captain
+ Colonel
+ Lieutenant Colonel
+ Commander
+ Commander-In-Chief
+ Lieutenant Commander
+ Wing Commander
+ Commodore
+ Air Commodore
+ Corporal
+ Lance Corporal
+ Staff Corporal
+ General
+ First Lieutenant
+ Flight Lieutenant
+ Major
+ Marshal
+ Air Marshal
+ Field Marshal
+ Mate
+ Chief Mate
+ First Mate
[officer]
- private
- sergeant
- sergeant at arms
- brigadier general
- cadet
- ensign
+ Private
+ Sergeant
+ Sergeant At Arms
+ Brigadier General
+ Cadet
+ Ensign
-[officer] officer
- chief academic officer
- chief executive officer
- chief information officer
- chief operating officer
- field officer
- first officer
- flag officer
- warrant officer
- petty officer
- police officer
- political officer
- senior officer
- staff officer
- police officer
- constable
- agent
+[officer] Officer
+ Chief Academic Officer
+ Chief Executive Officer
+ Chief Information Officer
+ Chief Operating Officer
+ Field Officer
+ First Officer
+ Flag Officer
+ Warrant Officer
+ Petty Officer
+ Police Officer
+ Political Officer
+ Senior Officer
+ Staff Officer
+ Police Officer
+ Constable
+ Agent
-[religious-title] venerable
- blessed
+[religious-title] Venerable
+ Blessed
Saint
St.
- decon
- archdeacon
- acolyte
- dean
- elder
- minister
- monsignor
- reader
- almoner
+ Decon
+ Archdeacon
+ Acolyte
+ Dean
+ Elder
+ Minister
+ Monsignor
+ Reader
+ Almoner
-[judicial-title] advocate
- attorney
- attorney general
- bailiff
- chancellor
- judge
- justice
- lord chief justice
- justice of the peace
- magistrate
- solicitor
+[judicial-title] Advocate
+ Attorney
+ Attorney General
+ Bailiff
+ Chancellor
+ Judge
+ Justice
+ Lord Chief Justice
+ Justice Of The Peace
+ Magistrate
+ Solicitor
-[president] president
- deputy president
- vice president
- executive vice president
- lord president of the council
+[president] President
+ Deputy President
+ Vice President
+ Executive Vice President
+ Lord President Of The Council
-[ambassador] ambassador
- ambassador (to [nation] )
+[ambassador] Ambassador
+ Ambassador (to [nation] )
-[envoy] envoy
- envoy (to [nation] )
- envoy (to the [generic-title] )
+[envoy] Envoy
+ Envoy (to [nation] )
+ Envoy (to the [generic-title] )
envoy (to [full-name-and-title] )
- special envoy
- special envoy (to [nation] )
- special envoy (to the [generic-title] )
- special envoy (to [full-name-and-title] )
+ Special Envoy
+ Special Envoy (to [nation] )
+ Special Envoy (to the [generic-title] )
+ Special Envoy (to [full-name-and-title] )
-[secretary] secretary
- secretary (to [full-name-and-title] )
- secretary (to the [generic-title] )
- under-secretary
- under-secretary (to [full-name-and-title] )
- under-secretary (to the [generic-title] )
- foreign secretary
- general secretary
- secretary of state
+[secretary] Secretary
+ Secretary (to [full-name-and-title] )
+ Secretary (to the [generic-title] )
+ Under-Secretary
+ Under-Secretary (to [full-name-and-title] )
+ Under-Secretary (to the [generic-title] )
+ Foreign Secretary
+ General Secretary
+ Secretary Of State
pragma suffix-with [full-name-and-title] [title-generation]
-pragma suffix-with [full-name-and-title] [title-suffix]
-pragma suffix-with [full-name-and-title] [title-suffix]
-pragma suffix-with [full-name-and-title] [title-suffix]
+pragma suffix-with [full-name-and-title] <&1..3> [title-suffix]
[title-generation] Sr.
Jr.
[roman-numeral]
- the [roman-numeral]
- the [ordinal]
- the [ordinal-number]
+ The [roman-numeral]
+ The [ordinal]
+ The [ordinal-number]
[title-trailer] CPA
Ph.D
@@ -423,9 +415,9 @@ pragma suffix-with [full-name-and-title] [title-suffix]
[random-name] [actual+random-name]
-[actual+random-name] [syllable] [syllable]
- [syllable] [syllable] [last-syllable]
+[actual+random-name] <&1..3> [syllable]
+ <&1..3> [syllable] [last-syllable]
[syllable] [vowel] [consonant-group] [vowel]
[consonant-group] [vowel] [syllable]
- [vowel] [syllable] [syllable]
+ [vowel] <&1..3> [syllable]
[syllable] [vowel-group] [consonant]
diff --git a/data/sample-grammars/newspaper.gram b/data/sample-grammars/newspaper.gram
index afa91ee..afa91ee 100644..100755
--- a/data/sample-grammars/newspaper.gram
+++ b/data/sample-grammars/newspaper.gram
diff --git a/data/sample-grammars/numbers.gram b/data/sample-grammars/numbers.gram
index 4db84b9..a494fab 100644..100755
--- a/data/sample-grammars/numbers.gram
+++ b/data/sample-grammars/numbers.gram
@@ -8,12 +8,12 @@ pragma export-rule [small-number]
pragma export-rule [medium-number]
pragma export-rule [zipcode]
-[actual+small-number] [digit-nonzero]
- [digit-nonzero] [digit]
- [digit-nonzero] [digit] [digit]
+[actual+small-number] [1..9]
+ [1..9] [0..9]
+ [1..9] [0..9] [0..9]
-[actual+medium-number] [digit-nonzero] [digit] [digit]
- [digit-nonzero] [digit] [digit] [digit]
- [digit-nonzero] [digit] [digit] [digit] [digit]
+[actual+medium-number] [1..9] [0..9] [0..9]
+ [1..9] [0..9] [0..9] [0..9]
+ [1..9] [0..9] [0..9] [0..9] [0..9]
-[actual+zipcode] [digit] [digit] [digit] [digit] [digit]
+[actual+zipcode] [0..9] [0..9] [0..9] [0..9] [0..9]
diff --git a/data/sample-grammars/ordinal.gram b/data/sample-grammars/ordinal.gram
index da4aa4e..70e9b39 100644..100755
--- a/data/sample-grammars/ordinal.gram
+++ b/data/sample-grammars/ordinal.gram
@@ -3,10 +3,10 @@
pragma export-rule [ordinal-number]
[actual+ordinal-number] [ordinal-digit]
- 1 [digit] th
- [digit-twoup] [ordinal-digit]
- [digit-twoup] [ordinal-digit]
- [digit-nonzero] [ordinal-number]
+ 1 [0..9] th
+ [2..9] [ordinal-digit]
+ [2..9] [ordinal-digit]
+ [1..9] [ordinal-number]
[ordinal-digit] 1st
2nd
diff --git a/data/sample-grammars/organization.gram b/data/sample-grammars/organization.gram
index 9c88686..0101aa1 100644..100755
--- a/data/sample-grammars/organization.gram
+++ b/data/sample-grammars/organization.gram
@@ -1,15 +1,14 @@
[organization-desc] [org-political]
-[org-postfix] (allies of [org-political] )
+[org-postfix] <^3> {empty}
+ (allies of [org-political] )
(enemies of [org-political] )
(secretly opposed to [org-political] )
(secretly in cohorts with [org-political] )
(based in [city] )
(based in [town-name] )
-pragma suffix-with [organization-desc] [org-postfix]
-pragma suffix-with [organization-desc] [org-postfix]
-pragma suffix-with [organization-desc] [org-postfix]
+pragma suffix-with [organization-desc] <&1..3> [org-postfix]
[organization] [org-political]
@@ -119,7 +118,7 @@ pragma prefix-with [org-goal] [org-goal-abolish]
wealth
filthy rich
-[min+wage] [9..20] . [digit] [digit]
+[min+wage] [9..20] . [0..9] [0..9]
[protect] bill of rights
first amendment
diff --git a/data/sample-grammars/part-creature.gram b/data/sample-grammars/part-creature.gram
index 41bbb83..5875ea1 100755
--- a/data/sample-grammars/part-creature.gram
+++ b/data/sample-grammars/part-creature.gram
@@ -16,12 +16,8 @@ pragma prefix-with [creature-choice] [abilities]
pragma initial-rule [full-creature]
pragma export-rule [creature-choice]
-[abilities] [ability]
- [ability]
- [ability]
- [ability]
- [quote-ability] and [quote-ability]
- [quote-ability] and [quote-ability]
+[abilities] <^4> [ability]
+ <^2> [quote-ability] and [quote-ability]
[quote-ability] , [quote-ability] and [quote-ability]
[quote-ability] ( [ability] )
@@ -60,12 +56,8 @@ pragma despace-rule [eating]
# @TODO 10/26/17 Ben Culkin :CharacteristicAdditions
# Add more templates and classes to the list
-[characteristics] [characteristic]
- [characteristic]
- [characteristic]
- [characteristic]
- [quote-characteristic] and [quote-characteristic]
- [quote-characteristic] and [quote-characteristic]
+[characteristics] <^4> [characteristic]
+ <^2> [quote-characteristic] and [quote-characteristic]
[quote-characteristic] , [quote-characteristic] and [quote-characteristic]
[quote-characteristic] ( [characteristic] )
diff --git a/data/sample-grammars/phone-number.gram b/data/sample-grammars/phone-number.gram
index 163ef4a..e9c3a7c 100644..100755
--- a/data/sample-grammars/phone-number.gram
+++ b/data/sample-grammars/phone-number.gram
@@ -10,20 +10,18 @@
pragma suffix-with [us-phone-number] [extension]
pragma export-rule [us-phone-number]
-[area+code] ( [digit] [digit] [digit] )
+[area+code] ( [0..9] [0..9] [0..9] )
-[full+num] [digit] [digit] [digit] - [digit] [digit] [digit] [digit]
+[full+num] [0..9] [0..9] [0..9] - [0..9] [0..9] [0..9] [0..9]
[intl+num] [1..100] - [full+num]
-[ext+num] [digit-nonzero] [digit] [digit]
+[ext+num] [1..9] [0..9] [0..9]
-pragma suffix-with [ext+num] [digit]
-pragma suffix-with [ext+num] [digit]
-pragma suffix-with [ext+num] [digit]
+pragma suffix-with [ext+num] <&1..3> [0..9]
-[letter+num] [digit] [digit] [digit] - [letter] [letter] [letter] [letter]
+[letter+num] [0..9] [0..9] [0..9] - [letter] [letter] [letter] [letter]
-[1800+num] 1-800- [digit] [digit] [digit] - [digit] [digit] [digit] [digit]
+[1800+num] 1-800- [0..9] [0..9] [0..9] - [0..9] [0..9] [0..9] [0..9]
[1800+letter+num] 1-800- [letter] [letter] [letter] [letter] [letter] [letter] [letter]
diff --git a/data/sample-grammars/pokeattacks.gram b/data/sample-grammars/pokeattacks.gram
index 649f42c..dcbd770 100755
--- a/data/sample-grammars/pokeattacks.gram
+++ b/data/sample-grammars/pokeattacks.gram
@@ -1,29 +1,24 @@
-[pokeattack] [pokeattack-name]
+[pokeattack] {@oword:=[word-1]} {@tword:=[word-2]} {@ptype:=[poke-type]} [act-pokeattack]
-[attack-type] ( [poke-type] type)
- ( [poke-type] / [poke-type] type)
+[act-pokeattack] [pokeattack-name]
+
+[attack-type] ( [@ptype] type)
+ ( [@ptype] / [@ptype] type)
[attack-pp] ( [5..40] pp )
-pragma despace-rule [attack-type]
-pragma despace-rule [attack-pp]
-
-pragma suffix-with [pokeattack] [move-kind]
-pragma suffix-with [pokeattack] [attack-type]
-pragma suffix-with [pokeattack] [attack-pp]
-
-[pokeattack-name] [word-1] [word-1]
- [word-2] [word-2]
- [word-1] [word-2]
- [word-2] [word-1]
- [word-1] [seperator] [word-1]
- [word-2] [seperator] [word-2]
- [word-1] [seperator] [word-2]
- [word-2] [seperator] [word-1]
- [word-1] [seperator] [word-1]
- [word-2] [seperator] [word-2]
- [word-1] [seperator] [word-2]
- [word-2] [seperator] [word-1]
+pragma suffix-with [act-pokeattack] [move-kind]
+pragma suffix-with [act-pokeattack] [attack-type]
+pragma suffix-with [act-pokeattack] [attack-pp]
+
+[pokeattack-name] <^2> <&1..2> [@oword] [@oword]
+ <^2> <&1..2> [@tword] [@tword]
+ <^2> [@oword] [@tword]
+ <^2> [@tword] [@oword]
+ [@oword] [seperator] [@oword]
+ [@oword] [seperator] [@tword]
+ [@tword] [seperator] [@oword]
+ [@tword] [seperator] [@tword]
[seperator] -
/
@@ -54,16 +49,16 @@ pragma suffix-with [pokeattack] [attack-pp]
pragma initial-rule [pokeattack]
pragma export-rule [pokeattack-name]
-[word-11] [word-1]
+[word-11] [@oword]
pragma suffix-with [word-11] [seperator]
-[word-21] [word-2]
+[word-21] [@tword]
pragma prefix-with [word-21] [seperator]
-pragma prefix-with [pokeattack-name] [word-1]
-pragma suffix-with [pokeattack-name] [word-2]
+pragma prefix-with [pokeattack-name] [word-11]
+pragma suffix-with [pokeattack-name] [word-21]
[word-1] acid
aerial
diff --git a/data/sample-grammars/president.gram b/data/sample-grammars/president.gram
index 63b928c..4312f4e 100644..100755
--- a/data/sample-grammars/president.gram
+++ b/data/sample-grammars/president.gram
@@ -1,64 +1,66 @@
-[us-president] george washington
- john adams
- thomas jefferson
- james madison
- james monroe
- john quincy adams
- andrew jackson
- martin van buren
- william henry harrison
- john tyler
- james polk
- zachary taylor
- millard fillmore
- franklin pierce
- james buchanan
- abraham lincoln
- andrew johnson
- ulysses s grant
- rutherford b. hayes
- james garfield
- chester a. arthur
- grover cleveland
- benjamin harrison
- william mckinley
- theodore roosevelt
- william taft
- woodrow wilson
- warren g. harding
- calvin coolidge
- herbert hoover
- franklin d. roosevelt
- harry s truman
- dwight eisenhower
- john f. kennedy
- lyndon b. johnson
- richard nixon
- gerald ford
- jimmie carter
- ronald reagan
- george bush
- bill clinton
- george w. bush
- barack obama
- donald trump
+[us-president] George Washington
+ John Adams
+ Thomas Jefferson
+ James Madison
+ James Monroe
+ John Quincy Adams
+ Andrew Jackson
+ Martin Van Buren
+ William Henry Harrison
+ John Tyler
+ James Polk
+ Zachary Taylor
+ Millard Fillmore
+ Franklin Pierce
+ James Buchanan
+ Abraham Lincoln
+ Andrew Johnson
+ Ulysses S Grant
+ Rutherford B. Hayes
+ James Garfield
+ Chester A. Arthur
+ Grover Cleveland
+ Benjamin Harrison
+ William Mckinley
+ Theodore Roosevelt
+ William Taft
+ Woodrow Wilson
+ Warren G. Harding
+ Calvin Coolidge
+ Herbert Hoover
+ Franklin D. Roosevelt
+ Harry S Truman
+ Dwight Eisenhower
+ John F. Kennedy
+ Lyndon B. Johnson
+ Richard Nixon
+ Gerald Ford
+ Jimmie Carter
+ Ronald Reagan
+ George Bush
+ Bill Clinton
+ George W. Bush
+ Barack Obama
+ Donald Trump
[us-president-common] washington
- adams
- jefferson
- madison
- monroe
- adams
- jackson
- van buren
- harrison
- taylor
- lincoln
- johnson
- garfield
- roosevelt
- wilson
- truman
+ Adams
+ Jefferson
+ Madison
+ Monroe
+ Adams
+ Jackson
+ Van Buren
+ Harrison
+ Taylor
+ Lincoln
+ Johnson
+ Garfield
+ Roosevelt
+ Wilson
+ Truman
+ Obama
+ Trump
pragma export-rule [us-president]
pragma export-rule [us-president-common]
diff --git a/data/sample-grammars/rtwiki/adjective.gram b/data/sample-grammars/rtwiki/adjective.gram
index 09168aa..487b0bf 100644..100755
--- a/data/sample-grammars/rtwiki/adjective.gram
+++ b/data/sample-grammars/rtwiki/adjective.gram
@@ -22,6 +22,8 @@
leaping
prancing
+pragma export-rule [adjective1]
+
[adjective2] curious
happy
lusty
@@ -32,3 +34,5 @@
zealous
angry
vulgar
+
+pragma export-rule [adjective2]
diff --git a/data/sample-grammars/rtwiki/bodyparts.gram b/data/sample-grammars/rtwiki/bodyparts.gram
index 71b4924..71b4924 100644..100755
--- a/data/sample-grammars/rtwiki/bodyparts.gram
+++ b/data/sample-grammars/rtwiki/bodyparts.gram
diff --git a/data/sample-grammars/rtwiki/class.gram b/data/sample-grammars/rtwiki/class.gram
index 8fcb17c..8fcb17c 100644..100755
--- a/data/sample-grammars/rtwiki/class.gram
+++ b/data/sample-grammars/rtwiki/class.gram
diff --git a/data/sample-grammars/rtwiki/color.gram b/data/sample-grammars/rtwiki/color.gram
index 346f73b..87aaae2 100644..100755
--- a/data/sample-grammars/rtwiki/color.gram
+++ b/data/sample-grammars/rtwiki/color.gram
@@ -1,15 +1,13 @@
-[color-phrases] [color-phrase]
- [multi-color-phrases]
-
-[multi-color-phrases] [color-phrase] blended with [color-phrase]
+[color-phrases] <^8> [color-phrase]
+ <^2> [color-phrase] blended with [color-phrase]
a blend between [color-phrase] , [color-phrase] and [color-phrase]
- something between [color-phrase] and [color-phrase]
+ <^2> something between [color-phrase] and [color-phrase]
something between [color-phrase] , [color-phrase] and [color-phrase]
pragma initial-rule [color-phrases]
-[color-phrase] [complete-color]
- [sw-complete-color]
+[color-phrase] <^2> [complete-color]
+ <^2> [sw-complete-color]
[sw-complete-color] [complete-color]
[sw-complete-color] - [complete-color]
[sw-complete-color] [sw-complete-color]
@@ -17,15 +15,14 @@ pragma initial-rule [color-phrases]
pragma export-rule [color-phrase]
-[sw-color-phrase] [sw-complete-color]
+[sw-color-phrase] <^2> [sw-complete-color]
[sw-complete-color] [sw-complete-color]
[sw-complete-color] - [sw-complete-color]
pragma export-rule [sw-color-phrase]
-[complete-color] {wtype=mw} [act-complete-color]
+[complete-color] {$wtype=mw} [act-complete-color]
-pragma despace-rule [complete-color]
pragma export-rule [complete-color]
[sw-complete-color] [act-sw-complete-color]
@@ -34,9 +31,7 @@ pragma export-rule [complete-color]
pragma despace-rule [sw-complete-color]
pragma export-rule [sw-complete-color]
-[act-sw-complete-color] {wtype=sw} [act-complete-color]
-
-pragma despace-rule [act-sw-complete-color]
+[act-sw-complete-color] {$wtype=sw} [act-complete-color]
[act-complete-color] [standard]
[red-purple]
@@ -46,6 +41,7 @@ pragma despace-rule [act-sw-complete-color]
[jewel]
[metallic]
[heraldic]
+ [other-color]
[other-color] [archaic-purple]
[archaic-green]
@@ -71,7 +67,7 @@ pragma despace-rule [act-sw-complete-color]
ivory
white
blue-gray
- [gray]
+ [gray||grey]
black
ebony
copper
@@ -83,35 +79,26 @@ pragma despace-rule [act-sw-complete-color]
[$wtype-standard]
transparent
-[gray] gray
- grey
-
[sw-standard] iridescent
opalescent
rainbow
-[mw-standard] [iridescent]
- [opalescent]
- [ombre]
- [rainbow]
+[mw-standard] [%iridescent||%opalescent||%ombre||%rainbow]
-[iridescent] iridescent [color]
+[iridescent] <^2> iridescent [color]
iridescent between [color] and [color]
[opalescent] opalescent [color]
[ombre] [color] (tinted [color] )
-[rainbow] rainbow of red, orange, yellow, green, blue, indigo and violet
- [custom-rainbow]
+[rainbow] <^2> rainbow of red, orange, yellow, green, blue, indigo and violet
[custom-rainbow] rainbow of [color]
pragma suffix-with [custom-rainbow] [com-color]
pragma suffix-with [custom-rainbow] [com-color]
-pragma suffix-with [custom-rainbow] [com-color]
-pragma suffix-with [custom-rainbow] [com-color]
-pragma suffix-with [custom-rainbow] [com-color]
+pragma suffix-with [custom-rainbow] <&1..3> [com-color]
pragma suffix-with [custom-rainbow] [and-color]
[com-color] , [color]
@@ -373,10 +360,9 @@ pragma suffix-with [custom-rainbow] [and-color]
sulphureous (bright yellow)
urobilin (urine-colored)
-[arcipluvian] (varies between [color] and [color] )
- (varies between [color] , [color] and [color] )
+[arcipluvian] <^4> (varies between [color] and [color] )
+ <^2> (varies between [color] , [color] and [color] )
(varies between [color] , [color] , [color] and [color] )
- (varies between [color] , [color] and [color] )
[archaic-green] [$wtype-archaic-green]
diff --git a/data/sample-grammars/rtwiki/creature.gram b/data/sample-grammars/rtwiki/creature.gram
index b3f7b92..b3f7b92 100644..100755
--- a/data/sample-grammars/rtwiki/creature.gram
+++ b/data/sample-grammars/rtwiki/creature.gram
diff --git a/data/sample-grammars/rtwiki/death-cause.gram b/data/sample-grammars/rtwiki/death-cause.gram
index 74e58e8..3ad27ea 100644..100755
--- a/data/sample-grammars/rtwiki/death-cause.gram
+++ b/data/sample-grammars/rtwiki/death-cause.gram
@@ -99,10 +99,10 @@
by crucifixion
by act of god
-[Monster/Animals] {{empty}}
+[Monster/Animals] {empty}
-[Character/Torture] {{empty}}
+[Character/Torture] {empty}
-[Character/Deaths] {{empty}}
+[Character/Deaths] {empty}
pragma export-rule [death-cause]
diff --git a/data/sample-grammars/rtwiki/fantasy-name.gram b/data/sample-grammars/rtwiki/fantasy-name.gram
index c4ce02e..ca3203f 100644..100755
--- a/data/sample-grammars/rtwiki/fantasy-name.gram
+++ b/data/sample-grammars/rtwiki/fantasy-name.gram
@@ -1,10 +1,19 @@
-[fantasy-name] [fantasy+name]
+[fantasy-name] <^6> [fantasy+name]
+ <^2> <&2> [fantasy+name]
+ <&3> [fantasy+name]
pragma initial-rule [fantasy-name]
-[fantasy+name] [name-root1] [name-root2]
- [name-root1] [name-root3]
- [name-root1] [name-root2] [name-root3]
+[fantasy+name] [name-root1]
+
+pragma suffix-with [fantasy+name] <&1..2> [name-root2] [name-root3]
+pragma prefix-with [fantasy+name] [hname-root1]
+
+[hname-root1] <^3> {empty}
+ [name-root1] -
+
+[hname-root3] <^3> {empty}
+ - [name-root3]
[name-root1] ag
al
diff --git a/data/sample-grammars/rtwiki/favorite.gram b/data/sample-grammars/rtwiki/favorite.gram
index ba1468a..47141f0 100644..100755
--- a/data/sample-grammars/rtwiki/favorite.gram
+++ b/data/sample-grammars/rtwiki/favorite.gram
@@ -1,11 +1,7 @@
-[favorite-food] My favorite foods are [fruit] , [vegetable] and [meat]
+[favorite-food] My favorite foods are [apple||banana||cherry] , [vegetable] and [meat]
pragma initial-rule [favorite-food]
-[fruit] apple
- banana
- cherry
-
[vegetable] potato
okra
brussel sprouts
@@ -16,7 +12,7 @@ pragma initial-rule [favorite-food]
green beans
[meat] hamburgers
- hot dogs
+ hot dog
salmon
beef
chicken
diff --git a/data/sample-grammars/rtwiki/guns.gram b/data/sample-grammars/rtwiki/guns.gram
index aafab8c..ec370a2 100644..100755
--- a/data/sample-grammars/rtwiki/guns.gram
+++ b/data/sample-grammars/rtwiki/guns.gram
@@ -5,21 +5,17 @@
[quote-guncorp] was bought by [quote-guncorp]
[quote-guncorp] 's [quote-gunname] vs. [quote-guncorp] 's [quote-gunname] : cost vs. quality
-[quote-gunname] [gun-name]
+[quote-gunname] ( [gun-name] )
-[quote-guncorp] [guncorp]
+[quote-guncorp] ( [guncorp] )
pragma initial-rule [gun-phrase]
-[gun-name] [1gun-name]
- [2gun-name2]
- [1gun-name]
- [2gun-name2]
- [1gun-name]
- [2gun-name2]
- [2gun-name1] [2gun-name2]
- [2gun-name1] [1gun-name]
- [1gun-name] [2gun-name2]
+[gun-name] <^4> [1gun-name]
+ <^4> [2gun-name2]
+ <^2> [2gun-name1] [2gun-name2]
+ <^2> [2gun-name1] [1gun-name]
+ <^2> [1gun-name] [2gun-name2]
[2gun-name1] [1gun-name] [2gun-name2]
pragma prefix-with [gun-name] [2gun-name1]
@@ -149,11 +145,9 @@ pragma export-rule [gun-name]
Poisoner
Remedy
-[guncorp] [guncorp-1]
- [guncorp-1] [guncorp-2]
- [guncorp-1] [guncorp-2]
- [guncorp-1] [guncorp-2]
- [guncorp-1] [guncorp-1] [guncorp-2]
+[guncorp] <^2> [guncorp-1]
+ <^3> [guncorp-1] [guncorp-2]
+ <&1..2> [guncorp-1] [guncorp-2]
[guncorp-1] - [guncorp-1] [guncorp-2]
[guncorp-1] and [guncorp-1] [guncorp-2]
[guncorp-1] / [guncorp-1] [guncorp-2]
diff --git a/data/sample-grammars/rtwiki/item.gram b/data/sample-grammars/rtwiki/item.gram
index fdee69c..47c5621 100644..100755
--- a/data/sample-grammars/rtwiki/item.gram
+++ b/data/sample-grammars/rtwiki/item.gram
@@ -1,15 +1,14 @@
-[item] [act-item]
- [act-item]
+[item] <^2> [act-item]
[act-item] of the [act-item]
+pragma initial-rule [item]
+
[act-item] [body]
[music]
[symbol]
[thing]
[weapon]
-pragma initial-rule [item]
-
[body] arm
open eye
closed eye
diff --git a/data/sample-grammars/rtwiki/traits.gram b/data/sample-grammars/rtwiki/traits.gram
index c3ff790..c3ff790 100644..100755
--- a/data/sample-grammars/rtwiki/traits.gram
+++ b/data/sample-grammars/rtwiki/traits.gram
diff --git a/data/sample-grammars/rune.gram b/data/sample-grammars/rune.gram
index 4c64e5a..79499f3 100755
--- a/data/sample-grammars/rune.gram
+++ b/data/sample-grammars/rune.gram
@@ -1,19 +1,14 @@
-# @TODO 10/23/17 Ben Culkin :RuneDebug
-# Something seems to be wrong with this grammar, and I'm not sure as to
-# the exact details.
-#
-# The problem is that we are getting multiple runes running together
-# without an obvious cause.
+[rune-string] {@1rune:=[rune-1]} {@2rune:=[rune-2]} {@3rune:=[rune-3]} [act-rune-string]
-[rune-string] [rune-2]
- [rune-1] [rune-2]
- [rune-1] [rune-2] [rune-3]
- [rune-2] [rune-3]
+[act-rune-string] [@2rune]
+ [@1rune] [@2rune]
+ [@1rune] [@2rune] [@3rune]
+ [@2rune] [@3rune]
pragma initial-rule [rune-string]
-pragma prefix-with [rune-string] [rune-1]
-pragma suffix-with [rune-string] [rune-3]
+pragma prefix-with [act-rune-string] [@1rune]
+pragma suffix-with [act-rune-string] [@3rune]
[rune-1] a dagger plunged into
vines growing out of
diff --git a/data/sample-grammars/school.gram b/data/sample-grammars/school.gram
index cd9298b..cd9298b 100644..100755
--- a/data/sample-grammars/school.gram
+++ b/data/sample-grammars/school.gram
diff --git a/data/sample-grammars/slashdot.gram b/data/sample-grammars/slashdot.gram
index 2b38ee3..2b38ee3 100644..100755
--- a/data/sample-grammars/slashdot.gram
+++ b/data/sample-grammars/slashdot.gram
diff --git a/data/sample-grammars/states.gram b/data/sample-grammars/states.gram
index 43f1402..ee4f547 100644..100755
--- a/data/sample-grammars/states.gram
+++ b/data/sample-grammars/states.gram
@@ -1,53 +1,53 @@
-[us-state] alabama
- alaska
- arizona
- arkansas
- california
- colorado
- connecticut
- delaware
- florida
- georgia
- hawaii
- idaho
- illinois
- indiana
- iowa
- kansas
- kentucky
- louisiana
- maine
- maryland
- massachusetts
- michigan
- minnesota
- mississippi
- missouri
- montana
- nebraska
- nevada
- new hampshire
- new jersey
- new mexico
- new york
- north carolina
- north dakota
- ohio
- oklahoma
- oregon
- pennsylvania
- rhode island
- south carolina
- south dakota
- tennessee
- texas
- utah
- vermont
- virginia
- washington
- west virginia
- wisconsin
- wyoming
+[us-state] Alabama
+ Alaska
+ Arizona
+ Arkansas
+ California
+ Colorado
+ Connecticut
+ Delaware
+ Florida
+ Georgia
+ Hawaii
+ Idaho
+ Illinois
+ Indiana
+ Iowa
+ Kansas
+ Kentucky
+ Louisiana
+ Maine
+ Maryland
+ Massachusetts
+ Michigan
+ Minnesota
+ Mississippi
+ Missouri
+ Montana
+ Nebraska
+ Nevada
+ New Hampshire
+ New Jersey
+ New Mexico
+ New York
+ North Carolina
+ North Dakota
+ Ohio
+ Oklahoma
+ Oregon
+ Pennsylvania
+ Rhode Island
+ South Carolina
+ South Dakota
+ Tennessee
+ Texas
+ Utah
+ Vermont
+ Virginia
+ Washington
+ West Virginia
+ Wisconsin
+ Wyoming
pragma export-rule [us-state]
pragma export-rule [us-postalstate]
diff --git a/data/sample-grammars/superhero.gram b/data/sample-grammars/superhero.gram
index cdb609f..b9fab59 100755
--- a/data/sample-grammars/superhero.gram
+++ b/data/sample-grammars/superhero.gram
@@ -5,14 +5,9 @@ pragma initial-rule [superhero-desc]
[superhero-postfix] [superhero-ally]
[superhero-enemy]
-pragma suffix-with [superhero-desc] [superhero-postfix]
-pragma suffix-with [superhero-desc] [superhero-postfix]
-pragma suffix-with [superhero-desc] [superhero-postfix]
-
+pragma suffix-with [superhero-desc] <&1..3> [superhero-postfix]
pragma suffix-with [superhero-desc] [superhero-secret]
-
-pragma suffix-with [superhero-desc] [superhero-org]
-pragma suffix-with [superhero-desc] [superhero-org]
+pragma suffix-with [superhero-desc] <&1..2> [superhero-org]
[superhero-ally] (ally of [superhero-name] )
(secret ally of [superhero-name] )
@@ -37,15 +32,15 @@ pragma suffix-with [superhero-desc] [superhero-org]
(second in command of the [organization] )
( [generic-title] of the [organization] )
-[superhero-name] [first-part] [second-part]
- [second-part] [first-part]
-
-pragma export-rule [superhero-name]
+[superhero-name] {empty}
+pragma prefix-with [superhero-name] [first-part] [second-part]
pragma suffix-with [superhero-name] [third-part]
+pragma prefix-with [superhero-name] [third-part2]
pragma suffix-with [superhero-name] [fourth-part]
pragma suffix-with [superhero-name] [fifth-part]
-pragma prefix-with [superhero-name] [third-part2]
+
+pragma export-rule [superhero-name]
[fifth-part] and the [third-part2]
and [third-part2]
@@ -123,8 +118,7 @@ pragma suffix-with [fifth-part] [fourth-part]
Torch
Magus
Wizard
- [second-class]
- [second-class]
+ <^2> [second-class]
[second-class] Rider
Caster
@@ -137,6 +131,11 @@ pragma suffix-with [fifth-part] [fourth-part]
Ruler
Shielder
Avenger
+ Foreigner
+ Alter Ego
+ Moon Cancer
+
+pragma prefix-with [second-class] Grand
[third-part] ,The [third-part2]
@@ -219,8 +218,7 @@ pragma suffix-with [third-part] [fifth-part]
Deadly
Flaming
Thunderer
- [major-arcana]
- [major-arcana]
+ <^2> [major-arcana]
Cardinal
Bishop
Archbishop
@@ -231,14 +229,12 @@ pragma suffix-with [third-part] [fifth-part]
Motherly
Sinister
Embodiment
- [generic-title]
- [generic-title]
+ <^2> [generic-title]
[fourth-part] of [fourth-part-act]
[fourth-part-act] the [fourth-part-the]
- [harrowed-many-things]
- [harrowed-many-things]
+ <^2> [harrowed-many-things]
Hope
Destiny
Justice
@@ -249,10 +245,8 @@ pragma suffix-with [third-part] [fifth-part]
Knowledge
Earth
Eternal Fire
- [planet]
- [planet]
- [second-part]
- [second-part]
+ <^2> [planet]
+ <^2> [second-part]
[planet] Earth
Mars
@@ -282,12 +276,9 @@ pragma suffix-with [third-part] [fifth-part]
Ancients
Archive
Moon
- [generic-title]
- [generic-title]
- [exalt-type]
- [exalt-type]
- [arcana]
- [arcana]
+ <^2> [generic-title]
+ <^2> [exalt-type]
+ <^2> [arcana]
[exalt-type] Dawn
Zenith
@@ -295,10 +286,11 @@ pragma suffix-with [third-part] [fifth-part]
Night
Eclipse
-[arcana] [tarot-card]
- Arcana
+[arcana] [%tarot-card||%alt-tarot-card]
Minor Arcana
Major Arcana
- [ordinal-roman] Arcana
- [ordinal-number] Arcana
- [ordinal] Arcana
+ <^3> [ordinal-arcana]
+
+[ordinal-arcana] {empty}
+
+pragma prefix-with [ordinal-arcana] Arcana [%ordinal||%ordinal-roman||%ordinal-number]
diff --git a/data/sample-grammars/tarotcard.gram b/data/sample-grammars/tarotcard.gram
index 43741a0..0e3a6da 100755
--- a/data/sample-grammars/tarotcard.gram
+++ b/data/sample-grammars/tarotcard.gram
@@ -1,4 +1,4 @@
-[tarot-card] [adjective-of] [title]
+[alt-tarot-card] [adjective-of] [title]
[adjective-of] [title] [adjective]
[adjective-of] [title] [adjective] [noun]
[adjective-of] [noun] [title]
@@ -11,12 +11,10 @@
[title] [adjective]
[title] [adjective] [noun]
-pragma initial-rule [tarot-card]
+pragma initial-rule [alt-tarot-card]
-[title] [male-title]
- [male-title]
- [female-title]
- [female-title]
+[title] <^2> [male-title]
+ <^2> [female-title]
[misc-title]
[male-title] emperor
diff --git a/data/sample-grammars/technobabble.gram b/data/sample-grammars/technobabble.gram
index 3861576..1f20fb4 100755
--- a/data/sample-grammars/technobabble.gram
+++ b/data/sample-grammars/technobabble.gram
@@ -1,14 +1,13 @@
-[technobabble] [part-prefix] [part-suffix] [part-problem]
- [part-suffix] [part-prefix] [part-problem]
- [part-prefix] [part-problem]
+[technobabble] [part-clause] [part-problem]
+[part-clause] {empty}
+
+pragma prefix-with [part-clause] [part-prefix] [part-suffix]
pragma initial-rule [technobabble]
pragma suffix-with [technobabble] [part-cause]
-[part-cause] the [part-prefix]
- the [part-suffix]
- the [part-prefix] [part-suffix]
+[part-cause] the [part-clause]
pragma suffix-with [part-cause] [add-cause]
diff --git a/data/sample-grammars/theory.gram b/data/sample-grammars/theory.gram
index af2ce49..828b180 100644..100755
--- a/data/sample-grammars/theory.gram
+++ b/data/sample-grammars/theory.gram
@@ -1,12 +1,9 @@
-[theory] [plural+last] [theory-suffix]
+[theory] <^2> [plural+last] [theory-suffix]
+ <^2> the [last-name] [theory-suffix]
+ <^3> the [2+last-name] [theory-suffix]
[plural+last] [theory-suffix]
- the [2+last-name] [theory-suffix]
- the [2+last-name] [theory-suffix]
- the [2+last-name] [theory-suffix]
the [3+last-name] [theory-suffix]
[plural+last] [ordinal] [theory-suffix]
- the [last-name] [theory-suffix]
- the [last-name] [theory-suffix]
pragma initial-rule [theory]
diff --git a/data/sample-grammars/trademark.gram b/data/sample-grammars/trademark.gram
index 7ec2fef..3871db6 100644..100755
--- a/data/sample-grammars/trademark.gram
+++ b/data/sample-grammars/trademark.gram
@@ -37,9 +37,7 @@ pragma initial-rule [trademark]
cere
mor
-[trademark+drug] [trademark-drug-fragment] [trademark-drug-suffix]
- [trademark-drug-fragment] [trademark-drug-suffix]
- [trademark-drug-fragment] [trademark-drug-suffix]
+[trademark+drug] <^3> [trademark-drug-fragment] [trademark-drug-suffix]
[trademark-fragment] [trademark-drug-suffix]
[trademark-fragment] [trademark-drug-fragment] [trademark-drug-suffix]
[syllable] [trademark-drug-fragment] [trademark-drug-suffix]
diff --git a/data/sample-grammars/vaultsofnagoh/turboghoul-hats.gram b/data/sample-grammars/vaultsofnagoh/turboghoul-hats.gram
index 57eef10..7632b94 100644..100755
--- a/data/sample-grammars/vaultsofnagoh/turboghoul-hats.gram
+++ b/data/sample-grammars/vaultsofnagoh/turboghoul-hats.gram
@@ -28,20 +28,11 @@ pragma suffix-with [turboghoul-hat] [eyeholes]
hockey
tights
-[headscarf] [headscarf-type] headscarf
+[headscarf] [flowery||bedouin] headscarf
-[headscarf-type] flowery
- bedouin
+[hood] [liripided||monastic] hood
-[hood] [hood-type] hood
-
-[hood-type] liripided
- monastic
-
-[turban] [turban-type] turban
-
-[turban-type] elaborate
- simple
+[turban] [elaborate||simple] turban
[hat] [hat-type] hat
[hat-type] hat with bandana
@@ -50,8 +41,7 @@ pragma suffix-with [turboghoul-hat] [eyeholes]
fancy feathered
wizard's pointy
-[helmet] [helmet-type] helmet
- [helmet-type] helm
+[helmet] [helmet-type] [helm||helmet]
[helmet-type] monstrous skull
common
diff --git a/data/sample-grammars/web.gram b/data/sample-grammars/web.gram
index 357fc36..32d2979 100644..100755
--- a/data/sample-grammars/web.gram
+++ b/data/sample-grammars/web.gram
@@ -20,14 +20,10 @@ pragma export-rule [big-tld]
[actual+email] [email-initial] @ [email-trailing]
-[email-initial] [username]
- [acronym]
- [email-alias]
- [full-name]
- [username]
- [acronym]
- [email-alias]
- [full-name]
+[email-initial] <^2> [username]
+ <^2> [acronym]
+ <^2> [email-alias]
+ <^2> [full-name]
[subdomain-name]
[email-misc]
[email-initial] + [email-initial]
@@ -99,7 +95,7 @@ pragma export-rule [big-tld]
[url-with-path]
[url-with-path]
-[url-with-path] [url-protocol] :// www.geocities.com/ [neighborhood] / [digit-nonzero] [digit] [digit] [digit] /
+[url-with-path] [url-protocol] :// www.geocities.com/ [neighborhood] / [1..9] [0..9] [0..9] [0..9] /
[url-protocol] :// [url-begin] . [acronym] .net/ [url-username] /
[url-protocol] :// [url-begin] . [town-name] .net/ [url-username]
[url-protocol] :// [subdomain-name] . [acronym] .net/ [url-username]
@@ -175,15 +171,9 @@ pragma export-rule [big-tld]
[last-name]
[syllable] [syllable]
-[tld] com
- com
- com
- com
- com
- net
- net
- org
- org
+[tld] <^5> com
+ <^2> net
+ <^2> org
edu
de
ca
@@ -195,8 +185,7 @@ pragma export-rule [big-tld]
se
no
-[big-tld] com
- com
+[big-tld] <^2> com
net
org
@@ -204,7 +193,7 @@ pragma export-rule [big-tld]
[planet]
mail
www2
- www [digit]
+ www [0..9]
alpha
beta
gamma
@@ -217,10 +206,10 @@ pragma export-rule [big-tld]
[email-initial]
[subdomain-name] - [subdomain-name]
-[email-misc]
- [us-stateadj]
+[email-misc] [us-stateadj]
[town-name]
[complete-many-things]
+ [minor-arcana]
[major-arcana]
[trademark+drug]
[trademark]
diff --git a/data/sample-grammars/zadrons-pouch.gram b/data/sample-grammars/zadrons-pouch.gram
index f72cf25..b918f1c 100755
--- a/data/sample-grammars/zadrons-pouch.gram
+++ b/data/sample-grammars/zadrons-pouch.gram
@@ -64,9 +64,7 @@ pragma export-rule [zadrons-item]
imprisoning
messaging
bounty
- [card]
- [card]
- [card]
+ <^3> [card]
[crys-sphere] → crystal of [crystal-type]
[crys-act]
diff --git a/data/seniordesign/dbdata.gram b/data/seniordesign/dbdata.gram
index 04938ad..de0879c 100644..100755
--- a/data/seniordesign/dbdata.gram
+++ b/data/seniordesign/dbdata.gram
@@ -1,17 +1,7 @@
-[user-role] student
- student
- student
- student
- student
- tutor
- tutor
- tutor
- tutor
- staff
- staff
- staff
- admin
- admin
+[user-role] <^5> student
+ <^4> tutor
+ <^3> staff
+ <^2> admin
sysadmin
pragma export-rule [user-role]
@@ -29,9 +19,7 @@ pragma export-rule [dept-id]
[synth+deptid] [letter]
-pragma suffix-with [synth+deptid] [letter]
-pragma suffix-with [synth+deptid] [letter]
-pragma suffix-with [synth+deptid] [letter]
+pragma suffix-with [synth+deptid] <&1..3> [letter]
[user-idno] [act-user+idno]
@@ -40,7 +28,7 @@ pragma export-rule [user-idno]
[act-user+idno] 800 [idno-chain]
700 [idno-chain]
-[idno-chain] [digit] [digit] [digit] [digit] [digit] [digit]
+[idno-chain] <&5> [digit]
[term-code] [2000..2040] 0 [1..9]
[2000..2040] [10..12]
@@ -48,7 +36,7 @@ pragma export-rule [user-idno]
pragma despace-rule [term-code]
pragma export-rule [term-code]
-[section-code] [letter] [0..9] [0..9]
+[section-code] [letter] <&2> [0..9]
pragma despace-rule [section-code]
pragma export-rule [section-code]
diff --git a/data/server-config-sample.cfg b/data/server-config-sample.cfg
deleted file mode 100644
index 90d3baf..0000000
--- a/data/server-config-sample.cfg
+++ /dev/null
@@ -1,119 +0,0 @@
-# Load 'long rules' -- Grammars with one rule with a lot of cases
-animal sample-grammars/long-data/animal.gram
-canada-province sample-grammars/long-data/canada-province.gram
-cards sample-grammars/long-data/cards.gram
-color sample-grammars/long-data/color.gram
-first-name-female sample-grammars/long-data/first-name-female.gram
-first-name-male sample-grammars/long-data/first-name-male.gram
-geographic-thing sample-grammars/long-data/geographic-thing.gram
-last-name sample-grammars/long-data/last-name.gram
-letters sample-grammars/long-data/letters.gram
-nation sample-grammars/long-data/nation.gram
-numbers sample-grammars/long-data/numbers.gram
-planet sample-grammars/long-data/planet.gram
-real-city sample-grammars/long-data/real-city.gram
-real-company sample-grammars/long-data/real-company.gram
-relative sample-grammars/long-data/relative.gram
-roman-numeral sample-grammars/long-data/roman-numeral.gram
-syllables sample-grammars/long-data/syllables.gram
-town-name sample-grammars/long-data/town-name.gram
-tree sample-grammars/long-data/tree.gram
-greek-letters sample-grammars/long-data/greek-letters.gram
-japanese-sylls sample-grammars/long-data/japanese-writing.gram
-
-# Load grammars
-
-# Set I of grammars
-24hr-rpg sample-grammars/24hr-rpg.gram
-acronym sample-grammars/acronym.gram
-address sample-grammars/address.gram
-anime sample-grammars/anime.gram
-art-objects sample-grammars/art-objects.gram
-awesome-names sample-grammars/awe-names.gram
-buzzword sample-grammars/buzzword.gram
-career sample-grammars/career.gram
-city sample-grammars/city.gram
-college sample-grammars/college.gram
-company sample-grammars/company.gram
-computer sample-grammars/computer.gram
-congress sample-grammars/congress.gram
-dates sample-grammars/dates.gram
-dungeon-enviroment sample-grammars/dungeon-enviroment.gram
-elemental sample-grammars/elementals.gram
-fantasy-locations sample-grammars/fantasy-locations.gram
-fortune sample-grammars/fortune.gram
-gemstones sample-grammars/gemstones.gram
-genre-fiction sample-grammars/genre-fiction.gram
-horror sample-grammars/horror.gram
-insults sample-grammars/insults.gram
-linux sample-grammars/linux.gram
-martial-arts sample-grammars/martial-arts.gram
-mary-sue sample-grammars/mary-sue.gram
-media sample-grammars/media.gram
-mission sample-grammars/mission.gram
-names sample-grammars/names.gram
-# newspaper sample-grammars/newspaper.gram
-numbers sample-grammars/numbers.gram
-ordinal sample-grammars/ordinal.gram
-organization sample-grammars/organization.gram
-part-creature sample-grammars/part-creature.gram
-phone-number sample-grammars/phone-number.gram
-pokeattacks sample-grammars/pokeattacks.gram
-president sample-grammars/president.gram
-rune sample-grammars/rune.gram
-school sample-grammars/school.gram
-slashdot sample-grammars/slashdot.gram
-states sample-grammars/states.gram
-superhero sample-grammars/superhero.gram
-tarotcard sample-grammars/tarotcard.gram
-technobabble sample-grammars/technobabble.gram
-theory sample-grammars/theory.gram
-trademark sample-grammars/trademark.gram
-web sample-grammars/web.gram
-zadrons-pouch sample-grammars/zadrons-pouch.gram
-
-# Diablo II items
-diabloii-base sample-grammars/diablo-ii/diabloii.gram
-diabloii-items sample-grammars/diablo-ii/diabloiiitems.gram
-diabloii-perish sample-grammars/diablo-ii/diabloiiperish.gram
-diabloii-prefixes sample-grammars/diablo-ii/diabloiiprefixes.gram
-diabloii-suffixes sample-grammars/diablo-ii/diabloiisuffixes.gram
-
-# Vaults of Nagoh
-turboghoul-hats sample-grammars/vaultsofnagoh/turboghoul-hats.gram
-
-# Set II of grammars
-repinsults new-sample-grammars/repinsult.gram
-
-# Drakensang online items
-ds-runes new-sample-grammars/drakensang/runes.gram
-ds-gems new-sample-grammars/drakensang/gems.gram
-ds-armor new-sample-grammars/drakensang/armor.gram
-
-# Other grammar files
-
-# Dungeon dressing
-abandoned sample-grammars/dungeondressing/abandoned.gram
-bedroom sample-grammars/dungeondressing/bedroom.gram
-dragonencounter sample-grammars/dungeondressing/dragonencounter.gram
-kitchen sample-grammars/dungeondressing/kitchen.gram
-monster sample-grammars/dungeondressing/monster.gram
-
-# RandomTable Wiki
-adjective sample-grammars/rtwiki/adjective.gram
-bodyparts sample-grammars/rtwiki/bodyparts.gram
-color sample-grammars/rtwiki/color.gram
-creature sample-grammars/rtwiki/creature.gram
-death-cause sample-grammars/rtwiki/death-cause.gram
-fantasy-name sample-grammars/rtwiki/fantasy-name.gram
-favorite sample-grammars/rtwiki/favorite.gram
-guns sample-grammars/rtwiki/guns.gram
-item sample-grammars/rtwiki/item.gram
-traits sample-grammars/rtwiki/traits.gram
-
-# Senior design
-seniordesign seniordesign/dbdata.gram
-
-# Misc
-700000items misc/700000items.gram
-nimble-bimble misc/nimble.gram
diff --git a/data/server-config-sample.gcfg b/data/server-config-sample.gcfg
new file mode 100755
index 0000000..95939a8
--- /dev/null
+++ b/data/server-config-sample.gcfg
@@ -0,0 +1,127 @@
+# Load 'long rules' -- Grammars which generally are used as part of the output
+# for other grammars
+load grammar animal sample-grammars/long-data/animal.gram
+load grammar canada-province sample-grammars/long-data/canada-province.gram
+load grammar cards sample-grammars/long-data/cards.gram
+load grammar color sample-grammars/long-data/color.gram
+load grammar first-name-female sample-grammars/long-data/first-name-female.gram
+load grammar first-name-male sample-grammars/long-data/first-name-male.gram
+load grammar geographic-thing sample-grammars/long-data/geographic-thing.gram
+load grammar last-name sample-grammars/long-data/last-name.gram
+load grammar letters sample-grammars/long-data/letters.gram
+load grammar nation sample-grammars/long-data/nation.gram
+load grammar numbers sample-grammars/long-data/numbers.gram
+load grammar planet sample-grammars/long-data/planet.gram
+load grammar real-city sample-grammars/long-data/real-city.gram
+load grammar real-company sample-grammars/long-data/real-company.gram
+load grammar relative sample-grammars/long-data/relative.gram
+load grammar roman-numeral sample-grammars/long-data/roman-numeral.gram
+load grammar syllables sample-grammars/long-data/syllables.gram
+load grammar town-name sample-grammars/long-data/town-name.gram
+load grammar tree sample-grammars/long-data/tree.gram
+load grammar greek-letters sample-grammars/long-data/greek-letters.gram
+load grammar japanese-sylls sample-grammars/long-data/japanese-writing.gram
+
+# Load grammars
+
+# Set I of grammars
+load grammar 24hr-rpg sample-grammars/24hr-rpg.gram
+load grammar acronym sample-grammars/acronym.gram
+load grammar address sample-grammars/address.gram
+load grammar anime sample-grammars/anime.gram
+load grammar art-objects sample-grammars/art-objects.gram
+load grammar awesome-names sample-grammars/awe-names.gram
+load grammar buzzword sample-grammars/buzzword.gram
+load grammar career sample-grammars/career.gram
+load grammar city sample-grammars/city.gram
+load grammar college sample-grammars/college.gram
+load grammar company sample-grammars/company.gram
+load grammar computer sample-grammars/computer.gram
+load grammar congress sample-grammars/congress.gram
+load grammar dates sample-grammars/dates.gram
+load grammar dungeon-enviroment sample-grammars/dungeon-enviroment.gram
+load grammar elemental sample-grammars/elementals.gram
+load grammar fantasy-locations sample-grammars/fantasy-locations.gram
+load grammar fortune sample-grammars/fortune.gram
+load grammar gemstones sample-grammars/gemstones.gram
+load grammar genre-fiction sample-grammars/genre-fiction.gram
+load grammar horror sample-grammars/horror.gram
+load grammar insults sample-grammars/insults.gram
+load grammar linux sample-grammars/linux.gram
+load grammar martial-arts sample-grammars/martial-arts.gram
+load grammar mary-sue sample-grammars/mary-sue.gram
+load grammar media sample-grammars/media.gram
+load grammar mission sample-grammars/mission.gram
+load grammar names sample-grammars/names.gram
+# newspaper sample-grammars/newspaper.gram
+load grammar numbers sample-grammars/numbers.gram
+load grammar ordinal sample-grammars/ordinal.gram
+load grammar organization sample-grammars/organization.gram
+load grammar part-creature sample-grammars/part-creature.gram
+load grammar phone-number sample-grammars/phone-number.gram
+load grammar pokeattacks sample-grammars/pokeattacks.gram
+load grammar president sample-grammars/president.gram
+load grammar rune sample-grammars/rune.gram
+load grammar school sample-grammars/school.gram
+load grammar slashdot sample-grammars/slashdot.gram
+load grammar states sample-grammars/states.gram
+load grammar superhero sample-grammars/superhero.gram
+load grammar tarotcard sample-grammars/tarotcard.gram
+load grammar technobabble sample-grammars/technobabble.gram
+load grammar theory sample-grammars/theory.gram
+load grammar trademark sample-grammars/trademark.gram
+load grammar web sample-grammars/web.gram
+load grammar zadrons-pouch sample-grammars/zadrons-pouch.gram
+
+# Diablo II items
+load grammar diabloii-base sample-grammars/diablo-ii/diabloii.gram
+load grammar diabloii-items sample-grammars/diablo-ii/diabloiiitems.gram
+load grammar diabloii-perish sample-grammars/diablo-ii/diabloiiperish.gram
+load grammar diabloii-prefixes sample-grammars/diablo-ii/diabloiiprefixes.gram
+load grammar diabloii-suffixes sample-grammars/diablo-ii/diabloiisuffixes.gram
+
+# Vaults of Nagoh
+load grammar turboghoul-hats sample-grammars/vaultsofnagoh/turboghoul-hats.gram
+
+# RPG tools
+load grammar wand rpg-tools-cd/wands.gram
+
+# Set II of grammars
+load grammar cbs new-sample-grammars/cbs.gram
+load grammar repinsults new-sample-grammars/repinsult.gram
+
+# Drakensang online items
+load grammar ds-runes new-sample-grammars/drakensang/runes.gram
+load grammar ds-gems new-sample-grammars/drakensang/gems.gram
+load grammar ds-armor new-sample-grammars/drakensang/armor.gram
+
+# Perchance sample grammars
+load grammar meal new-sample-grammars/perchance/meal.gram
+
+# Other grammar files
+
+# Dungeon dressing
+load grammar abandoned sample-grammars/dungeondressing/abandoned.gram
+load grammar bedroom sample-grammars/dungeondressing/bedroom.gram
+load grammar dragonencounter sample-grammars/dungeondressing/dragonencounter.gram
+load grammar kitchen sample-grammars/dungeondressing/kitchen.gram
+load grammar monster sample-grammars/dungeondressing/monster.gram
+
+# RandomTable Wiki
+load grammar adjective sample-grammars/rtwiki/adjective.gram
+load grammar bodyparts sample-grammars/rtwiki/bodyparts.gram
+load grammar color sample-grammars/rtwiki/color.gram
+load grammar creature sample-grammars/rtwiki/creature.gram
+load grammar death-cause sample-grammars/rtwiki/death-cause.gram
+load grammar fantasy-name sample-grammars/rtwiki/fantasy-name.gram
+load grammar favorite sample-grammars/rtwiki/favorite.gram
+load grammar guns sample-grammars/rtwiki/guns.gram
+load grammar item sample-grammars/rtwiki/item.gram
+load grammar traits sample-grammars/rtwiki/traits.gram
+
+# Senior design
+load grammar seniordesign seniordesign/dbdata.gram
+
+# Misc
+load grammar 700000items misc/700000items.gram
+load grammar nimble-bimble misc/nimble.gram
diff --git a/data/todos.txt b/data/todos.txt
index 1de8841..a382a05 100644..100755
--- a/data/todos.txt
+++ b/data/todos.txt
@@ -1,2 +1,8 @@
-:TODO 5/10/18 Ben Culkin :EasternSun
+@TODO 5/10/18 Ben Culkin :EasternSun
Finish up the new-style Diablo generator, using Eastern Sun things
+
+@TODO 10/11/17 Ben Culkin :GrammarReorg
+ Better organize the provided sample grammars.
+
+@TODO 5/29/18 Ben Culkin :Spacing
+ Convert grammars into using despace-rule where possible.
diff --git a/dotest.sh b/dotest.sh
index a39a012..c438dc7 100755
--- a/dotest.sh
+++ b/dotest.sh
@@ -2,4 +2,5 @@
mvn clean compile exec:java > outp.txt 2> error.txt;
-tail -n +36 outp.txt | view -c "normal! zR" -;
+tail -n +32 outp.txt | view -c "normal! zR" -c "tabe error.txt" -c "normal! gt" -;
+# tail -n +32 outp.txt | view -c "normal! zR" -;
diff --git a/gram.txt b/gram.txt
new file mode 100644
index 0000000..4c36a78
--- /dev/null
+++ b/gram.txt
@@ -0,0 +1,1361 @@
+RGen Grammars
+ filter remove_matches ^\s*#
+ extension gram
+ 3rd_gen_scale 5.00
+ADSO/IDSM
+ filter remove_matches ^\s*\*[\+\!]
+ extension adso
+ 3rd_gen_scale 3.00
+AMPLE
+ filter remove_matches ^\s*//
+ extension ample
+ extension dofile
+ extension startup
+ 3rd_gen_scale 2.00
+ASP
+ filter remove_matches ^\s*\47
+ extension asa
+ extension asp
+ 3rd_gen_scale 1.29
+ end_of_line_continuation \\$
+ASP.Net
+ filter call_regexp_common C
+ extension asax
+ extension ascx
+ extension asmx
+ extension aspx
+ extension master
+ extension sitemap
+ extension webinfo
+ 3rd_gen_scale 1.29
+ end_of_line_continuation \\$
+ActionScript
+ filter call_regexp_common C++
+ extension as
+ 3rd_gen_scale 1.36
+ end_of_line_continuation \\$
+Ada
+ filter remove_matches ^\s*--
+ extension ada
+ extension adb
+ extension ads
+ extension pad
+ 3rd_gen_scale 0.52
+ end_of_line_continuation \\$
+Ant
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension build.xml
+ 3rd_gen_scale 1.90
+Ant/XML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filename build.xml
+ 3rd_gen_scale 1.90
+Antlr
+ filter call_regexp_common C++
+ extension g
+ 3rd_gen_scale 2.00
+Apex Trigger
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension trigger
+ 3rd_gen_scale 1.40
+Arduino Sketch
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension ino
+ extension pde
+ 3rd_gen_scale 1.00
+AspectJ
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension aj
+ 3rd_gen_scale 1.36
+ end_of_line_continuation \\$
+Assembly
+ filter call_regexp_common C++
+ filter remove_matches ^\s*;
+ filter remove_matches ^\s*\@
+ filter remove_matches ^\s*\|
+ filter remove_matches ^\s*!
+ filter remove_matches ^\s*#
+ filter remove_matches ^\s*--
+ filter remove_inline //.*$
+ filter remove_inline ;.*$
+ filter remove_inline \@.*$
+ filter remove_inline \|.*$
+ filter remove_inline !.*$
+ filter remove_inline #.*$
+ filter remove_inline --.*$
+ extension S
+ extension asm
+ extension s
+ 3rd_gen_scale 0.25
+ end_of_line_continuation \\$
+AutoHotkey
+ filter remove_matches ^\s*;
+ filter remove_inline ;.*$
+ extension ahk
+ 3rd_gen_scale 1.29
+Blade
+ filter remove_between_general {{-- --}}
+ filter remove_html_comments
+ extension blade.php
+ 3rd_gen_scale 2.00
+Bourne Again Shell
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension bash
+ script_exe bash
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
+Bourne Shell
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension sh
+ script_exe sh
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
+C
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension c
+ extension ec
+ extension pgc
+ 3rd_gen_scale 0.77
+ end_of_line_continuation \\$
+C Shell
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension csh
+ extension tcsh
+ script_exe csh
+ script_exe tcsh
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
+C#
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension cs
+ 3rd_gen_scale 1.36
+ end_of_line_continuation \\$
+C++
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension C
+ extension c++
+ extension cc
+ extension cpp
+ extension cxx
+ extension pcc
+ 3rd_gen_scale 1.51
+ end_of_line_continuation \\$
+C/C++ Header
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension H
+ extension h
+ extension hh
+ extension hpp
+ extension hxx
+ 3rd_gen_scale 1.00
+ end_of_line_continuation \\$
+CCS
+ filter call_regexp_common C
+ extension ccs
+ 3rd_gen_scale 5.33
+CMake
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension CMakeLists.txt
+ extension cmake
+ filename CMakeLists.txt
+ 3rd_gen_scale 1.00
+ end_of_line_continuation \\$
+COBOL
+ filter remove_cobol_comments
+ extension CBL
+ extension COB
+ extension cbl
+ extension cob
+ 3rd_gen_scale 1.04
+CSON
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension cson
+ 3rd_gen_scale 2.50
+CSS
+ filter call_regexp_common C
+ extension css
+ 3rd_gen_scale 1.00
+CUDA
+ filter call_regexp_common C++
+ filter remove_matches ^\s*//
+ filter remove_inline //.*$
+ extension cu
+ extension cuh
+ 3rd_gen_scale 1.00
+Clean
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension dcl
+ extension icl
+ 3rd_gen_scale 2.50
+Clojure
+ filter remove_matches ^\s*;
+ extension clj
+ 3rd_gen_scale 1.25
+ClojureC
+ filter remove_matches ^\s*;
+ extension cljc
+ 3rd_gen_scale 1.25
+ClojureScript
+ filter remove_matches ^\s*;
+ extension cljs
+ 3rd_gen_scale 1.25
+CoffeeScript
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension coffee
+ 3rd_gen_scale 2.00
+ColdFusion
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension cfm
+ 3rd_gen_scale 4.00
+ColdFusion CFScript
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension cfc
+ 3rd_gen_scale 4.00
+Coq
+ filter remove_between_general (* *)
+ 3rd_gen_scale 5.00
+Crystal
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension cr
+ script_exe crystal
+ 3rd_gen_scale 2.50
+Crystal Reports
+ filter remove_matches ^\s*//
+ 3rd_gen_scale 4.00
+Cython
+ filter remove_matches ^\s*#
+ filter docstring_to_C
+ filter call_regexp_common C
+ filter remove_inline #.*$
+ extension pyx
+ 3rd_gen_scale 3.80
+ end_of_line_continuation \\$
+D
+ filter remove_between_general /+ +/
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ script_exe dmd
+ 3rd_gen_scale 1.70
+ end_of_line_continuation \\$
+DAL
+ filter remove_between_general [ ]
+ extension da
+ 3rd_gen_scale 1.50
+DITA
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension dita
+ 3rd_gen_scale 1.90
+DOORS Extension Language
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension dxl
+ 3rd_gen_scale 1.50
+DOS Batch
+ filter remove_matches ^\s*rem
+ extension BAT
+ extension BTM
+ extension CMD
+ extension bat
+ extension btm
+ extension cmd
+ 3rd_gen_scale 0.63
+DTD
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension dtd
+ 3rd_gen_scale 1.90
+Dart
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension dart
+ 3rd_gen_scale 2.00
+ end_of_line_continuation \\$
+Dockerfile
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ filename Dockerfile
+ 3rd_gen_scale 2.00
+ECPP
+ filter remove_between_general <%doc> </%doc>
+ filter remove_between_general <# #>
+ filter call_regexp_common HTML
+ extension ecpp
+ 3rd_gen_scale 1.90
+EEx
+ filter remove_between_general <%# %>
+ extension eex
+ 3rd_gen_scale 2.00
+ERB
+ filter remove_between_general <%# %>
+ extension ERB
+ extension erb
+ 3rd_gen_scale 2.00
+Elixir
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension ex
+ extension exs
+ 3rd_gen_scale 2.11
+Elm
+ filter remove_haskell_comments >filename<
+ extension elm
+ 3rd_gen_scale 2.50
+Erlang
+ filter remove_matches ^\s*%
+ filter remove_inline %.*$
+ extension erl
+ extension hrl
+ 3rd_gen_scale 2.11
+Expect
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension exp
+ 3rd_gen_scale 2.00
+ end_of_line_continuation \\$
+F#
+ filter call_regexp_common Pascal
+ filter remove_matches ^\s*//
+ extension fsi
+ 3rd_gen_scale 2.50
+Focus
+ filter remove_matches ^\s*\-\*
+ extension focexec
+ 3rd_gen_scale 1.90
+Forth
+ filter remove_matches ^\s*\\.*$
+ filter Forth_paren_to_C
+ filter call_regexp_common C++
+ filter remove_inline \\.*$
+ extension 4th
+ extension e4
+ extension f83
+ extension fb
+ extension forth
+ extension fpm
+ extension fr
+ extension frt
+ extension ft
+ extension fth
+ extension rx
+ 3rd_gen_scale 1.25
+Fortran 77
+ filter remove_f77_comments
+ filter remove_inline \!.*$
+ extension F
+ extension F77
+ extension FOR
+ extension FTN
+ extension f77
+ extension ftn
+ extension pfo
+ 3rd_gen_scale 0.75
+Fortran 90
+ filter remove_f77_comments
+ filter remove_f90_comments
+ filter remove_inline \!.*$
+ extension F90
+ extension f90
+ 3rd_gen_scale 1.00
+Fortran 95
+ filter remove_f77_comments
+ filter remove_f90_comments
+ filter remove_inline \!.*$
+ extension F95
+ extension f95
+ 3rd_gen_scale 1.13
+Freemarker Template
+ filter remove_between_general <#-- -->
+ extension ftl
+ 3rd_gen_scale 1.48
+GDScript
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension gd
+ 3rd_gen_scale 2.50
+GLSL
+ filter call_regexp_common C++
+ extension comp
+ extension frag
+ extension geom
+ extension glsl
+ extension tesc
+ extension tese
+ extension vert
+ 3rd_gen_scale 2.00
+Glade
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension glade
+ 3rd_gen_scale 2.00
+Go
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension go
+ 3rd_gen_scale 2.50
+ end_of_line_continuation \\$
+Grails
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filter remove_jsp_comments
+ filter add_newlines
+ filter call_regexp_common C++
+ extension gsp
+ 3rd_gen_scale 1.48
+Groovy
+ filter remove_inline //.*$
+ filter replace_between_regex (["'])(.*?/)(\*.*?)\g1 (.*?)
+ filter call_regexp_common C++
+ extension gant
+ extension gradle
+ extension groovy
+ 3rd_gen_scale 4.10
+HLSL
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension cg
+ extension cginc
+ extension hlsl
+ extension shader
+ 3rd_gen_scale 2.00
+HTML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension htm
+ extension html
+ 3rd_gen_scale 1.90
+Haml
+ filter remove_haml_block
+ filter remove_html_comments
+ filter remove_matches ^\s*/\s*\S+
+ filter remove_matches ^\s*-#\s*\S+
+ extension haml
+ 3rd_gen_scale 2.50
+Handlebars
+ filter remove_between_general {{!-- --}}
+ filter remove_between_general {{! }}
+ filter remove_html_comments
+ extension handlebars
+ extension hbs
+ 3rd_gen_scale 2.50
+Harbour
+ filter remove_matches ^\s*\&\&
+ filter remove_matches ^\s*\*
+ filter remove_matches ^\s*NOTE
+ filter remove_matches ^\s*note
+ filter remove_matches ^\s*Note
+ filter remove_inline //.*$
+ filter remove_inline \&\&.*$
+ filter call_regexp_common C++
+ extension hb
+ 3rd_gen_scale 2.00
+Haskell
+ filter remove_haskell_comments >filename<
+ extension hs
+ extension lhs
+ 3rd_gen_scale 2.11
+Haxe
+ filter call_regexp_common C++
+ extension hx
+ 3rd_gen_scale 2.00
+IDL
+ filter remove_matches ^\s*;
+ extension idl
+ script_exe idl
+ 3rd_gen_scale 3.80
+ end_of_line_continuation \$\$
+INI
+ filter remove_matches ^\s*;
+ extension ini
+ 3rd_gen_scale 1.00
+InstallShield
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension ism
+ 3rd_gen_scale 1.90
+JCL
+ filter remove_jcl_comments
+ extension jcl
+ 3rd_gen_scale 1.67
+JSON
+ filter remove_matches ^\s*$
+ extension json
+ 3rd_gen_scale 2.50
+JSP
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filter remove_jsp_comments
+ filter remove_matches ^\s*//
+ filter add_newlines
+ filter call_regexp_common C
+ extension jsp
+ extension jspf
+ 3rd_gen_scale 1.48
+JSX
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension jsx
+ 3rd_gen_scale 1.48
+ end_of_line_continuation \\$
+Jam
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ filename Jamfile
+ filename Jamrules
+ 3rd_gen_scale 2.00
+Java
+ filter replace_between_regex (["'])(.*?/)(\*.*?)\g1 (.*?)
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension java
+ 3rd_gen_scale 1.36
+ end_of_line_continuation \\$
+JavaScript
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension es6
+ extension js
+ 3rd_gen_scale 1.48
+ end_of_line_continuation \\$
+JavaServer Faces
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension jsf
+ 3rd_gen_scale 1.50
+Julia
+ filter remove_between_general #= =#
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ 3rd_gen_scale 4.00
+Kermit
+ filter remove_matches ^\s*#
+ filter remove_matches ^\s*;
+ filter remove_inline #.*$
+ extension ksc
+ script_exe kermit
+ 3rd_gen_scale 2.00
+ end_of_line_continuation \\$
+Korn Shell
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension ksh
+ script_exe ksh
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
+Kotlin
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension kt
+ extension kts
+ 3rd_gen_scale 2.00
+LESS
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension less
+ 3rd_gen_scale 1.50
+ end_of_line_continuation \\$
+LFE
+ filter remove_matches ^\s*;
+ filter remove_between_general #| |#
+ extension lfe
+ 3rd_gen_scale 1.25
+Lisp
+ filter remove_matches ^\s*;
+ filter remove_between_general #| |#
+ extension el
+ extension lisp
+ extension lsp
+ extension sc
+ 3rd_gen_scale 1.25
+LiveLink OScript
+ filter remove_matches ^\s*//
+ extension oscript
+ 3rd_gen_scale 3.50
+Logtalk
+ filter remove_matches ^\s*\%
+ filter call_regexp_common C
+ filter remove_inline (//|\%).*$
+ extension lgt
+ extension logtalk
+ 3rd_gen_scale 2.00
+Lua
+ filter remove_between_general --[[ ]]
+ filter remove_matches ^\s*\-\-
+ extension lua
+ script_exe lua
+ 3rd_gen_scale 4.00
+ end_of_line_continuation \\$
+MATLAB
+ filter remove_matches ^\s*%
+ filter remove_inline %.*$
+ 3rd_gen_scale 4.00
+ end_of_line_continuation \.\.\.\s*$
+MSBuild script
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension csproj
+ extension vbproj
+ extension vcproj
+ extension wdproj
+ extension wixproj
+ 3rd_gen_scale 1.90
+MUMPS
+ filter remove_matches ^\s*;
+ extension mps
+ 3rd_gen_scale 4.21
+MXML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filter remove_matches ^\s*//
+ filter add_newlines
+ filter call_regexp_common C
+ extension mxml
+ 3rd_gen_scale 1.90
+ end_of_line_continuation \\$
+Mako
+ filter remove_matches ##.*$
+ extension mako
+ 3rd_gen_scale 1.50
+Markdown
+ filter remove_between_regex \[(comment|\/\/)?\]\s*:?\s*(<\s*>|#)?\s*\(.*? .*?\)
+ extension md
+ 3rd_gen_scale 1.00
+Mathematica
+ filter remove_between_general (* *)
+ extension mt
+ extension wl
+ extension wlt
+ 3rd_gen_scale 5.00
+Maven
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension pom
+ extension pom.xml
+ 3rd_gen_scale 1.90
+Maven/XML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filename pom.xml
+ 3rd_gen_scale 2.50
+Mercury
+ filter remove_inline %.*$
+ filter remove_matches ^\s*%
+ 3rd_gen_scale 3.00
+Modula3
+ filter call_regexp_common Pascal
+ extension i3
+ extension ig
+ extension m3
+ extension mg
+ 3rd_gen_scale 2.00
+Mustache
+ filter remove_between_general {{! }}
+ extension mustache
+ 3rd_gen_scale 1.75
+NASTRAN DMAP
+ filter remove_matches ^\s*\$
+ filter remove_inline \$.*$
+ extension dmap
+ 3rd_gen_scale 2.35
+NAnt script
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension build
+ 3rd_gen_scale 1.90
+Nemerle
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension n
+ 3rd_gen_scale 2.50
+Nim
+ filter remove_between_general #[ ]#
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension nim
+ 3rd_gen_scale 2.00
+OCaml
+ filter call_regexp_common Pascal
+ extension ml
+ extension mli
+ extension mll
+ extension mly
+ 3rd_gen_scale 3.00
+ end_of_line_continuation \\$
+Objective C
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ 3rd_gen_scale 2.96
+ end_of_line_continuation \\$
+Objective C++
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension mm
+ 3rd_gen_scale 2.96
+ end_of_line_continuation \\$
+Octave
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ script_exe octave
+ 3rd_gen_scale 4.00
+ end_of_line_continuation \.\.\.\s*$
+OpenCL
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ 3rd_gen_scale 1.50
+Oracle Forms
+ filter call_regexp_common C
+ extension fmt
+ 3rd_gen_scale 2.67
+Oracle Reports
+ filter call_regexp_common C
+ extension rex
+ 3rd_gen_scale 2.76
+PHP
+ filter remove_matches ^\s*#
+ filter call_regexp_common C++
+ filter remove_inline #.*$
+ extension php
+ extension php3
+ extension php4
+ extension php5
+ extension phtml
+ script_exe php
+ script_exe php5
+ 3rd_gen_scale 3.50
+PL/I
+ filter call_regexp_common C
+ extension pl1
+ 3rd_gen_scale 1.38
+PO File
+ filter remove_matches ^\s*#[^,]
+ extension po
+ 3rd_gen_scale 1.50
+Pascal
+ filter remove_between_regex {[^$] }
+ filter remove_between_general (* *)
+ filter remove_matches ^\s*//
+ extension dpr
+ extension p
+ extension pas
+ 3rd_gen_scale 0.88
+Patran Command Language
+ filter remove_matches ^\s*#
+ filter remove_matches ^\s*\$#
+ filter call_regexp_common C
+ extension pcl
+ extension ses
+ 3rd_gen_scale 2.50
+ end_of_line_continuation \\$
+Perl
+ filter remove_below ^__(END|DATA)__
+ filter remove_matches ^\s*#
+ filter remove_below_above ^=head1 ^=cut
+ filter remove_inline #.*$
+ extension perl
+ extension plh
+ extension plx
+ extension pm
+ extension pm6
+ script_exe miniperl
+ script_exe perl
+ script_exe perl5
+ script_exe perl6
+ 3rd_gen_scale 4.00
+Pig Latin
+ filter remove_matches ^\s*--
+ filter remove_inline --.*$
+ filter call_regexp_common C
+ extension pig
+ 3rd_gen_scale 1.00
+PowerBuilder
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension sra
+ extension srf
+ extension srm
+ extension srs
+ extension sru
+ extension srw
+ 3rd_gen_scale 3.33
+ end_of_line_continuation \\$
+PowerShell
+ filter powershell_to_C
+ filter call_regexp_common C
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension ps1
+ extension psd1
+ extension psm1
+ 3rd_gen_scale 3.00
+ end_of_line_continuation \\$
+Prolog
+ filter remove_matches ^\s*\%
+ filter call_regexp_common C
+ filter remove_inline (//|\%).*$
+ extension P
+ script_exe swipl
+ 3rd_gen_scale 1.25
+Protocol Buffers
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension proto
+ 3rd_gen_scale 2.00
+Pug
+ filter remove_pug_block
+ filter remove_matches ^\s*//
+ filter remove_inline //.*$
+ extension pug
+ 3rd_gen_scale 2.00
+Puppet
+ filter remove_matches ^\s*#
+ filter call_regexp_common C
+ filter remove_inline #.*$
+ 3rd_gen_scale 2.00
+PureScript
+ filter remove_matches ^\s*--
+ filter remove_between_general {- -}
+ filter remove_inline --.*$
+ extension purs
+ 3rd_gen_scale 2.00
+Python
+ filter remove_matches ^\s*#
+ filter docstring_to_C
+ filter call_regexp_common C
+ filter remove_inline #.*$
+ extension py
+ script_exe python
+ script_exe python2.6
+ script_exe python2.7
+ script_exe python3
+ script_exe python3.3
+ script_exe python3.4
+ script_exe python3.5
+ 3rd_gen_scale 4.20
+ end_of_line_continuation \\$
+QML
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension qml
+ 3rd_gen_scale 1.25
+Qt
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ 3rd_gen_scale 2.00
+Qt Linguist
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ 3rd_gen_scale 1.00
+Qt Project
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ 3rd_gen_scale 1.00
+ end_of_line_continuation \\$
+R
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension R
+ extension r
+ 3rd_gen_scale 3.00
+ end_of_line_continuation \\$
+Racket
+ filter remove_matches ^\s*;
+ filter remove_inline ;.*$
+ extension rkt
+ extension rktl
+ extension sch
+ extension scm
+ extension scrbl
+ extension ss
+ 3rd_gen_scale 1.50
+RapydScript
+ filter remove_matches ^\s*#
+ filter docstring_to_C
+ filter call_regexp_common C
+ filter remove_inline #.*$
+ extension pyj
+ 3rd_gen_scale 4.20
+Razor
+ filter remove_between_general @* *@
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension cshtml
+ 3rd_gen_scale 2.00
+Rexx
+ filter call_regexp_common C
+ extension rexx
+ script_exe regina
+ script_exe rexx
+ 3rd_gen_scale 1.19
+RobotFramework
+ filter remove_matches ^\s*#
+ filter remove_matches ^\s*Comment
+ filter remove_matches ^\s*\*{3}\s+(Variables|Test\s+Cases|Settings|Keywords)\s+\*{3}
+ filter remove_matches ^\s*\[(Documentation|Tags)\]
+ filter remove_inline #.*$
+ extension robot
+ extension tsv
+ 3rd_gen_scale 2.50
+Ruby
+ filter remove_matches ^\s*#
+ filter remove_below_above ^=begin ^=end
+ filter remove_inline #.*$
+ extension rake
+ extension rb
+ filename Rakefile
+ filename rakefile
+ script_exe ruby
+ 3rd_gen_scale 4.20
+ end_of_line_continuation \\$
+Ruby HTML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension rhtml
+ 3rd_gen_scale 4.00
+Rust
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension rs
+ 3rd_gen_scale 1.00
+SAS
+ filter call_regexp_common C
+ filter remove_between_general * ;
+ extension sas
+ 3rd_gen_scale 1.50
+SKILL
+ filter call_regexp_common C
+ filter remove_matches ^\s*;
+ extension il
+ 3rd_gen_scale 2.00
+SKILL++
+ filter call_regexp_common C
+ filter remove_matches ^\s*;
+ extension ils
+ 3rd_gen_scale 2.00
+SQL
+ filter call_regexp_common C
+ filter remove_matches ^\s*--
+ filter remove_inline --.*$
+ extension SQL
+ extension psql
+ extension sql
+ 3rd_gen_scale 2.29
+SQL Data
+ filter call_regexp_common C
+ filter remove_matches ^\s*--
+ filter remove_inline --.*$
+ extension data.sql
+ 3rd_gen_scale 1.00
+SQL Stored Procedure
+ filter call_regexp_common C
+ filter remove_matches ^\s*--
+ filter remove_inline --.*$
+ extension spc.sql
+ extension spoc.sql
+ extension sproc.sql
+ extension udf.sql
+ 3rd_gen_scale 6.15
+Sass
+ filter remove_matches ^\s*//
+ filter remove_inline //.*$
+ extension sass
+ extension scss
+ 3rd_gen_scale 1.50
+Scala
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension scala
+ 3rd_gen_scale 4.10
+Slice
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension ice
+ 3rd_gen_scale 1.50
+Slim
+ filter remove_slim_block
+ extension slim
+ 3rd_gen_scale 3.00
+Smarty
+ filter smarty_to_C
+ filter call_regexp_common C
+ extension smarty
+ extension tpl
+ 3rd_gen_scale 3.50
+Softbridge Basic
+ filter remove_above ^\s*Attribute\s+VB_Name\s+=
+ filter remove_matches ^\s*Attribute\s+
+ filter remove_matches ^\s*\47
+ extension SBL
+ extension sbl
+ 3rd_gen_scale 2.76
+Specman e
+ filter pre_post_fix '> <'
+ filter remove_between_general '> <'
+ filter call_regexp_common C++
+ filter remove_matches ^\s*--
+ extension e
+ 3rd_gen_scale 2.00
+Standard ML
+ filter remove_between_general (* *)
+ extension fun
+ extension sig
+ extension sml
+ 3rd_gen_scale 3.00
+Stylus
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension styl
+ 3rd_gen_scale 1.48
+ end_of_line_continuation \\$
+Swift
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension swift
+ 3rd_gen_scale 2.50
+ end_of_line_continuation \\$
+TITAN Project File Information
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension tpd
+ 3rd_gen_scale 1.90
+TTCN
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension ttcn
+ extension ttcn2
+ extension ttcn3
+ extension ttcnpp
+ 3rd_gen_scale 2.00
+ end_of_line_continuation \\$
+Tcl/Tk
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension itk
+ extension tcl
+ extension tk
+ script_exe tcl
+ script_exe tclsh
+ script_exe wish
+ 3rd_gen_scale 4.00
+ end_of_line_continuation \\$
+TeX
+ filter remove_matches ^\s*%
+ filter remove_inline %.*$
+ extension bst
+ extension dtx
+ extension sty
+ extension tex
+ 3rd_gen_scale 1.50
+Teamcenter def
+ filter remove_matches ^\s*#
+ 3rd_gen_scale 1.00
+Teamcenter met
+ filter call_regexp_common C
+ extension met
+ 3rd_gen_scale 1.00
+Teamcenter mth
+ filter remove_matches ^\s*#
+ extension mth
+ 3rd_gen_scale 1.00
+Titanium Style Sheet
+ filter remove_matches ^\s*//
+ filter remove_inline //.*$
+ filter remove_between_regex /[^/] [^/]/
+ extension tss
+ 3rd_gen_scale 2.00
+Twig
+ filter remove_between_general {# #}
+ extension twig
+ 3rd_gen_scale 2.00
+TypeScript
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension tsx
+ 3rd_gen_scale 2.00
+ end_of_line_continuation \\$
+Unity-Prefab
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension mat
+ extension prefab
+ 3rd_gen_scale 2.50
+VHDL
+ filter remove_matches ^\s*--
+ filter call_regexp_common C++
+ filter remove_inline --.*$
+ filter remove_inline //.*$
+ extension VHD
+ extension VHDL
+ extension vhd
+ extension vhdl
+ 3rd_gen_scale 4.21
+Vala
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension vala
+ 3rd_gen_scale 1.50
+ end_of_line_continuation \\$
+Vala Header
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension vapi
+ 3rd_gen_scale 1.40
+ end_of_line_continuation \\$
+Velocity Template Language
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filter remove_jsp_comments
+ filter remove_matches ^\s*//
+ filter add_newlines
+ filter call_regexp_common C
+ extension vm
+ 3rd_gen_scale 1.00
+Verilog-SystemVerilog
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension sv
+ extension svh
+ 3rd_gen_scale 1.51
+Visual Basic
+ filter remove_above ^\s*Attribute\s+VB_Name\s+=
+ filter remove_matches ^\s*Attribute\s+
+ filter remove_matches ^\s*\47
+ extension VB
+ extension VBA
+ extension VBS
+ extension bas
+ extension cls
+ extension ctl
+ extension dsr
+ extension frm
+ extension vb
+ extension vba
+ extension vbs
+ 3rd_gen_scale 2.76
+Visual Fox Pro
+ filter remove_matches ^\s*\*
+ filter remove_inline \*.*$
+ filter remove_matches ^\s*&&
+ filter remove_inline &&.*$
+ extension SCA
+ extension sca
+ 3rd_gen_scale 4.00
+Visualforce Component
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension component
+ 3rd_gen_scale 1.90
+Visualforce Page
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension page
+ 3rd_gen_scale 1.90
+Vuejs Component
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ filter call_regexp_common C++
+ extension vue
+ 3rd_gen_scale 2.00
+WiX include
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension wxi
+ 3rd_gen_scale 1.90
+WiX source
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension wxs
+ 3rd_gen_scale 1.90
+WiX string localization
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension wxl
+ 3rd_gen_scale 1.90
+Windows Message File
+ filter remove_matches ^\s*;\s*//
+ filter call_regexp_common C
+ filter remove_matches ^\s*;\s*$
+ extension mc
+ 3rd_gen_scale 1.00
+Windows Module Definition
+ filter remove_matches ^\s*;
+ filter remove_inline ;.*$
+ extension def
+ 3rd_gen_scale 1.00
+Windows Resource File
+ filter remove_inline //.*$
+ filter call_regexp_common C++
+ extension rc
+ extension rc2
+ 3rd_gen_scale 1.00
+XAML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension xaml
+ 3rd_gen_scale 1.90
+XHTML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension xhtml
+ 3rd_gen_scale 1.90
+XMI
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension XMI
+ extension xmi
+ 3rd_gen_scale 1.90
+XML
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension XML
+ extension xml
+ 3rd_gen_scale 1.90
+XQuery
+ filter remove_between_general (: :)
+ extension xq
+ extension xquery
+ 3rd_gen_scale 2.50
+XSD
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension XSD
+ extension xsd
+ 3rd_gen_scale 1.90
+XSLT
+ filter remove_html_comments
+ filter call_regexp_common HTML
+ extension XSL
+ extension XSLT
+ extension xsl
+ extension xslt
+ 3rd_gen_scale 1.90
+YAML
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension yaml
+ extension yml
+ 3rd_gen_scale 0.90
+awk
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension awk
+ script_exe awk
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
+bc
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ script_exe bc
+ 3rd_gen_scale 1.50
+ end_of_line_continuation \\$
+builder
+ filter remove_matches ^\s*xml_markup.comment!
+ extension xml.builder
+ 3rd_gen_scale 2.00
+diff
+ filter remove_matches ^#
+ filter remove_matches ^\-\-\-
+ filter remove_matches ^\+\+\+
+ filter remove_matches ^\s
+ extension diff
+ 3rd_gen_scale 1.00
+dtrace
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ script_exe dtrace
+ 3rd_gen_scale 2.00
+lex
+ filter call_regexp_common C
+ extension l
+ 3rd_gen_scale 1.00
+ end_of_line_continuation \\$
+liquid
+ filter remove_between_general {% comment %} {% endcomment %}
+ filter remove_html_comments
+ extension liquid
+ 3rd_gen_scale 3.00
+m4
+ filter remove_matches ^dnl
+ extension ac
+ extension m4
+ 3rd_gen_scale 1.00
+make
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension Gnumakefile
+ extension Makefile
+ extension am
+ extension gnumakefile
+ extension makefile
+ extension mk
+ filename Gnumakefile
+ filename Makefile
+ filename gnumakefile
+ filename makefile
+ script_exe make
+ 3rd_gen_scale 2.50
+ end_of_line_continuation \\$
+sed
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension sed
+ script_exe sed
+ 3rd_gen_scale 4.00
+ end_of_line_continuation \\$
+vim script
+ filter remove_matches ^\s*"
+ filter remove_inline ".*$
+ extension vim
+ 3rd_gen_scale 3.00
+xBase
+ filter remove_matches ^\s*\&\&
+ filter remove_matches ^\s*\*
+ filter remove_matches ^\s*NOTE
+ filter remove_matches ^\s*note
+ filter remove_matches ^\s*Note
+ filter remove_inline //.*$
+ filter remove_inline \&\&.*$
+ filter call_regexp_common C++
+ extension prg
+ 3rd_gen_scale 2.00
+xBase Header
+ filter remove_matches ^\s*\&\&
+ filter remove_matches ^\s*\*
+ filter remove_matches ^\s*NOTE
+ filter remove_matches ^\s*note
+ filter remove_matches ^\s*Note
+ filter remove_inline //.*$
+ filter remove_inline \&\&.*$
+ filter call_regexp_common C++
+ extension ch
+ 3rd_gen_scale 2.00
+yacc
+ filter call_regexp_common C++
+ filter remove_inline //.*$
+ extension y
+ 3rd_gen_scale 1.51
+zsh
+ filter remove_matches ^\s*#
+ filter remove_inline #.*$
+ extension zsh
+ script_exe zsh
+ 3rd_gen_scale 3.81
+ end_of_line_continuation \\$
diff --git a/pom.xml b/pom.xml
index 1bb647e..72ba14e 100644..100755
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
<configuration>
<mainClass>bjc.rgens.parser.RGrammarTest</mainClass>
<arguments>
+ <argument>-Xss1M</argument>
</arguments>
</configuration>
</plugin>
@@ -54,7 +55,7 @@
<includes>
<include>**/*.gram</include>
- <include>**/*.cfg</include>
+ <include>**/*.gcfg</include>
</includes>
</resource>
</resources>
@@ -68,6 +69,12 @@
</dependency>
<dependency>
+ <groupId>bjc</groupId>
+ <artifactId>inflexion</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
<groupId>com.github.mifmif</groupId>
<artifactId>generex</artifactId>
<version>1.0.2</version>
diff --git a/src/main/java/bjc/rgens/ZadronsPouch.java b/src/main/java/bjc/rgens/ZadronsPouch.java
index 827d022..827d022 100644..100755
--- a/src/main/java/bjc/rgens/ZadronsPouch.java
+++ b/src/main/java/bjc/rgens/ZadronsPouch.java
diff --git a/src/main/java/bjc/rgens/parser/ConfigLoader.java b/src/main/java/bjc/rgens/parser/ConfigLoader.java
new file mode 100644
index 0000000..6e9da16
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/ConfigLoader.java
@@ -0,0 +1,242 @@
+package bjc.rgens.parser;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Scanner;
+
+import bjc.rgens.parser.templates.GrammarTemplate;
+
+public class ConfigLoader {
+ /**
+ * Load a grammar set from a configuration file.
+ *
+ * @param cfgFile
+ * The configuration file to load from.
+ *
+ * @return
+ * The grammar set created by the configuration file.
+ *
+ * @throws IOException
+ * If something goes wrong during configuration loading.
+ */
+ public static ConfigSet fromConfigFile(Path cfgFile) throws IOException {
+ ConfigSet cfgSet = new ConfigSet();
+
+ /* The grammar set we're parsing into. */
+ RGrammarSet set = new RGrammarSet();
+ cfgSet.grammars.put("default", set);
+ set.belongsTo = cfgSet;
+ set.name = "default";
+
+ long startCFGTime = System.nanoTime();
+
+ /* Get the directory that contains the config file. */
+ Path cfgParent = cfgFile.getParent();
+
+ try(Scanner scn = new Scanner(cfgFile)) {
+ int lno = 0;
+
+ /* Execute lines from the configuration file. */
+ while (scn.hasNextLine()) {
+ String ln = scn.nextLine().trim();
+
+ lno += 1;
+
+ try {
+ /* Ignore blank/comment lines. */
+ if (ln.equals("")) continue;
+
+ if (ln.startsWith("#")) continue;
+
+ /* Handle mixed whitespace. */
+ ln = ln.replaceAll("\\s+", " ");
+
+ /* Get line type */
+ int typeIdx = ln.indexOf(" ");
+ if(typeIdx == -1) {
+ throw new GrammarException("Must specify config line type");
+ }
+ String type = ln.substring(0, typeIdx).trim();
+ ln = ln.substring(typeIdx).trim();
+
+ switch(type) {
+ case "load":
+ loadConfigLine(ln, cfgSet, set, cfgParent);
+ break;
+ default:
+ throw new GrammarException("Unknown config line type " + type);
+ }
+ } catch(GrammarException gex) {
+ System.out.printf("ERROR: Line %s of config set %s\n", lno, cfgFile);
+
+ System.err.printf("ERROR: Line %s of config set %s\n", lno, cfgFile);
+ gex.printStackTrace();
+
+ System.out.println();
+ System.out.println();
+
+ System.err.println();
+ System.err.println();
+ }
+ }
+ }
+
+ long endCFGTime = System.nanoTime();
+
+ long cfgDur = endCFGTime - startCFGTime;
+
+ System.err.printf("\n\nPERF: Read config file %s in %d ns (%f s)\n", cfgFile, cfgDur, cfgDur / 1000000000.0);
+
+ return cfgSet;
+ }
+
+ private static void loadConfigLine(String ln, ConfigSet cfgSet, RGrammarSet set, Path cfgParent) throws IOException {
+ /*
+ * Get the place where the tag ID ends
+ */
+ int tagIdx = ln.indexOf(" ");
+ if(tagIdx == -1) {
+ throw new GrammarException("Must specify a tag as to what a line is");
+ }
+ String tag = ln.substring(0, tagIdx).trim();
+ ln = ln.substring(tagIdx).trim();
+
+ /*
+ * Get the place where the name of the grammar
+ * ends.
+ */
+ int nameIdx = ln.indexOf(" ");
+ if (nameIdx == -1) {
+ throw new GrammarException("Must specify a name for a loaded object");
+ }
+ String name = ln.substring(0, nameIdx);
+ ln = ln.substring(nameIdx).trim();
+
+ switch(tag) {
+ case "template":
+ loadTemplate(name, ln, cfgSet, set, cfgParent);
+ break;
+ case "subset":
+ {
+ /* @TODO implement subset grammars */
+ throw new GrammarException("Sub-grammar sets aren't implemented yet");
+ }
+ case "gram":
+ case "grammar":
+ loadGrammar(name, ln, cfgSet, set, cfgParent);
+ break;
+ default:
+ String msg = String.format("Unrecognized tag type '%s'", tag);
+ throw new GrammarException(msg);
+ }
+ }
+
+ private static void loadTemplate(String name, String ln, ConfigSet cfgSet, RGrammarSet set, Path cfgParent) throws IOException {
+ Path path = Paths.get(ln);
+
+ /*
+ * Convert from configuration relative path to
+ * absolute path.
+ */
+ Path convPath = cfgParent.resolve(path.toString());
+
+ if(Files.isDirectory(convPath)) {
+ throw new GrammarException("Can't load grammar from directory" + convPath.toString());
+ } else {
+ /* Load template file. */
+ try {
+ long startFileTime = System.nanoTime();
+
+ BufferedReader fis = Files.newBufferedReader(convPath);
+ GrammarTemplate template = GrammarTemplate.readTemplate(fis);
+ template.belongsTo = cfgSet;
+
+ if(template.name == null) {
+ System.err.printf("\tINFO: Naming unnamed template loaded from %s off config name '%s'\n",
+ convPath, name);
+
+ template.name = name;
+ }
+
+ fis.close();
+
+ long endFileTime = System.nanoTime();
+
+ long fileTime = endFileTime - startFileTime;
+
+ System.err.printf("\tPERF: Read template %s (from %s) in %d ns (%f s)\n",
+ template.name, convPath, fileTime, fileTime / 1000000000.0);
+
+ /* Add grammar to the set. */
+ cfgSet.templates.put(name, template);
+
+ /*
+ * @NOTE
+ *
+ * Do we need to do this
+ * for templates?
+ *
+ * Mark where the
+ * template came
+ * from.
+ */
+ //set.loadedFrom.put(name, path.toString());
+ } catch (GrammarException gex) {
+ String msg = String.format("Error loading template file '%s'", path);
+ throw new GrammarException(msg, gex);
+ }
+ }
+ }
+
+ private static void loadGrammar(String name, String ln, ConfigSet cfgSet, RGrammarSet set, Path cfgParent) throws IOException {
+ Path path = Paths.get(ln);
+
+ /*
+ * Convert from configuration relative path to
+ * absolute path.
+ */
+ Path convPath = cfgParent.resolve(path.toString());
+
+ if(Files.isDirectory(convPath)) {
+ throw new GrammarException("Can't load grammar from directory" + convPath.toString());
+ } else {
+ /* Load grammar file. */
+ try {
+ long startFileTime = System.nanoTime();
+
+ BufferedReader fis = Files.newBufferedReader(convPath);
+ RGrammar gram = RGrammarParser.readGrammar(fis);
+ if(gram.name == null) {
+ System.err.printf("\tINFO: Naming unnamed grammar loaded from %s off config name '%s'\n",
+ convPath, name);
+
+ gram.name = name;
+ }
+
+ fis.close();
+
+ long endFileTime = System.nanoTime();
+
+ long fileTime = endFileTime - startFileTime;
+
+ System.err.printf("\tPERF: Read grammar %s (from %s) in %d ns (%f s)\n",
+ gram.name, convPath, fileTime, fileTime / 1000000000.0);
+
+ /* Add grammar to the set. */
+ set.addGrammar(name, gram);
+
+ /*
+ * Mark where the grammar came
+ * from.
+ */
+ set.loadedFrom.put(name, path.toString());
+ } catch (GrammarException gex) {
+ String msg = String.format("Error loading template '%s'", path);
+ throw new GrammarException(msg, gex);
+ }
+ }
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/ConfigSet.java b/src/main/java/bjc/rgens/parser/ConfigSet.java
new file mode 100644
index 0000000..8945a0f
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/ConfigSet.java
@@ -0,0 +1,18 @@
+package bjc.rgens.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import bjc.rgens.parser.templates.GrammarTemplate;
+
+public class ConfigSet {
+ public final Map<String, RGrammarSet> grammars;
+ public final Map<String, GrammarTemplate> templates;
+ public final Map<String, ConfigSet> subconfigs;
+
+ public ConfigSet() {
+ grammars = new HashMap<>();
+ templates = new HashMap<>();
+ subconfigs = new HashMap<>();
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/FlatRuleCase.java b/src/main/java/bjc/rgens/parser/FlatRuleCase.java
new file mode 100644
index 0000000..4bbd1cc
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/FlatRuleCase.java
@@ -0,0 +1,23 @@
+package bjc.rgens.parser;
+
+import bjc.utils.funcdata.IList;
+
+import bjc.rgens.parser.elements.CaseElement;
+
+public class FlatRuleCase extends RuleCase {
+ public FlatRuleCase(IList<CaseElement> elms) {
+ super(elms);
+ }
+
+ @Override
+ public void generate(GenerationState state) {
+ for(CaseElement elm : elementList) {
+ elm.generate(state);
+ }
+ }
+
+ public FlatRuleCase withElements(IList<CaseElement> elms) {
+ return new FlatRuleCase(elms);
+ }
+}
+
diff --git a/src/main/java/bjc/rgens/parser/GenerationState.java b/src/main/java/bjc/rgens/parser/GenerationState.java
new file mode 100644
index 0000000..f5cbc60
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/GenerationState.java
@@ -0,0 +1,104 @@
+package bjc.rgens.parser;
+
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+/*
+ * The current state during generation.
+ *
+ */
+public class GenerationState {
+ /** The current string. */
+ public StringBuilder contents;
+ /** The RNG. */
+ public Random rnd;
+
+ /** The current grammar. */
+ public RGrammar gram;
+ /** The rules of the grammar. */
+ public Map<String, Rule> rules;
+ /** The rules imported from other grammars. */
+ public Map<String, Rule> importRules;
+
+ /** The current set of variables. */
+ public Map<String, String> vars;
+ public Map<String, Rule> rlVars;
+
+ private static final Random BASE = new Random();
+
+ /**
+ * Create a new generation state.
+ *
+ * @param cont
+ * The string being generated.
+ *
+ * @param rand
+ * The RNG to use.
+ *
+ * @param vs
+ * The variables to use.
+ */
+ public GenerationState(StringBuilder cont, Random rand, Map<String, String> vs,
+ Map<String, Rule> rvs, RGrammar gram) {
+ contents = cont;
+ rnd = rand;
+ vars = vs;
+ rlVars = rvs;
+
+ this.gram = gram;
+
+ this.rules = gram.getRules();
+ this.importRules = gram.getImportRules();
+ }
+
+ public static GenerationState fromGrammar(RGrammar gram) {
+ return fromGrammar(BASE, gram);
+ }
+
+ public static GenerationState fromGrammar(Random rand, RGrammar gram) {
+ return new GenerationState(new StringBuilder(), rand, new HashMap<>(), new HashMap<>(), gram);
+ }
+
+ public void swapGrammar(RGrammar gram) {
+ if(this.gram == gram) return;
+
+ this.gram = gram;
+
+ rules = gram.getRules();
+
+ importRules = gram.getImportRules();
+ }
+
+ public GenerationState newBuf() {
+ return new GenerationState(new StringBuilder(), rnd, vars, rlVars, gram);
+ }
+
+ /*
+ * @TODO 6/5/18 Ben Culkin :ImportRefactor
+ *
+ * Change this so that imports in almost all cases have to specify where
+ * they are importing the rule from, so as to make it clear which rules
+ * are imported, and which aren't
+ */
+ public Rule findRule(String ruleName, boolean allowImports) {
+ if(rules.containsKey(ruleName)) {
+ return rules.get(ruleName);
+ }
+
+ if(allowImports) return findImport(ruleName);
+
+ return null;
+ }
+
+ public Rule findImport(String ruleName) {
+ if(importRules.containsKey(ruleName)) {
+ return importRules.get(ruleName);
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/GrammarException.java b/src/main/java/bjc/rgens/parser/GrammarException.java
index 9eaa0a1..9eaa0a1 100644..100755
--- a/src/main/java/bjc/rgens/parser/GrammarException.java
+++ b/src/main/java/bjc/rgens/parser/GrammarException.java
diff --git a/src/main/java/bjc/rgens/parser/NormalRuleCase.java b/src/main/java/bjc/rgens/parser/NormalRuleCase.java
new file mode 100644
index 0000000..c8891a2
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/NormalRuleCase.java
@@ -0,0 +1,26 @@
+package bjc.rgens.parser;
+
+import bjc.utils.funcdata.IList;
+
+import bjc.rgens.parser.elements.CaseElement;
+
+public class NormalRuleCase extends RuleCase {
+ public NormalRuleCase(IList<CaseElement> elms) {
+ super(elms);
+ }
+
+ @Override
+ public void generate(GenerationState state) {
+ for(CaseElement elm : elementList) {
+ elm.generate(state);
+
+ if(elm.spacing) {
+ state.contents.append(" ");
+ }
+ }
+ }
+
+ public NormalRuleCase withElements(IList<CaseElement> elms) {
+ return new NormalRuleCase(elms);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/RGrammar.java b/src/main/java/bjc/rgens/parser/RGrammar.java
index 38f38c8..337ab35 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammar.java
+++ b/src/main/java/bjc/rgens/parser/RGrammar.java
@@ -1,14 +1,16 @@
package bjc.rgens.parser;
-import bjc.rgens.parser.elements.CaseElement;
-import bjc.rgens.parser.elements.LiteralCaseElement;
-import bjc.rgens.parser.elements.RangeCaseElement;
-import bjc.rgens.parser.elements.RuleCaseElement;
-import bjc.rgens.parser.elements.VariableCaseElement;
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
import bjc.utils.funcutils.StringUtils;
+import bjc.rgens.parser.elements.*;
+
+import java.util.Arrays;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -22,12 +24,23 @@ import edu.gatech.gtri.bktree.BkTreeSearcher.Match;
import edu.gatech.gtri.bktree.Metric;
import edu.gatech.gtri.bktree.MutableBkTree;
+import static bjc.utils.data.IPair.pair;
+
/**
* Represents a randomized grammar.
*
* @author EVE
*/
public class RGrammar {
+ public RGrammarSet belongsTo;
+
+ public String name;
+
+ public List<IPair<String, String>> postprocs;
+
+ private static final List<IPair<String, String>> builtinPostprocs;
+ public boolean useBuiltinPostprocs = true;
+
/* The max distance between possible alternate rules. */
private static final int MAX_DISTANCE = 6;
@@ -48,42 +61,10 @@ public class RGrammar {
}
}
- /* The current state during generation. */
- private static class GenerationState {
- /* The current string. */
- public StringBuilder contents;
- /* The RNG. */
- public Random rnd;
-
- /* The current set of variables. */
- public Map<String, String> vars;
-
- /**
- * Create a new generation state.
- *
- * @param cont
- * The string being generated.
- *
- * @param rand
- * The RNG to use.
- *
- * @param vs
- * The variables to use.
- */
- public GenerationState(StringBuilder cont, Random rand, Map<String, String> vs) {
- contents = cont;
- rnd = rand;
- vars = vs;
- }
- }
-
- /* The pattern for matching the name of a variable. */
- private static Pattern NAMEVAR_PATTERN = Pattern.compile("\\$(\\w+)");
-
/* The rules of the grammar. */
- private Map<String, Rule> rules;
+ public Map<String, Rule> rules;
/* The rules imported from other grammars. */
- private Map<String, RGrammar> importRules;
+ private Map<String, Rule> importRules;
/* The rules exported from this grammar. */
private Set<String> exportRules;
/* The initial rule of this grammar. */
@@ -92,6 +73,43 @@ public class RGrammar {
/* The tree to use for finding rule suggestions. */
private BkTreeSearcher<String> ruleSearcher;
+ static {
+ /* Collapse duplicate spaces */
+ IPair<String, String> collapseDupSpaces = pair("\\s+", " ");
+
+ /* Built-in post-processing steps */
+ builtinPostprocs = Arrays.asList(
+ collapseDupSpaces,
+
+ /*
+ * Remove extraneous spaces around punctuation
+ * marks, forced by the way the language syntax
+ * works.
+ *
+ * This can be done in grammars, but it is quite
+ * tedious to do so.
+ */
+
+
+ /* Handle 's */
+ pair(" 's ", "'s "),
+ /* Handle opening/closing punctuation. */
+ pair("([(\\[]) ", " $1"),
+ pair(" ([)\\]'\"])", "$1 "),
+ /* Remove spaces around series of opening/closing punctuation. */
+ pair("([(\\[])\\s+([(\\[])", "$1$2"),
+ pair("([)\\]])\\s+([)\\]])", "$1$2"),
+ /* Handle inter-word punctuation. */
+ pair(" ([,:.!])", "$1 "),
+ /* Handle intra-word punctuation. */
+ pair("\\s?([-/])\\s?", "$1"),
+
+ collapseDupSpaces,
+
+ /* Replace this once it is no longer needed. */
+ pair("\\s(ish|burg|ton|ville|opolis|field|boro|dale)", "$1")
+ );
+ }
/**
* Create a new randomized grammar using the specified set of rules.
*
@@ -100,6 +118,12 @@ public class RGrammar {
*/
public RGrammar(Map<String, Rule> ruls) {
rules = ruls;
+
+ for(Rule rl : ruls.values()) {
+ rl.belongsTo = this;
+ }
+
+ postprocs = new ArrayList<>();
}
/**
@@ -111,7 +135,7 @@ public class RGrammar {
* @param importedRules
* The set of imported rules to use.
*/
- public void setImportedRules(Map<String, RGrammar> importedRules) {
+ public void setImportedRules(Map<String, Rule> importedRules) {
importRules = importedRules;
}
@@ -137,7 +161,7 @@ public class RGrammar {
* @return A possible string from the grammar.
*/
public String generate(String startRule) {
- return generate(startRule, new Random(), new HashMap<>());
+ return generate(startRule, new Random(), new HashMap<>(), new HashMap<>());
}
/**
@@ -155,7 +179,26 @@ public class RGrammar {
*
* @return A possible string from the grammar.
*/
- public String generate(String startRule, Random rnd, Map<String, String> vars) {
+ public String generate(String startRule, Random rnd, Map<String, String> vars,
+ Map<String, Rule> rlVars) {
+ return generate(startRule, new GenerationState(new StringBuilder(), rnd, vars, rlVars, this));
+ }
+
+ /**
+ * Generate a string from this grammar, starting from the specified rule.
+ *
+ * @param startRule
+ * The rule to start generating at, or null to use the initial rule
+ * for this grammar.
+ *
+ * @param state
+ * The generation state.
+ */
+ public String generate(String startRule, GenerationState state) {
+ return generate(startRule, state, true);
+ }
+
+ public String generate(String startRule, GenerationState state, boolean doPostprocess) {
String fromRule = startRule;
if (startRule == null) {
@@ -170,242 +213,55 @@ public class RGrammar {
}
}
- RuleCase start = rules.get(fromRule).getCase(rnd);
-
- StringBuilder contents = new StringBuilder();
-
- generateCase(start, new GenerationState(contents, rnd, vars));
-
- String body = contents.toString();
- /*
- * Collapse duplicate spaces.
+ /*
+ * We don't search imports, so it will always belong to this
+ * grammar.
*/
- body = body.replaceAll("\\s+", " ");
-
- /*
- * Remove extraneous spaces around punctutation marks.
- *
- * This can be done in the grammars, but it is very tedious to do so.
- */
-
- /* Handle 's */
- body = body.replaceAll(" 's ", "'s ");
-
- /* Handle opening/closing punctuation. */
- body = body.replaceAll("([(\\[]) ", " $1");
- body = body.replaceAll(" ([)\\]'\"])", "$1 ");
+ Rule rl = state.findRule(fromRule, false);
- /* Remove spaces around series of opening/closing punctuation. */
- body = body.replaceAll("([(\\[])\\s+([(\\[])", "$1$2");
- body = body.replaceAll("([)\\]])\\s+([)\\]])", "$1$2");
+ if(rl == null)
+ throw new GrammarException("Could not find rule " + rl.name);
- /* Handle inter-word punctuation. */
- body = body.replaceAll(" ([,:.!])", "$1 ");
+ rl.generate(state);
- /* Handle intra-word punctuation. */
- body = body.replaceAll("\\s?([-/])\\s?", "$1");
+ String body = state.contents.toString();
- /*
- * Collapse duplicate spaces.
- */
- body = body.replaceAll("\\s+", " ");
-
- /*
- * @TODO 11/01/17 Ben Culkin :RegexRule Replace this once it is no longer
- * needed.
- */
- body = body.replaceAll("\\s(ish|burg|ton|ville|opolis|field|boro|dale)", "$1");
+ if(doPostprocess) {
+ body = postprocessRes(body);
+ }
return body;
}
- /* Generate a rule case. */
- private void generateCase(RuleCase start, GenerationState state) {
- try {
- switch (start.type) {
- case NORMAL:
- for (CaseElement elm : start.getElements()) {
- generateElement(elm, state);
-
- if (elm.type != CaseElement.ElementType.VARDEF) {
- state.contents.append(" ");
- }
- }
- break;
- case SPACEFLATTEN:
- for (CaseElement elm : start.getElements()) {
- generateElement(elm, state);
- }
- break;
- default:
- String msg = String.format("Unknown case type '%s'", start.type);
- throw new GrammarException(msg);
- }
- } catch (GrammarException gex) {
- String msg = String.format("Error in generating case (%s)", start);
- throw new GrammarException(msg, gex);
- }
- }
-
- /* Generate a case element. */
- private void generateElement(CaseElement elm, GenerationState state) {
- try {
- switch (elm.type) {
- case LITERAL: {
- LiteralCaseElement lit = (LiteralCaseElement)elm;
-
- state.contents.append(lit.val);
- break;
- }
- case RULEREF: {
- RuleCaseElement rle = (RuleCaseElement)elm;
-
- generateRuleReference(rle, state);
- break;
- }
- case RANGE: {
- RangeCaseElement rang = (RangeCaseElement)elm;
+ private String postprocessRes(String strang) {
+ String body = strang;
- int val = state.rnd.nextInt(rang.end - rang.begin);
- val += rang.begin;
-
- state.contents.append(val);
- break;
- }
- case VARDEF:
- generateVarDef(((VariableCaseElement)elm).varName, ((VariableCaseElement)elm).varDef, state);
- break;
- case EXPVARDEF:
- generateExpVarDef(((VariableCaseElement)elm).varName, ((VariableCaseElement)elm).varDef, state);
- break;
- default:
- String msg = String.format("Unknown element type '%s'", elm.type);
- throw new GrammarException(msg);
+ if(useBuiltinPostprocs) {
+ for(IPair<String, String> par : builtinPostprocs) {
+ body = body.replaceAll(par.getLeft(), par.getRight());
}
- } catch (GrammarException gex) {
- String msg = String.format("Error in generating case element (%s)", elm);
- throw new GrammarException(msg, gex);
}
- }
-
- /* Generate a expanding variable definition. */
- private void generateExpVarDef(String name, String defn, GenerationState state) {
- GenerationState newState = new GenerationState(new StringBuilder(), state.rnd, state.vars);
- if (rules.containsKey(defn)) {
- RuleCase destCase = rules.get(defn).getCase();
-
- generateCase(destCase, newState);
- } else if (importRules.containsKey(defn)) {
- RGrammar destGrammar = importRules.get(defn);
- String res = destGrammar.generate(defn, state.rnd, state.vars);
-
- newState.contents.append(res);
- } else {
- String msg = String.format("No rule '%s' defined", defn);
- throw new GrammarException(msg);
+ for(IPair<String, String> par : postprocs) {
+ body = body.replaceAll(par.getLeft(), par.getRight());
}
- state.vars.put(name, newState.contents.toString());
- }
-
- /* Generate a variable definition. */
- private static void generateVarDef(String name, String defn, GenerationState state) {
- state.vars.put(name, defn);
+ return body.trim();
}
-
- /* Generate a rule reference. */
- private void generateRuleReference(RuleCaseElement elm, GenerationState state) {
- String refersTo = elm.val;
-
- GenerationState newState = new GenerationState(new StringBuilder(), state.rnd, state.vars);
-
- if (refersTo.contains("$")) {
- /* Parse variables */
- String refBody = refersTo.substring(1, refersTo.length() - 1);
-
- if (refBody.contains("-")) {
- /* Handle dependent rule names. */
- StringBuffer nameBuffer = new StringBuffer();
-
- Matcher nameMatcher = NAMEVAR_PATTERN.matcher(refBody);
-
- while (nameMatcher.find()) {
- String var = nameMatcher.group(1);
-
- if (!state.vars.containsKey(var)) {
- String msg = String.format("No variable '%s' defined", var);
- throw new GrammarException(msg);
- }
-
- String name = state.vars.get(var);
-
- if (name.contains(" ")) {
- throw new GrammarException("Variables substituted into names cannot contain spaces");
- } else if (name.equals("")) {
- throw new GrammarException("Variables substituted into names cannot be empty");
- }
-
- nameMatcher.appendReplacement(nameBuffer, name);
- }
-
- nameMatcher.appendTail(nameBuffer);
-
- refersTo = "[" + nameBuffer.toString() + "]";
- } else {
- /* Handle string references. */
- if (refBody.equals("$")) {
- throw new GrammarException("Cannot refer to unnamed variables");
- }
-
- String key = refBody.substring(1);
-
- if (!state.vars.containsKey(key)) {
- String msg = String.format("No variable '%s' defined", key);
- throw new GrammarException(msg);
- }
-
- state.contents.append(state.vars.get(key));
-
- return;
- }
- }
-
- if (refersTo.startsWith("[^")) {
- refersTo = "[" + refersTo.substring(2);
-
- RGrammar dst = importRules.get(refersTo);
-
- newState.contents.append(dst.generate(refersTo, state.rnd, state.vars));
- } else if (rules.containsKey(refersTo)) {
- RuleCase cse = rules.get(refersTo).getCase(state.rnd);
-
- generateCase(cse, newState);
- } else if (importRules.containsKey(refersTo)) {
- RGrammar dst = importRules.get(refersTo);
-
- newState.contents.append(dst.generate(refersTo, state.rnd, state.vars));
- } else {
- if (ruleSearcher != null) {
- Set<Match<? extends String>> results = ruleSearcher.search(refersTo, MAX_DISTANCE);
-
- String[] resArray = results.stream().map(Match::getMatch).toArray((i) -> new String[i]);
-
- String msg = String.format("No rule '%s' defined (perhaps you meant %s?)", refersTo,
- StringUtils.toEnglishList(resArray, false));
-
- throw new GrammarException(msg);
- }
-
- String msg = String.format("No rule '%s' defined", refersTo);
- throw new GrammarException(msg);
- }
-
- if (refersTo.contains("+")) {
- /* Rule names with pluses in them get space-flattened */
- state.contents.append(newState.contents.toString().replaceAll("\\s+", ""));
- } else {
- state.contents.append(newState.contents.toString());
+ /**
+ * Generate a rule case.
+ *
+ * @param start
+ * The rule case to generate.
+ * @param state
+ * The current generation state.
+ */
+ public void generateCase(RuleCase start, GenerationState state) {
+ try {
+ start.generate(state);
+ } catch (GrammarException gex) {
+ String msg = String.format("Error in generating case (%s)", start);
+ throw new GrammarException(msg, gex);
}
}
@@ -435,7 +291,7 @@ public class RGrammar {
if (initRule.equals("")) {
throw new GrammarException("The empty string is not a valid rule name");
} else if (!rules.containsKey(initRule)) {
- String msg = String.format("No rule '%s' local to this grammar defined.", initRule);
+ String msg = String.format("No rule '%s' local to this grammar (%s) defined.", initRule, name);
throw new GrammarException(msg);
}
@@ -455,7 +311,8 @@ public class RGrammar {
for (String rname : exportRules) {
if (!rules.containsKey(rname)) {
- String msg = String.format("No rule '%s' local to this grammar defined", initialRule);
+ String msg = String.format("No rule '%s' local to this grammar (%s) defined for export",
+ name, rname);
throw new GrammarException(msg);
}
@@ -488,4 +345,8 @@ public class RGrammar {
public Map<String, Rule> getRules() {
return rules;
}
+
+ public Map<String, Rule> getImportRules() {
+ return importRules;
+ }
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
index b4cb04a..8f0a2d1 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
@@ -1,13 +1,19 @@
package bjc.rgens.parser;
import bjc.rgens.parser.elements.CaseElement;
+
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
+import bjc.utils.funcutils.ListUtils;
+import bjc.utils.funcutils.SetUtils;
-import static bjc.rgens.parser.RuleCase.CaseType.*;
-
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
@@ -46,9 +52,9 @@ public class RGrammarBuilder {
else if(rName.equals(""))
throw new IllegalArgumentException("The empty string is not a valid rule name");
- if(rules.containsKey(rName))
+ if(rules.containsKey(rName)) {
return rules.get(rName);
- else {
+ } else {
Rule ret = new Rule(rName);
rules.put(rName, ret);
@@ -66,8 +72,20 @@ public class RGrammarBuilder {
public RGrammar toRGrammar() {
RGrammar grammar = new RGrammar(rules);
+ if(initialRule != null) {
+ if(!rules.containsKey(initialRule)) {
+ throw new GrammarException(String.format("Rule '%s' doesn't exist\n", initialRule));
+ }
+ }
+
grammar.setInitialRule(initialRule);
+ for(String export : exportedRules) {
+ if(!rules.containsKey(export)) {
+ throw new GrammarException(String.format("Rule '%s' doesn't exist\n", export));
+ }
+ }
+
grammar.setExportedRules(exportedRules);
return grammar;
@@ -124,37 +142,48 @@ public class RGrammarBuilder {
* If the rule name is either invalid or not defined by this
* grammar, or if the suffix is invalid.
*/
- public void suffixWith(String ruleName, String suffix) {
+ public void suffixWith(String ruleName, IList<CaseElement> suffixes) {
if (ruleName == null) {
throw new NullPointerException("Rule name must not be null");
} else if (ruleName.equals("")) {
throw new IllegalArgumentException("The empty string is not a valid rule name");
} else if(!rules.containsKey(ruleName)) {
- String msg = String.format("Rule '%s' is not a valid rule name.");
+ String msg = String.format("Rule '%s' is not a valid rule name");
throw new IllegalArgumentException(msg);
}
- CaseElement element = CaseElement.createElement(suffix);
+ Set<CaseElement> elements = new HashSet<>(suffixes.getSize());
+ for(CaseElement suffix : suffixes) {
+ elements.add(suffix);
+ }
+
+ List<List<CaseElement>> suffixLists = powerList(elements);
+
+ FunctionalList<IPair<Integer, RuleCase>> newCases = new FunctionalList<>();
- FunctionalList<RuleCase> newCases = new FunctionalList<>();
+ IList<IPair<Integer, RuleCase>> caseList = rules.get(ruleName).getCases();
+ for (IPair<Integer, RuleCase> ruleCase : caseList) {
+ RuleCase cas = ruleCase.getRight();
- IList<RuleCase> caseList = rules.get(ruleName).getCases();
- for (RuleCase ruleCase : caseList) {
- FunctionalList<CaseElement> newCase = new FunctionalList<>();
+ for(List<CaseElement> suffixList : suffixLists) {
+ FunctionalList<CaseElement> newCase = new FunctionalList<>();
- for(CaseElement elm : ruleCase.getElements()) {
- newCase.add(elm);
- }
+ for(CaseElement elm : cas.elementList) {
+ newCase.add(elm);
+ }
- newCase.add(element);
+ for(CaseElement element : suffixList) {
+ newCase.add(element);
+ }
- newCases.add(new RuleCase(NORMAL, newCase));
+ newCases.add(new Pair<>(ruleCase.getLeft(), cas.withElements(newCase)));
+ }
}
- for (RuleCase newCase : newCases) {
- caseList.add(newCase);
+ for (IPair<Integer, RuleCase> newCase : newCases) {
+ rules.get(ruleName).addCase(newCase.getRight(), newCase.getLeft());
}
}
@@ -171,37 +200,48 @@ public class RGrammarBuilder {
* If the rule name is either invalid or not defined by this
* grammar, or if the prefix is invalid.
*/
- public void prefixWith(String ruleName, String prefix) {
+ public void prefixWith(String ruleName, IList<CaseElement> prefixes) {
if (ruleName == null) {
throw new NullPointerException("Rule name must not be null");
} else if (ruleName.equals("")) {
throw new IllegalArgumentException("The empty string is not a valid rule name");
} else if(!rules.containsKey(ruleName)) {
- String msg = String.format("Rule '%s' is not a valid rule name.");
+ String msg = String.format("Rule '%s' is not a valid rule name");
throw new IllegalArgumentException(msg);
}
- CaseElement element = CaseElement.createElement(prefix);
+ Set<CaseElement> elements = new HashSet<>(prefixes.getSize());
+ for(CaseElement prefix : prefixes) {
+ elements.add(prefix);
+ }
+
+ List<List<CaseElement>> prefixLists = powerList(elements);
- FunctionalList<RuleCase> newCases = new FunctionalList<>();
+ FunctionalList<IPair<Integer, RuleCase>> newCases = new FunctionalList<>();
- IList<RuleCase> caseList = rules.get(ruleName).getCases();
- for (RuleCase ruleCase : caseList) {
- FunctionalList<CaseElement> newCase = new FunctionalList<>();
+ IList<IPair<Integer, RuleCase>> caseList = rules.get(ruleName).getCases();
+ for (IPair<Integer, RuleCase> ruleCase : caseList) {
+ RuleCase cas = ruleCase.getRight();
- newCase.add(element);
+ for(List<CaseElement> prefixList : prefixLists) {
+ FunctionalList<CaseElement> newCase = new FunctionalList<>();
- for(CaseElement elm : ruleCase.getElements()) {
- newCase.add(elm);
- }
+ for(CaseElement elm: prefixList) {
+ newCase.add(elm);
+ }
- newCases.add(new RuleCase(NORMAL, newCase));
+ for(CaseElement elm :cas.elementList) {
+ newCase.add(elm);
+ }
+
+ newCases.add(new Pair<>(ruleCase.getLeft(), cas.withElements(newCase)));
+ }
}
- for (RuleCase newCase : newCases) {
- caseList.add(newCase);
+ for (IPair<Integer, RuleCase> newCase : newCases) {
+ rules.get(ruleName).addCase(newCase.getRight(), newCase.getLeft());
}
}
@@ -210,19 +250,85 @@ public class RGrammarBuilder {
throw new NullPointerException("ruleName must not be null");
} else if (ruleName.equals("")) {
throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if (!rules.containsKey(ruleName)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName));
}
- IList<RuleCase> caseList = rules.get(ruleName).getCases();
+ IList<IPair<Integer, RuleCase>> caseList = rules.get(ruleName).getCases();
- IList<RuleCase> newCaseList = new FunctionalList<>();
+ IList<IPair<Integer, RuleCase>> newCaseList = new FunctionalList<>();
- for(RuleCase cse : caseList) {
- newCaseList.add(new RuleCase(SPACEFLATTEN, cse.getElements()));
+ for(IPair<Integer, RuleCase> cse : caseList) {
+ newCaseList.add(new Pair<>(cse.getLeft(), new FlatRuleCase(cse.getRight().elementList)));
}
+ System.err.printf("\t\tTRACE: Despacing %d cases of rule %s\n", caseList.getSize(), ruleName);
+
rules.get(ruleName).replaceCases(newCaseList);
}
+ public void setWeight(String ruleName) {
+ if (ruleName == null) {
+ throw new NullPointerException("ruleName must not be null");
+ } else if (ruleName.equals("")) {
+ throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if (!rules.containsKey(ruleName)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName));
+ }
+
+ rules.get(ruleName).prob = Rule.ProbType.NORMAL;
+ }
+
+ public void setRuleRecur(String ruleName, int recurLimit) {
+ if (ruleName == null) {
+ throw new NullPointerException("ruleName must not be null");
+ } else if (ruleName.equals("")) {
+ throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if (!rules.containsKey(ruleName)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName));
+ }
+
+ rules.get(ruleName).recurLimit = recurLimit;
+ }
+
+ public void setDescent(String ruleName, int descentFactor) {
+ if (ruleName == null) {
+ throw new NullPointerException("ruleName must not be null");
+ } else if (ruleName.equals("")) {
+ throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if (!rules.containsKey(ruleName)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName));
+ }
+
+ Rule rl = rules.get(ruleName);
+
+ rl.prob = Rule.ProbType.DESCENDING;
+ rl.descentFactor = descentFactor;
+ }
+
+ public void setBinomial(String ruleName, int target, int bound, int trials) {
+ if (ruleName == null) {
+ throw new NullPointerException("ruleName must not be null");
+ } else if (ruleName.equals("")) {
+ throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if (!rules.containsKey(ruleName)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName));
+ }
+
+ Rule rl = rules.get(ruleName);
+
+ rl.prob = Rule.ProbType.BINOMIAL;
+
+ rl.target = target;
+ rl.bound = bound;
+ rl.trials = trials;
+ }
+ /*
+ * @TODO
+ *
+ * Actually get this working
+ */
+ /*
public void regexizeRule(String rule, String pattern) {
if (rule == null) {
throw new NullPointerException("rule must not be null");
@@ -230,6 +336,8 @@ public class RGrammarBuilder {
throw new NullPointerException("pattern must not be null");
} else if (rule.equals("")) {
throw new IllegalArgumentException("The empty string is not a valid rule name");
+ } else if(!rules.containsKey(rule)) {
+ throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", rule));
}
IList<RuleCase> caseList = rules.get(rule).getCases();
@@ -241,6 +349,52 @@ public class RGrammarBuilder {
}
rules.get(rule).replaceCases(newCaseList);
+ }*/
+
+ private static <T> List<List<T>> powerList(Set<T> elements) {
+ /*
+ * Fast-case the most common usage
+ */
+ if(elements.size() == 1) {
+ List<List<T>> ret = new LinkedList<>();
+
+ List<T> curr = new ArrayList<>(elements.size());
+ for(T elem : elements) {
+ curr.add(elem);
+ }
+
+ ret.add(curr);
+
+ return ret;
+ }
+
+ Set<Set<T>> powerSet = SetUtils.powerSet(elements);
+
+ List<List<T>> list = new LinkedList<>();
+
+ for(Set<T> set : powerSet) {
+ /*
+ * Skip empty sets
+ */
+ if(set.size() == 0) continue;
+
+ List<T> stor = new ArrayList<>(set.size());
+
+ for(T elm : set) {
+ stor.add(elm);
+ }
+
+ for(List<T> permute : ListUtils.permuteList(stor)) {
+ System.err.printf("\t\tTRACE: generated permute ");
+ for(T elm : permute) {
+ System.err.printf("%s ", elm);
+ }
+ System.err.println();
+
+ list.add(permute);
+ }
+ }
+ return list;
}
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammarFormatter.java b/src/main/java/bjc/rgens/parser/RGrammarFormatter.java
index a2454dc..c571cb7 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammarFormatter.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarFormatter.java
@@ -1,6 +1,8 @@
package bjc.rgens.parser;
import bjc.rgens.parser.elements.CaseElement;
+
+import bjc.utils.data.IPair;
import bjc.utils.funcdata.IList;
import java.util.HashSet;
@@ -52,7 +54,7 @@ public class RGrammarFormatter {
/* Format a rule. */
private static void processRule(Rule rule, StringBuilder sb) {
- IList<RuleCase> cases = rule.getCases();
+ IList<IPair<Integer, RuleCase>> cases = rule.getCases();
StringBuilder ruleBuilder = new StringBuilder();
@@ -61,20 +63,21 @@ public class RGrammarFormatter {
int markerPos = ruleBuilder.length();
- processCase(cases.first(), ruleBuilder);
+ processCase(cases.first().getRight(), ruleBuilder);
sb.append(ruleBuilder.toString().trim());
ruleBuilder = new StringBuilder();
- for (RuleCase cse : cases.tail()) {
+ for (IPair<Integer, RuleCase> cse : cases.tail()) {
sb.append("\n\t");
for (int i = 8; i < markerPos; i++) {
ruleBuilder.append(" ");
}
- processCase(cse, ruleBuilder);
+ /* @TODO do this right, once we pick the syntax */
+ processCase(cse.getRight(), ruleBuilder);
sb.append(ruleBuilder.toString());
@@ -86,7 +89,7 @@ public class RGrammarFormatter {
/* Format a case. */
private static void processCase(RuleCase cse, StringBuilder sb) {
/* Process each element, adding a space. */
- for (CaseElement element : cse.getElements()) {
+ for (CaseElement element : cse.elementList) {
sb.append(element.toString());
sb.append(" ");
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammarParser.java b/src/main/java/bjc/rgens/parser/RGrammarParser.java
index 3a357b1..a1fc0e9 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammarParser.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarParser.java
@@ -1,8 +1,13 @@
package bjc.rgens.parser;
-import bjc.rgens.parser.elements.CaseElement;
+import bjc.rgens.parser.elements.*;
+
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
+import bjc.utils.funcutils.ListUtils;
+import bjc.utils.funcutils.SetUtils;
import bjc.utils.funcutils.TriConsumer;
import bjc.utils.ioutils.blocks.Block;
import bjc.utils.ioutils.blocks.BlockReader;
@@ -10,8 +15,13 @@ import bjc.utils.ioutils.blocks.SimpleBlockReader;
import java.io.Reader;
import java.io.StringReader;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.LinkedList;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
/**
* Reads {@link RGrammar} from a input stream.
@@ -23,6 +33,7 @@ public class RGrammarParser {
* Whether we are in debug mode or not.
*/
public static final boolean DEBUG = false;
+ public static final boolean LINES = true;
/*
* Templates for level-dependent delimiters.
@@ -73,6 +84,63 @@ public class RGrammarParser {
}
});
+ pragmas.put("recur-limit", (body, build, level) -> {
+ String[] parts = body.split(" ");
+
+ if(parts.length != 2) {
+ throw new GrammarException("Recur-limit pragma takes two arguments: the name of the rule to set the limit for, and the new value of the limit");
+ }
+
+ if(!parts[1].matches("\\A\\d+\\Z")) {
+ throw new GrammarException("Limit value must be an integer");
+ }
+
+ build.setRuleRecur(parts[0], Integer.parseInt(parts[1]));
+ });
+
+ pragmas.put("enable-weight", (body, build, level) -> {
+ String[] parts = body.split(" ");
+
+ if(parts.length != 2) {
+ throw new GrammarException("Enable-weight pragma takes one arguments: the name of the rule to set the weight factor for");
+ }
+
+ build.setWeight(parts[0]);
+ });
+ pragmas.put("enable-descent", (body, build, level) -> {
+ String[] parts = body.split(" ");
+
+ if(parts.length != 2) {
+ throw new GrammarException("Enable-descent pragma takes two arguments: the name of the rule to set the descent factor for, and the new value of the factor");
+ }
+
+ if(!parts[1].matches("\\A\\d+\\Z")) {
+ throw new GrammarException("Factor value must be an integer");
+ }
+
+ build.setDescent(parts[0], Integer.parseInt(parts[1]));
+ });
+
+ pragmas.put("enable-binomial", (body, build, level) -> {
+ String[] parts = body.split(" ");
+
+ if(parts.length != 4) {
+ throw new GrammarException("Enable-descent pragma takes four arguments: the name of the rule to set the binomial factors for, and the three binomial parameters (target, bound trials)");
+ }
+
+ if(!parts[1].matches("\\A\\d+\\Z")) {
+ throw new GrammarException("Target value must be an integer");
+ }
+ if(!parts[2].matches("\\A\\d+\\Z")) {
+ throw new GrammarException("Bound value must be an integer");
+ }
+ if(!parts[3].matches("\\A\\d+\\Z")) {
+ throw new GrammarException("Trials value must be an integer");
+ }
+
+ build.setBinomial(parts[0], Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]));
+ });
+
pragmas.put("regex-rule", (body, build, level) -> {
int nameIndex = body.indexOf(" ");
@@ -83,31 +151,31 @@ public class RGrammarParser {
String name = body.substring(0, nameIndex).trim();
String patt = body.substring(nameIndex + 1).trim();
- build.regexizeRule(name, patt);
+ //build.regexizeRule(name, patt);
});
pragmas.put("suffix-with", (body, build, level) -> {
- String[] parts = body.trim().split(" ");
+ int idx = body.indexOf(" ");
- if (parts.length != 2) {
- String msg = "Suffix-with pragma takes two arguments, the name of the rule to suffix, then what to suffix it with";
+ if (idx == -1) {
+ String msg = "Suffix-with pragma takes at least two arguments, the name of the rule to suffix, then what to suffix it with\n\tThis can be more than one token, to get them suffixed as a group";
throw new GrammarException(msg);
}
- build.suffixWith(parts[0], parts[1]);
+ build.suffixWith(body.substring(0, idx), parseElementString(body.substring(idx + 1)).getLeft());
});
pragmas.put("prefix-with", (body, build, level) -> {
- String[] parts = body.trim().split(" ");
+ int idx = body.indexOf(" ");
- if (parts.length != 2) {
- String msg = "Prefix-with pragma takes two arguments, the name of the rule to prefix, then what to prefix it with";
+ if (idx == -1) {
+ String msg = "Prefix-with pragma takes at least two arguments, the name of the rule to prefix, then what to prefix it with\n\tThis can be more than one token, to get them prefixed as a group";
throw new GrammarException(msg);
}
- build.prefixWith(parts[0], parts[1]);
+ build.prefixWith(body.substring(0, idx), parseElementString(body.substring(idx + 1)).getLeft());
});
}
@@ -134,12 +202,15 @@ public class RGrammarParser {
try {
RGrammarBuilder build = new RGrammarBuilder();
- reader.forEachBlock((block) -> {
+ for(Block block : reader) {
if(DEBUG)
System.err.printf("Handling top-level block (%s)\n", block);
- handleBlock(build, block.contents, 0);
- });
+ handleBlock(build, block.contents, 0, block.startLine);
+ }
+
+ if(LINES)
+ System.err.printf("%d ", reader.getBlock().endLine);
return build.toRGrammar();
} catch (GrammarException gex) {
@@ -155,7 +226,7 @@ public class RGrammarParser {
/* Handles an arbitrary block. */
private static void handleBlock(RGrammarBuilder build, String block,
- int level) throws GrammarException {
+ int level, int lineOffset) throws GrammarException {
/* Discard empty blocks. */
if (block.equals("") || block.matches("\\R"))
return;
@@ -170,18 +241,19 @@ public class RGrammarParser {
String blockType = block.substring(0, typeSep).trim();
if (blockType.equalsIgnoreCase("pragma")) {
- handlePragmaBlock(block, build, level);
+ handlePragmaBlock(block, build, level, lineOffset);
} else if (blockType.startsWith("[")) {
- handleRuleBlock(block, build, level);
+ handleRuleBlock(block, build, level, lineOffset);
} else if (blockType.equalsIgnoreCase("where")) {
- handleWhereBlock(block, build, level);
- } else if (blockType.equalsIgnoreCase("#")) {
+ handleWhereBlock(block, build, level, lineOffset);
+ } else if (blockType.startsWith("#")) {
if(DEBUG)
System.err.printf("Handled comment block (%s)\n", block);
/*
* Comment block.
*
* @TODO 10/11/17 Ben Culkin :GrammarComment
+ *
* Attach these to the grammar somehow so that they
* can be re-output during formatting.
*/
@@ -194,11 +266,13 @@ public class RGrammarParser {
/* Handle reading a block of pragmas. */
private static void handlePragmaBlock(String block, RGrammarBuilder build,
- int level) throws GrammarException {
+ int level, int lineOffset) throws GrammarException {
String dlm = String.format(TMPL_PRAGMA_BLOCK_DELIM, level);
try (BlockReader pragmaReader = new SimpleBlockReader(dlm, new StringReader(block))) {
try {
- pragmaReader.forEachBlock((pragma) -> {
+ for(Block pragma : pragmaReader) {
+ pragma.lineOffset = lineOffset;
+
if(DEBUG)
System.err.printf("Handled pragma block (%s)\n", pragma);
@@ -221,8 +295,8 @@ public class RGrammarParser {
throw new GrammarException(msg);
}
- handlePragma(pragmaBody, build, level);
- });
+ handlePragma(pragmaBody, build, level, pragma.startLine + lineOffset);
+ }
} catch (GrammarException gex) {
Block pragma = pragmaReader.getBlock();
String msg = String.format("Error in pragma: (%s)", pragma);
@@ -236,7 +310,7 @@ public class RGrammarParser {
/* Handle an individual pragma in a block. */
private static void handlePragma(String pragma, RGrammarBuilder build,
- int level) throws GrammarException {
+ int level, int lineOffset) throws GrammarException {
int bodySep = pragma.indexOf(' ');
if (bodySep == -1)
@@ -265,7 +339,7 @@ public class RGrammarParser {
/* Handle a block of a rule declaration and one or more cases. */
private static void handleRuleBlock(String ruleBlock, RGrammarBuilder build,
- int level) throws GrammarException {
+ int level, int lineOffset) throws GrammarException {
String dlm = String.format(TMPL_RULEDECL_BLOCK_DELIM, level);
try (BlockReader ruleReader = new SimpleBlockReader(dlm, new StringReader(ruleBlock))) {
try {
@@ -273,19 +347,20 @@ public class RGrammarParser {
/* Rule with a declaration followed by multiple cases. */
ruleReader.nextBlock();
Block declBlock = ruleReader.getBlock();
+ declBlock.lineOffset = lineOffset;
String declContents = declBlock.contents;
- Rule rl = handleRuleDecl(build, declContents);
+ Rule rl = handleRuleDecl(build, declContents, lineOffset + declBlock.startLine);
- ruleReader.forEachBlock((block) -> {
+ for(Block block : ruleReader) {
/* Ignore comment lines. */
if(block.contents.trim().startsWith("#")) return;
- handleRuleCase(block.contents, build, rl);
- });
+ handleRuleCase(block.contents, build, rl, block.startLine + lineOffset);
+ }
} else {
/* Rule with a declaration followed by a single case. */
- handleRuleDecl(build, ruleBlock);
+ handleRuleDecl(build, ruleBlock, lineOffset);
}
} catch (GrammarException gex) {
String msg = String.format("Error in rule case (%s)", ruleReader.getBlock());
@@ -298,7 +373,7 @@ public class RGrammarParser {
}
/* Handle a rule declaration and its initial case. */
- private static Rule handleRuleDecl(RGrammarBuilder build, String declContents) {
+ private static Rule handleRuleDecl(RGrammarBuilder build, String declContents, int lineOffset) {
int declSep = declContents.indexOf("\u2192");
if (declSep == -1) {
@@ -312,7 +387,7 @@ public class RGrammarParser {
declSep = declContents.indexOf(' ');
if (declSep == -1) {
- String msg = "A rule must be given at least one case in its declaration, and seperated from that case by \u2192";
+ String msg = "A rule must be given at least one case in its declaration, and seperated from that case by \u2192 or ' '";
throw new GrammarException(msg);
}
@@ -327,32 +402,22 @@ public class RGrammarParser {
Rule rul = build.getOrCreateRule(ruleName);
- handleRuleCase(ruleBody, build, rul);
+ handleRuleCase(ruleBody, build, rul, lineOffset);
return rul;
}
/* Handle a single case of a rule. */
- private static void handleRuleCase(String cse, RGrammarBuilder build, Rule rul) {
- IList<CaseElement> caseParts = new FunctionalList<>();
+ private static void handleRuleCase(String cse, RGrammarBuilder build, Rule rul, int lineOffset) {
+ Pair<IList<CaseElement>, Integer> caseParts = parseElementString(cse);
- for (String csepart : cse.split(" ")) {
- String partToAdd = csepart.trim();
-
- /* Ignore empty parts */
- if (partToAdd.equals(""))
- continue;
-
- caseParts.add(CaseElement.createElement(partToAdd));
- }
-
- rul.addCase(new RuleCase(RuleCase.CaseType.NORMAL, caseParts));
+ rul.addCase(new NormalRuleCase(caseParts.getLeft()), caseParts.getRight());
}
/* Handle a where block (a block with local rules). */
private static void handleWhereBlock(String block, RGrammarBuilder build,
- int level) throws GrammarException {
- int nlIndex = block.indexOf("\\n");
+ int level, int lineOffset) throws GrammarException {
+ int nlIndex = block.indexOf("\\nin");
if (nlIndex == -1) {
throw new GrammarException("Where block must be a context followed by a body");
@@ -363,9 +428,10 @@ public class RGrammarParser {
String whereDelim = String.format(TMPL_WHERE_BLOCK_DELIM, level);
try (BlockReader whereReader = new SimpleBlockReader(whereDelim,
- new StringReader(trimBlock))) {
+ new StringReader(trimBlock))) {
try {
Block whereCtx = whereReader.next();
+ whereCtx.lineOffset = lineOffset;
StringReader ctxReader = new StringReader(whereCtx.contents.trim());
String ctxDelim = String.format(TMPL_TOPLEVEL_BLOCK_DELIM, level + 1);
@@ -373,7 +439,9 @@ public class RGrammarParser {
try (BlockReader bodyReader = new SimpleBlockReader(ctxDelim, ctxReader)) {
@SuppressWarnings("unused")
Block whereBody = whereReader.next();
+ whereBody.lineOffset = lineOffset + whereCtx.startLine;
+ System.err.printf("\tUNIMPLEMENTED WHERE:\n%s\n", whereBody.contents);
/**
* @TODO 10/11/17 Ben Culkin :WhereBlocks
* Implement where blocks.
@@ -385,10 +453,105 @@ public class RGrammarParser {
}
} catch (GrammarException gex) {
throw new GrammarException(String.format("Error in where block (%s)",
- whereReader.getBlock()), gex);
+ whereReader.getBlock()), gex);
}
} catch (Exception ex) {
throw new GrammarException("Unknown error in where block", ex);
}
}
+
+ public static Pair<IList<CaseElement>, Integer> parseElementString(String cses) {
+ return parseElementString(cses.split(" "));
+ }
+
+ public static Pair<IList<CaseElement>, Integer> parseElementString(String... cses) {
+ IList<CaseElement> caseParts = new FunctionalList<>();
+
+ int weight = 1;
+
+ int repCount = 1;
+
+ int serialLower = -1;
+ int serialUpper = -1;
+
+ int chance = -1;
+ boolean doSerial = false;
+ boolean doChance = false;
+
+ for (String csepart : cses) {
+ String partToAdd = csepart.trim();
+
+ if (partToAdd.equals("")) {
+ /* Ignore empty parts */
+ continue;
+ } else if(partToAdd.matches("\\<\\^\\d+\\>")) {
+ /* Set case weights */
+ weight = Integer.parseInt(partToAdd.substring(2, partToAdd.length() - 1));
+ } else if(partToAdd.matches("\\<&\\d+\\>")) {
+ repCount = Integer.parseInt(partToAdd.substring(2, partToAdd.length() - 1));
+ } else if(partToAdd.matches("\\<&\\d+\\.\\.\\d+\\>")) {
+ serialLower = Integer.parseInt(partToAdd.substring(2, partToAdd.indexOf(".")));
+ serialUpper = Integer.parseInt(partToAdd.substring(partToAdd.lastIndexOf(".") + 1, partToAdd.length() - 1));
+
+ doSerial = true;
+ } else if(partToAdd.matches("\\<\\?\\d+\\>")) {
+ chance = Integer.parseInt(partToAdd.substring(2, partToAdd.length() - 1));
+
+ doChance = true;
+ } else if (partToAdd.matches("\\<\\<\\>")) {
+ CaseElement elm = caseParts.popLast();
+
+ if(repCount == 0) {
+ /* Skip no-reps */
+ } else {
+ if(doChance) {
+ elm = new ChanceCaseElement(elm, chance);
+
+ doChance = false;
+ }
+
+ if(doSerial) {
+ elm = new SerialCaseElement(elm, serialLower, serialUpper);
+
+ doSerial = false;
+ }
+
+ for(int i = 1; i <= repCount; i++) {
+ caseParts.add(elm);
+ }
+
+ repCount = 1;
+ }
+ } else if(partToAdd.matches("\\<[^\\>]+\\>")) {
+ throw new GrammarException("Unknown parser meta-rule " + partToAdd);
+ } else {
+ CaseElement elm = CaseElement.createElement(partToAdd);
+
+ if(repCount == 0) {
+ /* Skip no-reps */
+ } else {
+ if(doChance) {
+ elm = new ChanceCaseElement(elm, chance);
+
+ doChance = false;
+ }
+
+ if(doSerial) {
+ elm = new SerialCaseElement(elm, serialLower, serialUpper);
+
+ doSerial = false;
+ }
+
+ for(int i = 1; i <= repCount; i++) {
+ caseParts.add(elm);
+ }
+
+ }
+
+ repCount = 1;
+ }
+ }
+
+ return new Pair<>(caseParts, weight);
+ }
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammarSet.java b/src/main/java/bjc/rgens/parser/RGrammarSet.java
index 975510a..b110d21 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammarSet.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarSet.java
@@ -1,13 +1,8 @@
package bjc.rgens.parser;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-import java.util.Scanner;
+import java.util.TreeMap;
import java.util.Set;
/**
@@ -16,26 +11,33 @@ import java.util.Set;
* @author EVE
*/
public class RGrammarSet {
+ public String name;
+
+ public ConfigSet belongsTo;
+
+ public RGrammar exportGrammar;
+
/* Contains all the grammars in this set. */
private Map<String, RGrammar> grammars;
/* Contains all the exported rules from grammars. */
- private Map<String, RGrammar> exportedRules;
-
- /* Contains which export came from which grammar. */
- private Map<String, String> exportFrom;
+ private Map<String, Rule> exportedRules;
/* Contains which file a grammar was loaded from. */
- private Map<String, String> loadedFrom;
+ public Map<String, String> loadedFrom;
+
+ public static final boolean PERF = true;
+ public static final boolean DEBUG = true;
/** Create a new set of randomized grammars. */
public RGrammarSet() {
grammars = new HashMap<>();
- exportedRules = new HashMap<>();
+ exportedRules = new TreeMap<>();
- exportFrom = new HashMap<>();
loadedFrom = new HashMap<>();
+
+ exportGrammar = new RGrammar(exportedRules);
}
/**
@@ -61,12 +63,17 @@ public class RGrammarSet {
}
grammars.put(grammarName, gram);
+ gram.belongsTo = this;
/* Process exports from the grammar. */
for (Rule export : gram.getExportedRules()) {
- exportedRules.put(export.name, gram);
+ if(exportedRules.containsKey(export.name))
+ System.err.printf("WARN: Shadowing rule %s in %s from %s\n", export.name, export.belongsTo.name, grammarName);
- exportFrom.put(export.name, grammarName);
+ exportedRules.put(export.name, export);
+
+ if(DEBUG)
+ System.err.printf("\t\tDEBUG: %s (%d cases) exported from %s\n", export.name, export.getCases().getSize(), grammarName);
}
/* Add exports to grammar. */
@@ -123,7 +130,7 @@ public class RGrammarSet {
throw new IllegalArgumentException(msg);
}
- return exportedRules.get(exportName);
+ return exportedRules.get(exportName).belongsTo;
}
/**
@@ -152,7 +159,12 @@ public class RGrammarSet {
throw new IllegalArgumentException(msg);
}
- return exportFrom.getOrDefault(exportName, "Unknown");
+ String nm = exportedRules.get(exportName).belongsTo.name;
+ if(nm == null) {
+ return "Unknown";
+ }
+
+ return nm;
}
/**
@@ -204,87 +216,4 @@ public class RGrammarSet {
public Set<String> getExportedRules() {
return exportedRules.keySet();
}
-
- /**
- * Load a grammar set from a configuration file.
- *
- * @param cfgFile
- * The configuration file to load from.
- *
- * @return
- * The grammar set created by the configuration file.
- *
- * @throws IOException
- * If something goes wrong during configuration loading.
- */
- public static RGrammarSet fromConfigFile(Path cfgFile) throws IOException {
- /* The grammar set to hand back. */
- RGrammarSet set = new RGrammarSet();
-
- /* Get the directory that contains the config file. */
- Path cfgParent = cfgFile.getParent();
-
- try(Scanner scn = new Scanner(cfgFile)) {
- /* Execute lines from the configuration file. */
- while (scn.hasNextLine()) {
- String ln = scn.nextLine().trim();
-
- /* Ignore blank/comment lines. */
- if (ln.equals("")) continue;
-
- if (ln.startsWith("#")) continue;
-
- /* Handle mixed whitespace. */
- ln = ln.replaceAll("\\s+", " ");
-
- /*
- * Get the place where the name of the grammar
- * ends.
- */
- int nameIdx = ln.indexOf(" ");
- if (nameIdx == -1) {
- throw new GrammarException("Must specify a name for a loaded grammar");
- }
-
- /* Name and path of grammar. */
- String name = ln.substring(0, nameIdx);
- Path path = Paths.get(ln.substring(nameIdx).trim());
-
- /*
- * Convert from configuration relative path to
- * absolute path.
- */
- Path convPath = cfgParent.resolve(path.toString());
-
- //if(Files.isDirectory(convPath)) {
- // /* @TODO implement subset grammars */
- // throw new GrammarException("Sub-grammar sets aren't implemented yet");
- //} else if (convPath.getFileName().endsWith(".gram")) {
- /* Load grammar file. */
- try {
- BufferedReader fis = Files.newBufferedReader(convPath);
- RGrammar gram = RGrammarParser.readGrammar(fis);
- fis.close();
-
- /* Add grammar to the set. */
- set.addGrammar(name, gram);
-
- /*
- * Mark where the grammar came
- * from.
- */
- set.loadedFrom.put(name, path.toString());
- } catch (GrammarException gex) {
- String msg = String.format("Error loading file '%s'", path);
- throw new GrammarException(msg, gex);
- }
- //} else {
- // String msg = String.format("Unrecognized file type '%s'", convPath.getFileName());
- // throw new GrammarException(msg);
- //}
- }
- }
-
- return set;
- }
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammarTest.java b/src/main/java/bjc/rgens/parser/RGrammarTest.java
index 4b1f283..8193fa3 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammarTest.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarTest.java
@@ -1,10 +1,13 @@
package bjc.rgens.parser;
+import bjc.rgens.parser.templates.GrammarTemplate;
+
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Random;
/**
* Test for new grammar syntax.
@@ -19,49 +22,19 @@ public class RGrammarTest {
* Unused CLI args.
*/
public static void main(String[] args) {
- URL rsc = RGrammarTest.class.getResource("/server-config-sample.cfg");
+ URL rsc = RGrammarTest.class.getResource("/server-config-sample.gcfg");
try {
/* Load a grammar set. */
Path cfgPath = Paths.get(rsc.toURI());
- RGrammarSet gramSet = RGrammarSet.fromConfigFile(cfgPath);
+ ConfigSet cfgSet = ConfigLoader.fromConfigFile(cfgPath);
- /* Generate rule suggestions for all the grammars in the set. */
- for (String gramName : gramSet.getGrammars()) {
- gramSet.getGrammar(gramName).generateSuggestions();
+ for(RGrammarSet gramSet : cfgSet.grammars.values()) {
+ testGrammarSet(gramSet);
}
- /* Generate for each exported rule. */
- for (String exportName : gramSet.getExportedRules()) {
- /* Where we loaded the rule from. */
- String loadSrc = gramSet.loadedFrom(gramSet.exportedFrom(exportName));
-
- System.out.println();
- System.out.printf("Generating for exported rule '%s' from file '%s'\n", exportName, loadSrc);
-
- RGrammar grammar = gramSet.getExportSource(exportName);
- for (int i = 0; i < 100; i++) {
- try {
- String res = grammar.generate(exportName);
- if(exportName.contains("+")) res = res.replaceAll("\\s+", "");
-
- if(res.length() > 120) {
- System.out.printf("\t\n\tContents: %s\n\t\n", res);
- } else {
- System.out.printf("\tContents: %s\n", res);
- }
- } catch (GrammarException gex) {
- /* Print out errors with generation. */
- String fmt = "Error in exported rule '%s' (loaded from '%s')\n";
-
- System.out.printf(fmt, exportName, loadSrc);
- System.out.println();
- gex.printStackTrace();
-
- System.out.println();
- System.out.println();
- }
- }
+ for(GrammarTemplate template : cfgSet.templates.values()) {
+ testTemplate(template, cfgSet.grammars.get("default"));
}
} catch (IOException ioex) {
ioex.printStackTrace();
@@ -69,4 +42,83 @@ public class RGrammarTest {
urisex.printStackTrace();
}
}
+
+ private static void testTemplate(GrammarTemplate template, RGrammarSet set) {
+ System.out.printf("Generating for template %s\n", template);
+
+ Random rnd = new Random();
+
+ for(int i = 0; i < 10; i++) {
+ GenerationState state = GenerationState.fromGrammar(rnd, set.exportGrammar);
+
+ template.generate(state);
+
+ String res = state.contents.toString();
+
+ if(res.length() > 120) {
+ System.out.printf("\t\n\tContents: %s\n\t\n", res);
+ } else {
+ System.out.printf("\tContents: %s\n", res);
+ }
+ }
+ }
+
+ private static void testGrammarSet(RGrammarSet gramSet) {
+ /* Generate rule suggestions for all the grammars in the set. */
+ for (String gramName : gramSet.getGrammars()) {
+ long startSuggTime = System.nanoTime();
+
+ gramSet.getGrammar(gramName).generateSuggestions();
+
+ long endSuggTime = System.nanoTime();
+
+ long suggDur = endSuggTime - startSuggTime;
+
+ System.err.printf("PERF: Generated rule suggestions for %s in %d ns (%f s)\n", gramName, suggDur, suggDur / 1000000000.0);
+ }
+
+ System.err.printf("\n\n");
+
+ /* Generate for each exported rule. */
+ for (String exportName : gramSet.getExportedRules()) {
+ /* Where we loaded the rule from. */
+ String loadSrc = gramSet.loadedFrom(gramSet.exportedFrom(exportName));
+
+ System.out.println();
+ System.out.printf("Generating for exported rule '%s' from file '%s'\n", exportName, loadSrc);
+
+ RGrammar grammar = gramSet.getExportSource(exportName);
+ long startGenTime = System.nanoTime();
+ for (int i = 0; i < 100; i++) {
+ try {
+ String res = grammar.generate(exportName);
+ if(exportName.contains("+")) res = res.replaceAll("\\s+", "");
+
+ if(res.length() > 120) {
+ System.out.printf("\t\n\tContents: %s\n\t\n", res);
+ } else {
+ System.out.printf("\tContents: %s\n", res);
+ }
+ } catch (GrammarException gex) {
+ /* Print out errors with generation. */
+ String fmt = "ERROR: Exported rule %s from %s failed (loaded from '%s')\n";
+
+ System.out.printf(fmt, exportName, grammar.name, loadSrc);
+ System.out.println();
+ System.out.println();
+
+ System.err.printf(fmt, exportName, grammar.name, loadSrc);
+ gex.printStackTrace();
+
+ System.err.println();
+ System.err.println();
+ }
+ }
+ long endGenTime = System.nanoTime();
+
+ long genDur = endGenTime - startGenTime;
+
+ System.err.printf("PERF: Generated %s 100 times in %d ns (%f s)\n\n\n", exportName, genDur, genDur / 1000000000.0);
+ }
+ }
}
diff --git a/src/main/java/bjc/rgens/parser/RGrammars.java b/src/main/java/bjc/rgens/parser/RGrammars.java
index f74a756..cc31bad 100644..100755
--- a/src/main/java/bjc/rgens/parser/RGrammars.java
+++ b/src/main/java/bjc/rgens/parser/RGrammars.java
@@ -16,20 +16,21 @@ import java.util.Map;
* @author Ben Culkin
*/
public class RGrammars {
- private static RGrammarSet gramSet;
+ private static ConfigSet cfgSet;
private static void loadSet() {
try {
- URI rsc = RGrammarTest.class.getResource("/server-config-sample.cfg").toURI();
+ URI rsc = RGrammarTest.class.getResource("/server-config-sample.gcfg").toURI();
Map<String, String> env = new HashMap<>();
env.put("create", "true");
+ /* Ensure we can get at the file we need */
@SuppressWarnings("unused")
FileSystem zipfs = FileSystems.newFileSystem(rsc, env);
Path cfgPath = Paths.get(rsc);
- gramSet = RGrammarSet.fromConfigFile(cfgPath);
+ cfgSet = ConfigLoader.fromConfigFile(cfgPath);
} catch (IOException | URISyntaxException ex) {
RuntimeException rtex = new RuntimeException("Could not load grammars");
@@ -49,19 +50,23 @@ public class RGrammars {
* If something went wrong.
*/
public static String generateExport(String exportName) throws GrammarException {
- if (gramSet == null)
+ if (cfgSet == null)
loadSet();
- if (!gramSet.getExportedRules().contains(exportName)) {
- throw new GrammarException(String.format("No exported rule named %s", exportName));
- }
+ for(RGrammarSet gramSet : cfgSet.grammars.values()) {
+ if (!gramSet.getExportedRules().contains(exportName)) {
+ continue;
+ }
+
+ RGrammar gram = gramSet.getExportSource(exportName);
- RGrammar gram = gramSet.getExportSource(exportName);
+ String res = gram.generate(exportName);
+ if (exportName.contains("+"))
+ res = res.replaceAll("\\s+", "");
- String res = gram.generate(exportName);
- if (exportName.contains("+"))
- res = res.replaceAll("\\s+", "");
+ return res;
+ }
- return res;
+ throw new GrammarException(String.format("No exported rule named %s", exportName));
}
}
diff --git a/src/main/java/bjc/rgens/parser/RecurLimitException.java b/src/main/java/bjc/rgens/parser/RecurLimitException.java
new file mode 100644
index 0000000..faeffb3
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/RecurLimitException.java
@@ -0,0 +1,35 @@
+package bjc.rgens.parser;
+
+/**
+ * The exception thrown when a rule exceeds its recurrence limit
+ *
+ * @author student
+ */
+public class RecurLimitException extends GrammarException {
+ /* Serialization ID. */
+ private static final long serialVersionUID = -7287427479316953668L;
+
+ /**
+ * Create a new grammar exception with the specified message.
+ *
+ * @param msg
+ * The message for this exception.
+ */
+ public RecurLimitException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Create a new grammar exception with the specified message and
+ * cause.
+ *
+ * @param msg
+ * The message for this exception.
+ *
+ * @param cause
+ * The cause of this exception.
+ */
+ public RecurLimitException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/RegexRuleCase.java b/src/main/java/bjc/rgens/parser/RegexRuleCase.java
index 5e03cd6..3c57489 100644..100755
--- a/src/main/java/bjc/rgens/parser/RegexRuleCase.java
+++ b/src/main/java/bjc/rgens/parser/RegexRuleCase.java
@@ -6,27 +6,22 @@ import bjc.utils.funcdata.IList;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+/*
+ * @TODO
+ *
+ * Actually implement this
+ */
public class RegexRuleCase extends RuleCase {
- private Pattern patt;
+ public RegexRuleCase(IList<CaseElement> elements) {
+ super(elements);
- public RegexRuleCase(IList<CaseElement> elements, String pattern) {
- super(RuleCase.CaseType.REGEX);
-
- elementList = elements;
-
- try {
- patt = Pattern.compile(pattern);
- } catch (PatternSyntaxException psex) {
- IllegalArgumentException iaex =
- new IllegalArgumentException("This type requires a valid regular expression parameter");
+ }
- iaex.initCause(psex);
+ public void generate(GenerationState state) {
- throw iaex;
- }
}
- public Pattern getPattern() {
- return patt;
+ public RegexRuleCase withElements(IList<CaseElement> elements) {
+ return new RegexRuleCase(elements);
}
}
diff --git a/src/main/java/bjc/rgens/parser/Rule.java b/src/main/java/bjc/rgens/parser/Rule.java
index 7043e0f..ac67158 100644..100755
--- a/src/main/java/bjc/rgens/parser/Rule.java
+++ b/src/main/java/bjc/rgens/parser/Rule.java
@@ -1,7 +1,9 @@
package bjc.rgens.parser;
+import bjc.utils.data.IPair;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
+import bjc.utils.gen.WeightedRandom;
import java.util.Random;
@@ -11,12 +13,34 @@ import java.util.Random;
* @author EVE
*/
public class Rule {
+ public RGrammar belongsTo;
+
/** The name of this grammar rule. */
- public final String name;
+ public String name;
/* The cases for this rule. */
- private IList<RuleCase> cases;
+ private WeightedRandom<RuleCase> cases;
+
+ public static enum ProbType {
+ NORMAL,
+ DESCENDING,
+ BINOMIAL
+ }
+
+ public ProbType prob;
+
+ public int descentFactor;
+
+ public int target;
+ public int bound;
+ public int trials;
+
+ public int recurLimit = 5;
+ private int currentRecur;
+ private final static Random BASE = new Random();
+
+ private int serial = 1;
/**
* Create a new grammar rule.
*
@@ -35,7 +59,9 @@ public class Rule {
name = ruleName;
- cases = new FunctionalList<>();
+ cases = new WeightedRandom<>();
+
+ prob = ProbType.NORMAL;
}
/**
@@ -45,11 +71,25 @@ public class Rule {
* The case to add.
*/
public void addCase(RuleCase cse) {
+ addCase(cse, 1);
+ }
+
+ /**
+ * Adds a case to the rule.
+ *
+ * @param cse
+ * The case to add.
+ */
+ public void addCase(RuleCase cse, int weight) {
if (cse == null) {
throw new NullPointerException("Case must not be null");
}
- cases.add(cse);
+ cse.belongsTo = this;
+ cse.debugName = String.format("%s-%d", name, serial);
+ serial += 1;
+
+ cases.addProbability(weight, cse);
}
/**
@@ -59,7 +99,7 @@ public class Rule {
* A random case from this rule.
*/
public RuleCase getCase() {
- return cases.randItem();
+ return getCase(BASE);
}
/**
@@ -72,7 +112,16 @@ public class Rule {
* A random case from this rule.
*/
public RuleCase getCase(Random rnd) {
- return cases.randItem(rnd::nextInt);
+ switch(prob) {
+ case DESCENDING:
+ return cases.getDescent(descentFactor, rnd);
+ case BINOMIAL:
+ return cases.getBinomial(target, bound, trials, rnd);
+ case NORMAL:
+ return cases.generateValue(rnd);
+ default:
+ return cases.generateValue(rnd);
+ }
}
/**
@@ -81,8 +130,8 @@ public class Rule {
* @return
* All the cases in this rule.
*/
- public IList<RuleCase> getCases() {
- return cases;
+ public IList<IPair<Integer, RuleCase>> getCases() {
+ return cases.getValues();
}
/**
@@ -91,8 +140,17 @@ public class Rule {
* @param cases
* The new list of cases.
*/
- public void replaceCases(IList<RuleCase> cases) {
- this.cases = cases;
+ public void replaceCases(IList<IPair<Integer, RuleCase>> cases) {
+ this.cases = new WeightedRandom<>();
+
+ for(IPair<Integer, RuleCase> cse : cases) {
+ RuleCase cs = cse.getRight();
+ cs.belongsTo = this;
+ cs.debugName = String.format("%s-%d", name, serial);
+ serial += 1;
+
+ this.cases.addProbability(cse.getLeft(), cs);
+ }
}
@Override
@@ -129,6 +187,58 @@ public class Rule {
@Override
public String toString() {
- return String.format("Rule [ruleName='%s', ruleCases=%s]", name, cases);
+ return String.format("Rule '%s' with %d cases", name, cases.getValues().getSize());
+ }
+
+ public boolean doRecur() {
+ if(currentRecur > recurLimit) return false;
+
+ currentRecur += 1;
+
+ return true;
+ }
+
+ public void endRecur() {
+ if(currentRecur > 0) currentRecur -= 1;
+ }
+
+ public Rule exhaust() {
+ Rule rl = new Rule(name);
+
+ rl.belongsTo = belongsTo;
+
+ rl.cases = cases.exhaustible();
+
+ rl.prob = prob;
+
+ rl.descentFactor = descentFactor;
+
+ rl.target = target;
+ rl.bound = bound;
+ rl.trials = trials;
+
+ rl.recurLimit = recurLimit;
+ /* @NOTE Is this the right thing to do? */
+ rl.currentRecur = 0;
+
+ return rl;
+ }
+
+ public void generate(GenerationState state) {
+ state.swapGrammar(belongsTo);
+
+ if(doRecur()) {
+ RuleCase cse = getCase(state.rnd);
+
+ System.err.printf("\tFINE: Generating %s (from %s)\n", cse, belongsTo.name);
+
+ belongsTo.generateCase(cse, state);
+
+ endRecur();
+ }
+
+ if(name.contains("+")) {
+ state.contents = new StringBuilder(state.contents.toString().replaceAll("\\s+", ""));
+ }
}
}
diff --git a/src/main/java/bjc/rgens/parser/RuleCase.java b/src/main/java/bjc/rgens/parser/RuleCase.java
index 9c0a856..33aea0c 100644..100755
--- a/src/main/java/bjc/rgens/parser/RuleCase.java
+++ b/src/main/java/bjc/rgens/parser/RuleCase.java
@@ -13,76 +13,42 @@ import bjc.utils.funcdata.IList;
*
* @author EVE
*/
-public class RuleCase {
- /**
- * The possible types of a case.
- *
- * @author EVE
- */
- public static enum CaseType {
- /** A normal case, composed from a list of elements. */
- NORMAL,
- /** A case that doesn't insert spaces. */
- SPACEFLATTEN,
- /** A case that applies a regex after generation. */
- REGEX
- }
+public abstract class RuleCase {
+ public String debugName;
- /** The type of this case. */
- public final CaseType type;
+ public final int serial;
- /**
- * The list of element values for this case.
- *
- * <h2>Used For</h2>
- * <dl>
- * <dt>NORMAL, SPACEFLATTEN</dt>
- * <dd>Used as the list of elementList the rule is composed of.</dd>
- * </dl>
- */
- protected IList<CaseElement> elementList;
+ private static int nextSerial = 0;
- protected RuleCase(CaseType typ) {
- type = typ;
- }
+ public Rule belongsTo;
+
+ public IList<CaseElement> elementList;
/**
* Create a new case of the specified type that takes a element list
* parameter.
*
- * @param typ
- * The type of case to create.
- *
* @param elements
* The element list parameter of the case.
*
- * @throws IllegalArgumentException
- * If this type doesn't take a element list parameter.
*/
- public RuleCase(CaseType typ, IList<CaseElement> elements) {
- this(typ);
-
- switch (typ) {
- case NORMAL:
- case SPACEFLATTEN:
- break;
- case REGEX:
- throw new IllegalArgumentException("This type requires an element list and a pattern");
- default:
- throw new IllegalArgumentException("This type doesn't have a element list parameter");
- }
-
+ protected RuleCase(IList<CaseElement> elements) {
elementList = elements;
+
+ serial = nextSerial;
+ nextSerial += 1;
}
- /**
- * Get the element list value of this type.
- *
- * @return
- * The element list value of this case, or null if this type
- * doesn't have one.
- */
- public IList<CaseElement> getElements() {
- return elementList;
+ public abstract void generate(GenerationState state);
+
+ public abstract RuleCase withElements(IList<CaseElement> elements);
+
+ public String toString() {
+ if(debugName != null) {
+ return String.format("Case %s (#%d) of %s", debugName, serial, belongsTo);
+ } else {
+ return String.format("Case #%d of %s", serial, belongsTo, serial, belongsTo);
+ }
}
+
}
diff --git a/src/main/java/bjc/rgens/parser/elements/BlankCaseElement.java b/src/main/java/bjc/rgens/parser/elements/BlankCaseElement.java
index 7229e92..66ff310 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/BlankCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/BlankCaseElement.java
@@ -1,5 +1,7 @@
package bjc.rgens.parser.elements;
+import bjc.rgens.parser.GenerationState;
+
public class BlankCaseElement extends LiteralCaseElement {
public BlankCaseElement() {
super("");
diff --git a/src/main/java/bjc/rgens/parser/elements/CaseElement.java b/src/main/java/bjc/rgens/parser/elements/CaseElement.java
index d74ab52..a44ef6c 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/CaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/CaseElement.java
@@ -1,17 +1,16 @@
package bjc.rgens.parser.elements;
+import bjc.utils.funcutils.StringUtils;
+
+import bjc.rgens.parser.GenerationState;
import bjc.rgens.parser.GrammarException;
-/*
- * @TODO 10/11/17 Ben Culkin :CaseElementSplit Split this into multiple
- * subclasses based off of a value of ElementType.
- */
/**
* A element in a rule case.
*
* @author EVE
*/
-public class CaseElement {
+public abstract class CaseElement {
/**
* The possible types of an element.
*
@@ -19,27 +18,27 @@ public class CaseElement {
*/
public static enum ElementType {
/** An element that represents a literal string. */
- LITERAL,
+ LITERAL(true),
/** An element that represents a rule reference. */
- RULEREF,
+ RULEREF(true),
/** An element that represents a random range. */
- RANGE,
+ RANGE(true),
/** An element that represents a variable that stores a string. */
- VARDEF,
- /**
- * An element that represents a variable that stores the result of generating a
- * rule.
- */
- EXPVARDEF;
- }
+ VARIABLE(false);
- /* Regexps for marking rule types. */
- private static final String SPECIAL_CASELEM = "\\{[^}]+\\}";
- private static final String REFER_CASELEM = "\\[[^\\]]+\\]";
- private static final String RANGE_CASELM = "\\[\\d+\\.\\.\\d+\\]";
+ public final boolean spacing;
+
+ private ElementType(boolean spacing) {
+ this.spacing = spacing;
+ }
+ }
/** The type of this element. */
- public final ElementType type;
+ public boolean spacing;
+
+ protected CaseElement() {
+ this(true);
+ }
/**
* Create a new case element.
@@ -47,17 +46,17 @@ public class CaseElement {
* @param typ
* The type of this element.
*/
- protected CaseElement(ElementType typ) {
- type = typ;
+ protected CaseElement(boolean spacing) {
+ this.spacing = spacing;
}
- @Override
- public String toString() {
- switch (type) {
- default:
- return String.format("Unknown type '%s'", type);
- }
- }
+ /**
+ * Generate this case element.
+ *
+ * @param state
+ * The current state of generation.
+ */
+ public abstract void generate(GenerationState state);
/**
* Create a case element from a string.
@@ -72,52 +71,80 @@ public class CaseElement {
throw new NullPointerException("Case part cannot be null");
}
- if (csepart.matches(SPECIAL_CASELEM)) {
- /* Handle special cases. */
+ if (csepart.matches("\\(\\S+\\)")) {
+ return createElement(csepart.substring(1, csepart.length() - 1));
+ } else if (csepart.matches("\\{\\S+\\}")) {
+ /*
+ * Handle special case elements.
+ *
+ */
String specialBody = csepart.substring(1, csepart.length() - 1);
- System.out.printf("\t\tTRACE: special body is '%s'\n", specialBody);
+ if (specialBody.matches("\\S+:\\S=\\S+")) {
+ String[] parts = StringUtils.levelSplit(specialBody, "=").toArray(new String[0]);
- if (specialBody.matches("\\S+:=\\S+")) {
- /* Handle expanding variable definitions. */
- String[] parts = specialBody.split(":=");
+ if(parts.length != 2) {
+ throw new GrammarException("Colon variables must have a name and a definition");
+ }
+
+ String varName = parts[0];
+
+ char op = varName.charAt(varName.length() - 1);
+
+ System.err.printf("\t\tTRACE: Colon definition w/ op %d", (int)op);
- if (parts.length != 2) {
- String msg = "Expanded variables must be a name and a definition, seperated by :=";
+ // Remove the colon, plus any tacked on operator
+ varName = varName.substring(0, varName.length() - 2);
- throw new GrammarException(msg);
+ return VariableDefCaseElement.parseVariable(varName, parts[1], op, true);
+ } else if (specialBody.matches("\\S+:=\\S+")) {
+ String[] parts = StringUtils.levelSplit(specialBody, "=").toArray(new String[0]);
+
+ if(parts.length != 2) {
+ throw new GrammarException("Colon variables must have a name and a definition");
}
- return new ExpVariableCaseElement(parts[0], parts[1]);
- } else if (specialBody.matches("\\S+=\\S+")) {
- /* Handle regular variable definitions. */
- String[] parts = specialBody.split("=");
+ String varName = parts[0];
- if (parts.length != 2) {
- String msg = "Variables must be a name and a definition, seperated by =";
+ varName = varName.substring(0, varName.length() - 1);
- throw new GrammarException(msg);
+ return VariableDefCaseElement.parseVariable(varName, parts[1], ' ', true);
+ } else if (specialBody.matches("\\S+=\\S+")) {
+ String[] parts = specialBody.split("=");
+ if(parts.length != 2) {
+ throw new GrammarException("Variables must have a name and a definition");
}
- return new LitVariableCaseElement(parts[0], parts[1]);
- } else if (specialBody.matches("{empty}")) {
+ // Non-colon variables can't take an operator
+ return VariableDefCaseElement.parseVariable(parts[0], parts[1], (char)0, false);
+ } else if (specialBody.matches("empty")) {
/* Literal blank, for empty cases. */
return new BlankCaseElement();
} else {
throw new IllegalArgumentException(String.format("Unknown special case part '%s'", specialBody));
}
- } else if (csepart.matches(REFER_CASELEM)) {
- if (csepart.matches(RANGE_CASELM)) {
- /* Handle ranges */
- String rawRange = csepart.substring(1, csepart.length() - 1);
+ } else if (csepart.matches("\\[\\S+\\]")) {
+ String rawCase = csepart.substring(1, csepart.length() - 1);
- int firstNum = Integer.parseInt(rawRange.substring(0, rawRange.indexOf('.')));
- int secondNum = Integer.parseInt(rawRange.substring(rawRange.lastIndexOf('.') + 1));
+ if (rawCase.matches("\\d+\\.{2}\\d+")) {
+ int firstNum = Integer.parseInt(rawCase.substring(0, rawCase.indexOf('.')));
+ int secondNum = Integer.parseInt(rawCase.substring(rawCase.lastIndexOf('.') + 1));
return new RangeCaseElement(firstNum, secondNum);
- }
+ } else if(rawCase.contains("||")) {
+ String[] elms = StringUtils.levelSplit(rawCase, "||").toArray(new String[0]);
- return new RuleCaseElement(csepart);
+ return new InlineRuleCaseElement(elms);
+ } else if(rawCase.contains("|")) {
+ throw new GrammarException("\t\tERROR: Inline rule using | found, they use || now");
+
+ // String[] elms = StringUtils.levelSplit(rawCase, "|").toArray(new String[0]);
+ // return new InlineRuleCaseElement(elms);
+ } else {
+ return new RuleCaseElement(rawCase);
+ }
+ } else if(csepart.startsWith("%") && !csepart.equals("%")) {
+ return new RuleCaseElement(csepart);
} else {
return new LiteralCaseElement(csepart);
}
@@ -127,7 +154,7 @@ public class CaseElement {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + (spacing ? 0 : 2);
return result;
}
@@ -140,8 +167,8 @@ public class CaseElement {
if (getClass() != obj.getClass())
return false;
CaseElement other = (CaseElement) obj;
- if (type != other.type)
+ if (spacing != other.spacing)
return false;
return true;
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/ChanceCaseElement.java b/src/main/java/bjc/rgens/parser/elements/ChanceCaseElement.java
new file mode 100644
index 0000000..483a103
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/ChanceCaseElement.java
@@ -0,0 +1,20 @@
+package bjc.rgens.parser.elements;
+
+import bjc.rgens.parser.GenerationState;
+
+public class ChanceCaseElement extends CaseElement {
+ public final CaseElement elm;
+
+ public int chance;
+
+ public ChanceCaseElement(CaseElement elm, int chance) {
+ super(elm.spacing);
+
+ this.elm = elm;
+ this.chance = chance;
+ }
+
+ public void generate(GenerationState state) {
+ if(state.rnd.nextInt(chance) == 0) elm.generate(state);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/ExpVariableCaseElement.java b/src/main/java/bjc/rgens/parser/elements/ExpVariableCaseElement.java
index 30925e2..e58d073 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/ExpVariableCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/ExpVariableCaseElement.java
@@ -1,7 +1,40 @@
package bjc.rgens.parser.elements;
-public class ExpVariableCaseElement extends VariableCaseElement {
+import bjc.utils.data.IPair;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+import bjc.rgens.parser.RecurLimitException;
+import bjc.rgens.parser.RGrammar;
+import bjc.rgens.parser.Rule;
+import bjc.rgens.parser.RuleCase;
+
+public class ExpVariableCaseElement extends VariableDefCaseElement {
public ExpVariableCaseElement(String name, String def) {
- super(name, def, true);
+ super(name, def);
+ }
+
+ @Override
+ public void generate(GenerationState state) {
+ GenerationState newState = state.newBuf();
+
+ Rule rl = state.findRule(varDef, true);
+
+ if(rl != null) {
+ RGrammar destGrammar = rl.belongsTo;
+ newState.swapGrammar(destGrammar);
+ /*
+ * Don't post-process the string, we should only do that
+ * once.
+ */
+ String res = destGrammar.generate(varDef, state, false);
+
+ newState.contents = new StringBuilder(res);
+ } else {
+ String msg = String.format("No rule '%s' defined", varDef);
+ throw new GrammarException(msg);
+ }
+
+ state.vars.put(varName, newState.contents.toString());
}
}
diff --git a/src/main/java/bjc/rgens/parser/elements/InlineRuleCaseElement.java b/src/main/java/bjc/rgens/parser/elements/InlineRuleCaseElement.java
new file mode 100644
index 0000000..917dd33
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/InlineRuleCaseElement.java
@@ -0,0 +1,41 @@
+package bjc.rgens.parser.elements;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.RGrammarParser;
+
+import bjc.utils.data.IPair;
+import bjc.utils.funcdata.FunctionalList;
+import bjc.utils.funcdata.IList;
+import bjc.utils.funcutils.StringUtils;
+import bjc.utils.gen.WeightedRandom;
+
+public class InlineRuleCaseElement extends CaseElement {
+ public final WeightedRandom<CaseElement> elements;
+
+ public InlineRuleCaseElement(String... parts) {
+ super(true);
+
+ this.elements = new WeightedRandom<>();
+
+ for(String part : parts) {
+ String[] partArr;
+
+ if(StringUtils.levelContains(part, "|")) {
+ partArr = StringUtils.levelSplit(part, "||").toArray(new String[0]);
+ } else {
+ partArr = new String[] {part};
+ }
+
+ IPair<IList<CaseElement>, Integer> par = RGrammarParser.parseElementString(partArr);
+ int prob = par.getRight();
+
+ for(CaseElement elm : par.getLeft()) {
+ elements.addProbability(prob, elm);
+ }
+ }
+ }
+
+ public void generate(GenerationState state) {
+ elements.generateValue(state.rnd).generate(state);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/LitVariableCaseElement.java b/src/main/java/bjc/rgens/parser/elements/LitVariableCaseElement.java
index 11035b1..3c6ba98 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/LitVariableCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/LitVariableCaseElement.java
@@ -1,7 +1,13 @@
package bjc.rgens.parser.elements;
-public class LitVariableCaseElement extends VariableCaseElement {
+import bjc.rgens.parser.GenerationState;
+
+public class LitVariableCaseElement extends VariableDefCaseElement {
public LitVariableCaseElement(String name, String def) {
- super(name, def, false);
+ super(name, def);
+ }
+
+ public void generate(GenerationState state) {
+ state.vars.put(varName, varDef);
}
}
diff --git a/src/main/java/bjc/rgens/parser/elements/LiteralCaseElement.java b/src/main/java/bjc/rgens/parser/elements/LiteralCaseElement.java
index d96a32d..6e0f8fd 100644
--- a/src/main/java/bjc/rgens/parser/elements/LiteralCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/LiteralCaseElement.java
@@ -1,7 +1,17 @@
package bjc.rgens.parser.elements;
-public class LiteralCaseElement extends StringCaseElement {
- public LiteralCaseElement(String vl) {
- super(vl, true);
+import bjc.rgens.parser.GenerationState;
+
+public class LiteralCaseElement extends CaseElement {
+ public String val;
+
+ public LiteralCaseElement(String val) {
+ super(true);
+
+ this.val = val;
+ }
+
+ public void generate(GenerationState state) {
+ state.contents.append(val);
}
}
diff --git a/src/main/java/bjc/rgens/parser/elements/RangeCaseElement.java b/src/main/java/bjc/rgens/parser/elements/RangeCaseElement.java
index d98bc61..e877dd1 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/RangeCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/RangeCaseElement.java
@@ -1,16 +1,25 @@
package bjc.rgens.parser.elements;
+import bjc.rgens.parser.GenerationState;
+
public class RangeCaseElement extends CaseElement {
public final int begin;
public final int end;
public RangeCaseElement(int beg, int en) {
- super(ElementType.RANGE);
+ super(true);
begin = beg;
end = en;
}
+ public void generate(GenerationState state) {
+ int val = state.rnd.nextInt(end - begin);
+ val += begin;
+
+ state.contents.append(val);
+ }
+
@Override
public int hashCode() {
final int prime = 31;
diff --git a/src/main/java/bjc/rgens/parser/elements/RuleCaseElement.java b/src/main/java/bjc/rgens/parser/elements/RuleCaseElement.java
index f4d3512..f13dbdb 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/RuleCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/RuleCaseElement.java
@@ -1,7 +1,103 @@
package bjc.rgens.parser.elements;
-public class RuleCaseElement extends StringCaseElement {
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
+
+import bjc.rgens.parser.*;
+import bjc.rgens.parser.elements.vars.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class RuleCaseElement extends CaseElement {
+ public List<VariableElement> elements;
+
public RuleCaseElement(String vl) {
- super(vl, false);
+ super(true);
+
+ this.elements = VariableElement.parseElementString(vl);
+ }
+
+ public RuleCaseElement(String vl, List<VariableElement> elements) {
+ super(true);
+
+ this.elements = elements;
+ }
+
+ public void generate(GenerationState state) {
+ GenerationState newState = state.newBuf();
+
+ boolean inName = false;
+
+ for(VariableElement elm : elements) {
+ elm.generate(newState);
+
+ if(inName == false) inName = elm.forbidSpaces;
+ }
+
+ String body = newState.contents.toString();
+
+ if(inName) {
+ doGenerate(String.format("[%s]", body), state);
+ } else {
+ state.contents.append(body);
+ }
+ }
+
+ protected void doGenerate(String actName, GenerationState state) {
+ GenerationState newState = state.newBuf();
+
+ Rule rl;
+
+ if (actName.startsWith("[^")) {
+ actName = "[" + actName.substring(2);
+
+ rl = state.findImport(actName);
+ } else {
+ rl = state.findRule(actName, true);
+ }
+
+ if(rl != null) {
+ RGrammar destGrammar = rl.belongsTo;
+ newState.swapGrammar(destGrammar);
+ /*
+ * Don't postprocess the string, we should only do that
+ * once.
+ */
+ String res = destGrammar.generate(actName, newState, false);
+ newState.contents = new StringBuilder(res);
+ } else {
+ /*
+ * @TODO 5/29/18 Ben Culkin :RuleSuggesting
+ *
+ * Re-get this working again.
+ */
+ /*
+ if (ruleSearcher != null) {
+ Set<Match<? extends String>> results = ruleSearcher.search(actName, MAX_DISTANCE);
+
+ String[] resArray = results.stream().map(Match::getMatch).toArray((i) -> new String[i]);
+
+ String msg = String.format("No rule '%s' defined (perhaps you meant %s?)", actName,
+ StringUtils.toEnglishList(resArray, false));
+
+ throw new GrammarException(msg);
+ }
+ */
+
+ String msg = String.format("No rule '%s' defined", actName);
+ throw new GrammarException(msg);
+ }
+
+ String res = newState.contents.toString();
+
+ if (actName.contains("+")) {
+ /* Rule names with pluses in them get space-flattened */
+ state.contents.append(res.replaceAll("\\s+", ""));
+ } else {
+ state.contents.append(res);
+ }
}
}
diff --git a/src/main/java/bjc/rgens/parser/elements/RuleVariableCaseElement.java b/src/main/java/bjc/rgens/parser/elements/RuleVariableCaseElement.java
new file mode 100644
index 0000000..29b6fc9
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/RuleVariableCaseElement.java
@@ -0,0 +1,39 @@
+package bjc.rgens.parser.elements;
+
+import bjc.utils.data.IPair;
+import bjc.utils.data.Pair;
+
+import bjc.rgens.parser.GrammarException;
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.Rule;
+import bjc.rgens.parser.RGrammar;
+
+public class RuleVariableCaseElement extends VariableDefCaseElement {
+ public final boolean exhaust;
+
+ public RuleVariableCaseElement(String varName, String varDef, boolean exhaust) {
+ super(varName, varDef);
+
+ this.exhaust = exhaust;
+ }
+
+ public void generate(GenerationState state) {
+ Rule rl = state.findRule(varDef, true);
+
+ if(rl == null) {
+ throw new GrammarException("Can't create variable referencing non-existent rule " + varDef);
+ }
+
+ if(exhaust) {
+ rl = rl.exhaust();
+ }
+
+ state.rlVars.put(varName, rl);
+
+ if(exhaust) {
+ System.err.printf("\t\tFINE: Defined exhausted rulevar '%s' ('%s')\n", varName, varDef);
+ } else {
+ System.err.printf("\t\tFINE: Defined rulevar '%s' ('%s')\n", varName, varDef);
+ }
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/SerialCaseElement.java b/src/main/java/bjc/rgens/parser/elements/SerialCaseElement.java
new file mode 100644
index 0000000..348cfbb
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/SerialCaseElement.java
@@ -0,0 +1,30 @@
+package bjc.rgens.parser.elements;
+
+import bjc.rgens.parser.GenerationState;
+
+public class SerialCaseElement extends CaseElement {
+ public final CaseElement rep;
+
+ public final int lower;
+ public final int upper;
+
+ public SerialCaseElement(CaseElement rep, int lower, int upper) {
+ super(rep.spacing);
+
+ this.rep = rep;
+
+ this.lower = lower;
+ this.upper = upper;
+ }
+
+ public void generate(GenerationState state) {
+ int num = state.rnd.nextInt(upper - lower) + lower;
+
+ for(int i = 0; i < num; i++) {
+ rep.generate(state);
+
+ if(rep.spacing)
+ state.contents.append(" ");
+ }
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/StringCaseElement.java b/src/main/java/bjc/rgens/parser/elements/StringCaseElement.java
index 0e64fd3..00441c0 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/StringCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/StringCaseElement.java
@@ -1,10 +1,10 @@
package bjc.rgens.parser.elements;
-public class StringCaseElement extends CaseElement {
+public abstract class StringCaseElement extends CaseElement {
public final String val;
- protected StringCaseElement(String vl, boolean isLiteral) {
- super(isLiteral ? ElementType.LITERAL : ElementType.RULEREF);
+ protected StringCaseElement(String vl) {
+ super(true);
val = vl;
}
diff --git a/src/main/java/bjc/rgens/parser/elements/VariableCaseElement.java b/src/main/java/bjc/rgens/parser/elements/VariableDefCaseElement.java
index 920445a..37a12b6 100644..100755
--- a/src/main/java/bjc/rgens/parser/elements/VariableCaseElement.java
+++ b/src/main/java/bjc/rgens/parser/elements/VariableDefCaseElement.java
@@ -1,6 +1,8 @@
package bjc.rgens.parser.elements;
-public class VariableCaseElement extends CaseElement {
+import bjc.rgens.parser.GrammarException;
+
+public abstract class VariableDefCaseElement extends CaseElement {
/**
* The name of the variable this element defines.
*/
@@ -11,8 +13,8 @@ public class VariableCaseElement extends CaseElement {
*/
public final String varDef;
- public VariableCaseElement(String name, String def, boolean isExp) {
- super(isExp ? ElementType.EXPVARDEF : ElementType.VARDEF);
+ public VariableDefCaseElement(String name, String def) {
+ super(false);
varName = name;
varDef = def;
@@ -35,7 +37,7 @@ public class VariableCaseElement extends CaseElement {
return false;
if (getClass() != obj.getClass())
return false;
- VariableCaseElement other = (VariableCaseElement) obj;
+ VariableDefCaseElement other = (VariableDefCaseElement) obj;
if (varDef == null) {
if (other.varDef != null)
return false;
@@ -49,12 +51,16 @@ public class VariableCaseElement extends CaseElement {
return true;
}
- @Override
- public String toString() {
- if (type == ElementType.VARDEF) {
- return String.format("{%s:=%s}", varName, varDef);
+ public static CaseElement parseVariable(String varName, String varDef, char op, boolean colon) {
+ if(varName.startsWith("$")) {
+ // Handle normal/expanding variable definitions
+ if(colon) return new ExpVariableCaseElement(varName.substring(1), varDef);
+
+ return new LitVariableCaseElement(varName.substring(1), varDef);
+ } else if(varName.startsWith("@")) {
+ return new RuleVariableCaseElement(varName.substring(1), varDef, colon);
} else {
- return String.format("{%s=%s}", varName, varDef);
+ throw new GrammarException("Unrecognized declaration sigil " + varName.charAt(0));
}
}
}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/ARefVariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/ARefVariableElement.java
new file mode 100644
index 0000000..a4bb730
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/ARefVariableElement.java
@@ -0,0 +1,31 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+import bjc.rgens.parser.Rule;
+
+public class ARefVariableElement extends VariableElement {
+ public String value;
+
+ public ARefVariableElement(String val) {
+ super(false);
+
+ value = val;
+ }
+
+ public void generate(GenerationState state) {
+ if(!state.rlVars.containsKey(value)) {
+ throw new GrammarException("No rule variable named " + value);
+ }
+
+ Rule rl = state.rlVars.get(value);
+
+ GenerationState newState = state.newBuf();
+
+ rl.generate(newState);
+
+ String res = newState.contents.toString();
+
+ state.contents.append(res);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/LiteralVariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/LiteralVariableElement.java
new file mode 100644
index 0000000..cf33c66
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/LiteralVariableElement.java
@@ -0,0 +1,17 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.rgens.parser.GenerationState;
+
+public class LiteralVariableElement extends VariableElement {
+ public String val;
+
+ public LiteralVariableElement(boolean forbidSpaces, String val) {
+ super(forbidSpaces);
+
+ this.val = val;
+ }
+
+ public void generate(GenerationState state) {
+ state.contents.append(val);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/RRefVariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/RRefVariableElement.java
new file mode 100644
index 0000000..d731d64
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/RRefVariableElement.java
@@ -0,0 +1,31 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+import bjc.rgens.parser.Rule;
+
+public class RRefVariableElement extends VariableElement {
+ public String value;
+
+ public RRefVariableElement(boolean forbidSpaces, String val) {
+ super(forbidSpaces);
+
+ value = val;
+ }
+
+ public void generate(GenerationState state) {
+ Rule rl = state.findRule(value, true);
+
+ GenerationState newState = state.newBuf();
+
+ rl.generate(newState);
+
+ String res = newState.contents.toString();
+
+ if(forbidSpaces && res.contains(" ")) {
+ throw new GrammarException("Spaces not allowed in this context (rule-reference %s)");
+ }
+
+ state.contents.append(res);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/TRefVariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/TRefVariableElement.java
new file mode 100644
index 0000000..a33d78c
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/TRefVariableElement.java
@@ -0,0 +1,42 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+import bjc.rgens.parser.templates.GrammarTemplate;
+
+/*
+ * @TODO
+ *
+ * finish when template vars are implemented.
+ */
+public class TRefVariableElement extends VariableElement {
+ public String value;
+
+ public TRefVariableElement(boolean forbidSpaces, String val) {
+ super(forbidSpaces);
+
+ value = val;
+ }
+
+ public void generate(GenerationState state) {
+ /*
+ if(!state.rlVars.containsKey(val)) {
+ throw new GrammarException("No rule variable named " + val);
+ }
+
+ Rule rl = state.rlVars.get(val);
+
+ GenerationState newState = state.newBuf();
+
+ rl.generate(newState);
+
+ String res = newState.contents.toString();
+
+ if(forbidSpaces && res.contains(" ")) {
+ throw new GrammarException("Spaces not allowed in this context (rule-var %s)");
+ }
+
+ return res;
+ */
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/VRefVariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/VRefVariableElement.java
new file mode 100644
index 0000000..b19f785
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/VRefVariableElement.java
@@ -0,0 +1,27 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+
+public class VRefVariableElement extends VariableElement {
+ public final String nam;
+
+ public VRefVariableElement(boolean forbidSpaces, String nam) {
+ super(forbidSpaces);
+
+ this.nam = nam;
+ }
+
+ public void generate(GenerationState state) {
+ if (!state.vars.containsKey(nam)) {
+ throw new GrammarException(String.format("No variable '%s' defined", nam));
+ }
+
+ String strang = state.vars.get(nam);
+ if(forbidSpaces && strang.contains(" ")) {
+ throw new GrammarException(String.format("Cannot include variable %s w/ spaces in body in rule name", nam));
+ }
+
+ state.contents.append(strang);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/elements/vars/VariableElement.java b/src/main/java/bjc/rgens/parser/elements/vars/VariableElement.java
new file mode 100644
index 0000000..19c1e2c
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/elements/vars/VariableElement.java
@@ -0,0 +1,71 @@
+package bjc.rgens.parser.elements.vars;
+
+import bjc.utils.funcutils.StringUtils;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.GrammarException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class VariableElement {
+ public boolean forbidSpaces;
+
+ protected VariableElement(boolean forbidSpacing) {
+ forbidSpaces = forbidSpacing;
+ }
+
+ public abstract void generate(GenerationState state);
+
+ public static List<VariableElement> parseElementString(String varElm) {
+ boolean forbidSpaces = StringUtils.levelContains(varElm, "-", "+");
+
+ String[] parts;
+
+ if(forbidSpaces) {
+ parts = StringUtils.levelSplit(varElm, true, "-", "+").toArray(new String[0]);
+ } else {
+ parts = new String[] { varElm };
+ }
+
+ return parseElementString(forbidSpaces, parts);
+ }
+
+ public static List<VariableElement> parseElementString(boolean forbidSpaces, String... parts) {
+ List<VariableElement> elms = new ArrayList<>(parts.length);
+
+ VariableElement prevElement = null;
+
+ for (String part : parts) {
+ VariableElement elm = null;
+
+ if(part.startsWith("$")) {
+ elm = new VRefVariableElement(forbidSpaces, part.substring(1));
+ } else if (part.startsWith("@")) {
+ if(forbidSpaces)
+ throw new GrammarException("Arrays references aren't allowed in rule names");
+
+ elm = new ARefVariableElement(part.substring(1));
+ } else if (part.startsWith("%")) {
+ elm = new RRefVariableElement(forbidSpaces, part.substring(1));
+ } else if (part.startsWith("/")) {
+ throw new GrammarException("Template variables aren't implemented yet");
+ } else {
+ if(prevElement != null && prevElement instanceof LiteralVariableElement) {
+ /* Aggregate chain literals together */
+ ((LiteralVariableElement)prevElement).val += part;
+ } else {
+ elm = new LiteralVariableElement(forbidSpaces, part);
+ }
+ }
+
+ if(elm != null) {
+ elms.add(elm);
+
+ prevElement = elm;
+ }
+ }
+
+ return elms;
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/new-syntax.txt b/src/main/java/bjc/rgens/parser/new-syntax.txt
index f6578b4..f6578b4 100644..100755
--- a/src/main/java/bjc/rgens/parser/new-syntax.txt
+++ b/src/main/java/bjc/rgens/parser/new-syntax.txt
diff --git a/src/main/java/bjc/rgens/parser/templates/GrammarTemplate.java b/src/main/java/bjc/rgens/parser/templates/GrammarTemplate.java
new file mode 100644
index 0000000..fa634a5
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/templates/GrammarTemplate.java
@@ -0,0 +1,75 @@
+package bjc.rgens.parser.templates;
+
+import bjc.rgens.parser.ConfigSet;
+import bjc.rgens.parser.GenerationState;
+
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+public class GrammarTemplate {
+ public ConfigSet belongsTo;
+
+ public String name;
+
+ public final List<TemplateElement> elements;
+
+ public boolean doSpacing = true;
+
+ public GrammarTemplate(List<TemplateElement> elements) {
+ this.elements = elements;
+ }
+
+ public void generate(GenerationState state) {
+ for(TemplateElement element : elements) {
+ element.generate(state);
+
+ if(doSpacing && element.spacing)
+ state.contents.append("\n");
+ }
+ }
+
+ public static GrammarTemplate readTemplate(Reader rdr) {
+ List<TemplateElement> elements = new ArrayList<>();
+ GrammarTemplate template = new GrammarTemplate(elements);
+
+ Scanner scn = new Scanner(rdr);
+ scn.useDelimiter("\\R");
+
+ int lno = 0;
+ while(scn.hasNextLine()) {
+ String ln = scn.nextLine();
+ lno += 1;
+
+ switch(ln.charAt(0)) {
+ case '#':
+ // Ignore comments
+ break;
+ case '/':
+ handlePragma(elements, template, ln.substring(1));
+ break;
+ default:
+ handleLine(elements, template, ln);
+ }
+ }
+
+
+ return template;
+ }
+
+ private static void handleLine(List<TemplateElement> elements, GrammarTemplate template, String ln) {
+ if(ln.matches("^.*?\\$@.+?@\\$.*$")) {
+ /*
+ * Handle live templates
+ */
+ elements.add(new LiveTemplateElement(ln));
+ } else {
+ elements.add(new LiteralTemplateElement(ln));
+ }
+ }
+
+ private static void handlePragma(List<TemplateElement> elements, GrammarTemplate template, String ln) {
+
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/templates/LiteralTemplateElement.java b/src/main/java/bjc/rgens/parser/templates/LiteralTemplateElement.java
new file mode 100644
index 0000000..36cdb12
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/templates/LiteralTemplateElement.java
@@ -0,0 +1,17 @@
+package bjc.rgens.parser.templates;
+
+import bjc.rgens.parser.GenerationState;
+
+public class LiteralTemplateElement extends TemplateElement {
+ public final String val;
+
+ public LiteralTemplateElement(String val) {
+ super(true);
+
+ this.val = val;
+ }
+
+ public void generate(GenerationState state) {
+ state.contents.append(val);
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/templates/LiveTemplateElement.java b/src/main/java/bjc/rgens/parser/templates/LiveTemplateElement.java
new file mode 100644
index 0000000..154ea68
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/templates/LiveTemplateElement.java
@@ -0,0 +1,60 @@
+package bjc.rgens.parser.templates;
+
+import bjc.utils.data.BooleanToggle;
+import bjc.utils.funcdata.FunctionalList;
+
+import bjc.rgens.parser.GenerationState;
+import bjc.rgens.parser.RGrammarParser;
+import bjc.rgens.parser.elements.CaseElement;
+import bjc.rgens.parser.elements.LiteralCaseElement;
+
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class LiveTemplateElement extends TemplateElement {
+ private static final Pattern INSERT_PAT = Pattern.compile("\\$@(.+?)@\\$");
+
+ public final List<List<CaseElement>> elements;
+
+ public LiveTemplateElement(String val) {
+ super(true);
+
+ elements = new ArrayList<>();
+
+ Matcher mat = INSERT_PAT.matcher(val);
+ StringBuffer sb = new StringBuffer();
+
+ while(mat.find()) {
+ mat.appendReplacement(sb, "");
+ String body = mat.group(1);
+
+ FunctionalList<CaseElement> elms = (FunctionalList<CaseElement>)RGrammarParser.parseElementString(body).getLeft();
+
+ elements.add(Arrays.asList(new LiteralCaseElement(sb.toString())));
+ elements.add(elms.getInternal());
+
+ sb = new StringBuffer();
+ }
+
+ mat.appendTail(sb);
+ elements.add(Arrays.asList(new LiteralCaseElement(sb.toString())));
+ }
+
+ public void generate(GenerationState state) {
+ BooleanToggle bt = new BooleanToggle(false);
+
+ for(List<CaseElement> elmList : elements) {
+ boolean doSpacing = bt.get();
+
+ for(CaseElement elm : elmList) {
+ elm.generate(state);
+
+ if(doSpacing && elm.spacing)
+ state.contents.append(" ");
+ }
+ }
+ }
+}
diff --git a/src/main/java/bjc/rgens/parser/templates/TemplateElement.java b/src/main/java/bjc/rgens/parser/templates/TemplateElement.java
new file mode 100644
index 0000000..2d0724b
--- /dev/null
+++ b/src/main/java/bjc/rgens/parser/templates/TemplateElement.java
@@ -0,0 +1,15 @@
+package bjc.rgens.parser.templates;
+
+import bjc.rgens.parser.GenerationState;
+
+public abstract class TemplateElement {
+ public boolean spacing;
+
+ public GrammarTemplate belongsTo;
+
+ protected TemplateElement(boolean spacing) {
+ this.spacing = spacing;
+ }
+
+ public abstract void generate(GenerationState state);
+}
diff --git a/src/main/java/bjc/rgens/text/markov/Markov.java b/src/main/java/bjc/rgens/text/markov/Markov.java
index e21d60f..e21d60f 100644..100755
--- a/src/main/java/bjc/rgens/text/markov/Markov.java
+++ b/src/main/java/bjc/rgens/text/markov/Markov.java
diff --git a/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java b/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java
index cebf2bc..cebf2bc 100644..100755
--- a/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java
+++ b/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java
diff --git a/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java b/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java
index 339e8d5..339e8d5 100644..100755
--- a/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java
+++ b/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java
diff --git a/src/main/java/bjc/rgens/text/markov/TextGenerator.java b/src/main/java/bjc/rgens/text/markov/TextGenerator.java
index f629d49..f629d49 100644..100755
--- a/src/main/java/bjc/rgens/text/markov/TextGenerator.java
+++ b/src/main/java/bjc/rgens/text/markov/TextGenerator.java
diff --git a/src/main/sql/db_schema.sql b/src/main/sql/db_schema.sql
index 553c7a8..553c7a8 100644..100755
--- a/src/main/sql/db_schema.sql
+++ b/src/main/sql/db_schema.sql
diff --git a/todos.txt b/todos.txt
index e4e39cd..664c995 100644..100755
--- a/todos.txt
+++ b/todos.txt
@@ -1,9 +1,7 @@
-@TODO 10/11/17 Ben Culkin :GrammarReorg
- Better organize the provided sample grammars.
-
-@TODO 10/11/17 Ben Culkin :Determinism
+DONE(6/3/18) 10/11/17 Ben Culkin :Determinism
Add a way to get the grammar to pick rules in a deterministic fashion,
so as to be able to iterate all of the rules.
+ - Specify the same Random instance to the state
@TODO 10/11/17 Ben Culkin :ExportSanity
Figure out a way to organize exports instead of just sticking them all
@@ -23,8 +21,8 @@
kind of pragma to convert a rule to a single-level spacer?
ADDENDA: 10/24/17
- We now have a partial solution in 'despace-rule'. Now, grammars need to
- be adapted to use it.
+ We now have a partial solution in 'despace-rule'. However, this doesn't
+ quite work in some cases. Why is that?
@TODO 10/23/17 Ben Culkin :Pluralizing
Add some way to say to pluralize the contents of a rule
@@ -52,5 +50,6 @@
Add some way to sort of 'import' a rules body into another rule so as to
not throw off probability by splitting.
-@TODO 5/18/18 Ben Culkin :PragmaErrors
- Give better error messages for malformed pragmas
+@TODO 6/3/18 Ben Culkin :DieRandom
+ Add a way to use dice from dicelang (probably the rewrite, once that has
+ a string parser) to create random numbers