Download presentation
Presentation is loading. Please wait.
Published byYenny Hardja Modified over 5 years ago
1
CSE 341 -- S. Tanimoto Syntax
Syntax vs Semantics Backus-Naur Form Extended BNF Derivations Parse Trees CSE S. Tanimoto Syntax
2
CSE 341 -- S. Tanimoto Syntax
Syntax: The grammatical form of programs. vs Semantics: The meaning of the program Syntax (of textual languages) is typically specified by production rules for a context-free grammar using Backus-Naur Form (BNF) or Extended BNF (EBNF) In visual languages, syntax is described by a set of restrictions on how diagrams may be constructed. (e.g., connection constraints) CSE S. Tanimoto Syntax
3
CSE 341 -- S. Tanimoto Syntax
Syntactic Components Identifiers and reserved words Numeric constants Parentheses, braces and brackets Expressions Statements CSE S. Tanimoto Syntax
4
BNF (Backus-Naur Form)
(2.0 * PI) / n <expression> ::= <expression> + <term> | <expression> - <term> | <term> <term> ::= <term> * <factor> | <term> / <factor> | <factor> <factor> ::= number | name | ( <expression> ) CSE S. Tanimoto Syntax
5
CSE 341 -- S. Tanimoto Syntax
Extended BNF Optional constructs written as [ x ] Zero or more of x written as { x } Choice (“or”) written using | Grouping with parentheses ( x | y ) as in { (x | y ) z } <expression> ::= <term> { (+ | -) <term> } <term> ::= <factor> { (* | /) <factor> } <factor> ::= ’(’ <expression> ’)’ | name | number CSE S. Tanimoto Syntax
6
CSE 341 -- S. Tanimoto Syntax
Derivation E ::= E + T | E - T | T T ::= T * F | T / F | F F ::= number | name | ( E ) E E + T T + T T / F + T F / F + T F / F + F 25 / F + F 25 / F 25 / total CSE S. Tanimoto Syntax
7
CSE 341 -- S. Tanimoto Syntax
Parse Trees E ::= E + T | E - T | T T ::= T * F | T / F | F F ::= number | name | ( E ) / total number / number name F F F T T T E E CSE S. Tanimoto Syntax
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.