# Jan23 - CSE262: Programming Languages Instructor: Dr. Liang...

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

CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering P.C. Rossin College of Engineering & Applied Science Lehigh University January 23, 2007

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 01/23/07 Outline ± Recap ± Compiler/Compilation in a nutshell ± BNF without ambiguity ± Extended BNF ± Summary and homework
Instructor: Dr. Liang Cheng CSE262: Programming Languages 01/23/07 Language Users <program> <stmts> <stmt> const a <var> = <expr> <var> b <term> + <term> BNF Functionality ± Describing Lists ± Grammar & Derivation ± Parse Trees ± Avoiding Ambiguity <program> => <stmts> => <stmt> => <var> = <expr> => a = <expr> => a = <term> + <term> => a = <var> + <term> => a = b + <term> => a = b + const <program> <stmts> <stmts> <stmt> | <stmt> ; <stmts> <stmt> <var> = <expr> <var> a | b | c | d <expr> <term> + <term> | <term> - <term> <term> <var> | const

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 01/23/07 Language Designers ± Design a BNF grammar for a language that could express a one-digit number, an addition of two one-digit numbers, or a subtraction of two one-digit numbers ± <expr> <term> + <term> | <term> - <term> | <term> ± <term> 0 | 1 | 2 | … | 9
Instructor: Dr. Liang Cheng CSE262: Programming Languages 01/23/07 Language Implementers ± A recursive-descent parser ± Language implementation directly following the BNF grammar ± <expr> <term> + <term> | <term> - <term> | <term> ± <term> 0 | 1 | 2 | … | 9 ± Extra credit homework question ± Pseudo code void expr() { void term() { term(); match( int_literal ); if( token== plus_op } or token== minus_op ) { match(token); void match(expectedToken) { term(); if(token==expectedToken) } getNextToken(); else error(); else error(); }}

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

View Full Document
Instructor: Dr. Liang Cheng
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/06/2008 for the course CSE 262 taught by Professor Cheng during the Spring '07 term at Lehigh University .

### Page1 / 24

Jan23 - CSE262: Programming Languages Instructor: Dr. Liang...

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

View Full Document
Ask a homework question - tutors are online