Lect 1.2.5 EBNF Worked Examples

# Lect 1.2.5 EBNF Worked Examples - Lecture1.2.5...

• Notes
• 5

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

Lecture 1.2.5 EBNF Worked Examples

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

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
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.

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

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

• Fall '10
• Mr.Leong
• \$0, \$0.27, 4 Second, 9,876,543.10 \$, 567 \$

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern