Lect 1.2.5 EBNF Worked Examples

Lect 1.2.5 EBNF Worked Examples - 3 First example –...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 1.2.5 EBNF Worked Examples
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture 02.5 For the exams, you may be required to Write/evaluate EBNF syntax Draw syntax diagrams Two worked examples Nov 2007 exam paper , Question 1d Nov 2005 exam paper, Question 1a 2
Background image of page 2
First example One commonly used format for displaying the amount of money is as follows: The amount starts with a leading dollar sign ($), an optional string of asterisks (*) (these are typically used on cheques to prevent fraud), a string of decimal digits, and an optional fractional part consisting of a decimal point (.), and two decimal digits. The string of digits to the left of the decimal point may consist of a single zero (0); otherwise it must not start with a zero.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 First example – Groups of three digits to the left of the decimal point are separated by a comma (,) – A few examples of the above format are as follows: • $**9,876,543.10 • $**567 • $*5 • $0 • $0.27 • Construct the EBNF specification for a language that recognizes the above format. 4 Second example • Consider the following BNF grammar rules 1. <S> ::= <A> 2. <A> ::= [<B>,<A>] 3. <A> ::= <B> 4. <B> ::= <C> 5. <B> ::= (<A>) 6. <C> ::= a 7. <C> ::= b 8. <C> ::= c • For each of the strings below, indicate whether they are valid or invalid according to the BNF grammar rules given on the left. i. (a) ii. [b] iii. ([a,b]) iv. [(a),b] v. [(a),[b,a]] 5...
View Full Document

This note was uploaded on 12/08/2010 for the course SCE CSC301 taught by Professor Mr.leong during the Fall '10 term at Nanyang Technological University.

Page1 / 5

Lect 1.2.5 EBNF Worked Examples - 3 First example –...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online