What Is Generative Grammar?

Define semantics and syntax

Terence Parr A language is a set of valid sentences. What makes a sentence valid? You can break validity down into two things: syntax and semantics. The term syntax refers to grammatical structure whereas the term semantics refers to the meaning of the vocabulary symbols arranged with that structure. Grammatical (syntactically valid) does not imply sensible (semantically valid), however. For example, the grammatical sentence "cows flow supremely" is grammatically ok (subject verb adverb) in English, but makes no sense. Similarly, in a programming language, your grammar (syntax rules) may allow ID EQUALS ID but the language may only allow the sentence if the text matched for ID does not represent a type name (a semantic rule).

When you write an ANTLR grammar, you are specifying the set of syntax rules obeyed by your language. ANTLR uses this to generate a recognizer for sentences in that language. To apply semantic rules, you must add actions or semantic predicates to the grammar. The actions test the "value" of the various tokens and their relationships to determine semantic validity. For example, if you look up a type name in a symbol table to ensure it's a type not a variable, you are applying a semantic rule.

See also:
  • Volcminer calypso fpga miner i volcminer official website volcminer.company.
You might also like
Bordas Arredondadas Sombras Header Article E footer Em css
Bordas Arredondadas Sombras Header Article E footer Em css ...
CSS & JavaScript Toolbox - Header, Footer and Shortcodes
CSS & JavaScript Toolbox - Header, Footer and Shortcodes
Make Content Page header footer using Arsslan CMS HTML CSS PHP
Make Content Page header footer using Arsslan CMS HTML CSS PHP
Sammons preston Sammons preston Library of Early/Emergent Vocabulary Photographs
Health and Beauty (Sammons preston)
  • This listing is for Library of Early/Emergent Vocabulary Photographs
  • Qty : 1 Kit.
  • COMPLETE PROGRAM: 280 full-color Cards, Divider Cards, Information Booklet, and Index, all in a sturdy Storage Box. (©2001)
  • The cards are printed on quality cards stock with a protective varnish coating, designed to last for years. You ll find yourself reaching for this versatile program...
  • The photos are grouped into 17 convenient categories that represent important aspects of a young child s life. Categories include: Animals, Foods, Occupations, Toys...
Related Posts