1 / 7

Syntax

Syntax. Syntax vs Semantics Backus-Naur Form Extended BNF Derivations Parse Trees. Syntax. Syntax: The grammatical form of programs. vs Semantics: The meaning of the program

bdelvalle
Download Presentation

Syntax

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Syntax • Syntax vs Semantics • Backus-Naur Form • Extended BNF • Derivations • Parse Trees CSE 341 -- S. Tanimoto Syntax

  2. 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 341 -- S. Tanimoto Syntax

  3. Syntactic Components Identifiers and reserved words Numeric constants Parentheses, braces and brackets Expressions Statements CSE 341 -- 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 341 -- S. Tanimoto Syntax

  5. 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 341 -- S. Tanimoto Syntax

  6. 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 / 100 + F 25 / 100 + total CSE 341 -- S. Tanimoto Syntax

  7. Parse Trees E ::= E + T | E - T | T T ::= T * F | T / F | F F ::= number | name | ( E ) 25 / 100 + total number / number + name F F F T T T E E CSE 341 -- S. Tanimoto Syntax

More Related