Advanced Programming Techniques COSI12B

Overview
This program focuses on programming with recursion. Turn in files named
GrammarSolver.java, GrammarTester.java and grammar.txt . You will need support files GrammarMain.java , sentence.txt , and other input files; place them in the same folder as your project.
iuww520iuww520iuww520iuww520iuww520iuww520iuww520iuww520
Languages and Grammars
A formal language is a set of words and/or symbols along with a set of rules,
collectively called the syntax of the language, defining how those symbols may be used together. A grammar is a way of describing the syntax and symbols of a formal language. Many language grammars can be described in a common format called
Backus-Naur Form ( BNF ).
Some symbols in a grammar are called terminals because they represent
fundamental words of the language. A terminal in the English language might be the word "boy" or "run" or "Jessica". Other symbols of the grammar are called non terminals and represent high-level parts of the language syntax, such as a noun phrase or a sentence. Every non-terminal consists of one or more terminals; for example, the verb phrase "throw a ball" consists of three terminal words.
The BNF description of a language consists of a set of derivation rules , where each rule names a symbol and the legal transformations that can be performed between that symbol and other constructs in the language. For example, a BNF grammar for the English language might state that a sentence consists of a noun phrase and a verb phrase, and that a noun phrase can consist of an adjective followed by a noun or just a noun. Rules can be described recursively (in terms of themselves). For example, a noun phrase might consist of an adjective followed by another noun phrase.
A BNF grammar is specified as an input file containing one or more rules, each on its own line, of the form:
non-terminal ::= rule | rule | rule | ... | rule
A ::= (colon colon equals) separator divides the non-terminal from its expansion rules. There will be exactly one ::= per line. A | (pipe) separates each rule; if there is only one rule for a given non-terminal, there will be no pipe characters. The following is a valid example BNF input file describing a small subset of the English language. Non-terminal names such as <s> , <np> and <tv> are short for linguistic elements such as sentences, noun phrases, and transitive verbs.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值