# I'm reworking this. Great thanks is due to "Essentials of English", # formerly "Essentials of Effective Writing", by Hopper, Gale, Foote # and Griffith, published by Barron's. I used the fourth edition, # though I expect the other editions are just fine too. I refer to it # in the comments as 'EoE'. - angelbob # This is really just the end of the grammar. Before this, Phantasmal # starts with the whitespace rule, some autogenerated part-of-speech # token rules, the other basic token rules (see nl_tokens.dpd), and a # bad-token rule. # The autogenerated rules just categorize various words (like "lamp", # "checkered", "fast", "take", etc) by what parts of speech (like # noun, adjective, transitive verb, etc) they are. Each overlap of # categories (is a noun, isn't an adverb, etc) gets an autogenerated # category. # Later we may autogenerate the rules for each part of speech below, # just to take more repetitive bits out of the grammar file. Besides, # that section's going to double in size every time we add a part of # speech. Autogenerating would let us remove nonexistent categories # rather than stubbing them out. ### Start of non-token rules # This is the start token line: # A line of input is called 'line'. Lines can consist of one or more # sentences. A sub_line is just one or more consecutive sentences, # each with punctuation at the end. Each sentence is an independent # action. line: sentence line: sub_line line: sub_line sentence # Sub_line is defined here as above. It's just one or more sentences, # each with command-ending punctuation (like a period or semicolon) at # the end. Note that commas don't count as command-ending # punctuation. sub_line: sentence punctuation sub_line: sub_line sentence punctuation # Sentences can have one or more independent clauses, which are # treated like separate sentences for the sake of the MUD. sentence: indep_clause #sentence: sentence 'and' indep_clause #sentence: sentence 'but' indep_clause # Independent clauses -- the basic action. Usually each clause is # converted into one action, though there may be exceptions. indep_clause: iverb ? iclause_iverb indep_clause: tverb np ? iclause_tverb_np #indep_clause: tverb pp #indep_clause: tverb np pp #indep_clause: tverb pp pp # Plural noun phrases ("the cat and the girl") will eventually go # here. That's why we need a "noun phrase right" (npr) which can # be parsed unambiguously. np: npr #np: np noun_conjunction npr # Unambiguous definitions of noun phrases. 'npr' stands for noun # phrase right-side, since this is where it appears in the noun phrase # rules. An npr is a simple noun phrase, and an 'np' is one or more # nprs joined by conjunctions. # # Eventually we'll add rules about things like pronouns here. npr: adj_noun ? npr_adj_noun npr: det adj_noun ? npr_det_adj_noun # adj_noun is zero or more adjectives followed by a noun adj_noun: adjp noun # An adjp is zero or more adjectives adjp: adjp: adjp adjective # Determiners, including articles. Eventually things like possessives # will go here. det: article