Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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? o I read books o I read long books o I read long red books o Birds fly o Red birds fly o Birds fly fast


Download ppt "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."

Similar presentations


Ads by Google