Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Lexical grammar and Syntactic grammar?

I am reading The Java Language Specification 8.

I am trying to understand Chapter 2. Grammars.

Here's what I have already learned:

  1. Semantics:
    Semantics is the study of meaning.

  2. Meaning:
    Meaning, in semantics, is defined as being Extension: The thing in the world that the word/phrase refers to, plus Intention: The concepts/mental images that the word/phrase evokes.

  3. Syntax:
    Syntax is all about the structure of sentences, and what determines which words go where.

  4. Production:
    A production or production rule in computer science is a rewrite rule specifying a symbol substitution that can be recursively performed to generate new symbol sequences.

  5. Alphabet:
    A non-empty set is called alphabet when its intended use in string operations shall be indicated.

  6. Lexeme:
    A lexeme is a string of characters which forms a syntactic unit.

  7. Syntactic unit:
    Sentence is the "highest" (i.e., largest) syntactic unit,
    the lowest (i.e., smallest) syntactic units are words,
    the intermediate syntactic units are the phrases.

  8. Token:
    A token is a structure representing a lexeme that explicitly indicates its categorization for the purpose of parsing.

  9. Grammar:
    A grammar (when the context is not given, often called a formal grammar for clarity) is a set of production rules for strings in a formal language. The rules describe how to form strings from the language's alphabet that are valid according to the language's syntax. A formal grammar is a set of rules for rewriting strings, along with a "start symbol" from which rewriting starts.

  10. Lexical grammar:
    A lexical grammar is a formal grammar defining the syntax of tokens.

I could not find out what syntactic grammar is.

like image 202
Rounak Avatar asked May 17 '15 07:05

Rounak


People also ask

What is the difference between syntactic and lexical?

The lexical features are unigrams, bigrams, and the surface form of the target word, while the syntactic features are part of speech tags and various components from a parse tree. The surface form of a target word may restrict its possible senses.

What's the difference between lexical and grammatical?

The categories of English words that are lexical include nouns, adjectives, most verbs, and many adverbs. Lexical meaning is dominant in content words, whereas grammatical meaning is dominant in function words, but in neither is grammatical meaning absent.

What is difference between syntax and grammar?

What's the Difference Between Syntax and Grammar? Syntax is a subdivision of grammar. Grammar comprises the entire system of rules for a language, including syntax. Syntax deals with the way that words are put together to form phrases, clauses, and sentences.

What are the differences between lexical syntactic and semantic analysis?

The main difference between syntax analysis and semantic analysis is that syntax analysis takes the tokens generated by the lexical analysis and generates a parse tree while semantic analysis checks whether the parse tree generated by syntax analysis follows the rules of the language.


1 Answers

A more expansive definition of "syntax" would be the set of all ordered combinations of symbols which form a correct document, in the given language. Thus, "syntactic grammar" can be summarily described as the portion of the language's grammar that describes how various tokens can be ordered, to form meaningful phrases.

Of course this folds back on your provided definition of "lexical grammar", so allow me to highlight the major difference--lexical grammar describes the structure of the lexicon, that is, every token (word) used in the language. Syntactical grammar describes how phrases and documents are formed from those tokens.

like image 161
Michael Macha Avatar answered Oct 04 '22 18:10

Michael Macha