1 / 4

Grammars

Grammars. Grammars can get quite complex, but are essential. Syntax: the form of the text that is valid Semantics: the meaning of the form Sometimes semantics are needed to read syntax But, in this class we will keep things very simple…

rene
Download Presentation

Grammars

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. Grammars • Grammars can get quite complex, but are essential. • Syntax: the form of the text that is valid • Semantics: the meaning of the form • Sometimes semantics are needed to read syntax • But, in this class we will keep things very simple… • Parsing: how to take a grammar and apply it to some input

  2. Grammars • Grammar is important: • For understanding programming languages • Each language has a grammar • For dealing with input/output • Input/output usually obeys some rules • Parsing can vary in complexity • Reading very simple grammars often not even thought of as “parsing” • Our examples in this class get to a “moderate” level of complexity

  3. Parsing • We saw examples of this previously with the calculator, and with some sentences in English. • Parsing is how you go from an input to something the computer can deal with.

  4. Grammar/Parsing Example • Sentence: • Subject Verb Object • Subject Verb • Subject • Noun • Object • Adjective Object • Noun • Are these valid? • I read books • I read long books • I read long red books • Birds fly • Red birds fly • Birds fly fast

More Related