C

Grammaire hors contexte

CFG

Une Grammaire Hors Contexte (CFG) définit des règles pour générer des chaînes dans un langage en utilisant un ensemble de symboles et de règles de production.

A Grammaire Libre de Contexte (CFG) is a formal grammar that consists of a set of production rules used to generate strings from a given language. It is a type of formal grammar where each rule describes how a symbol (non-terminal) can be replaced by a sequence of symbols, which can include both terminal symbols (the actual characters of the language) and non-terminal symbols (variables that can be replaced further).

Les CFG sont largement utilisés dans langages de programmation and traitement du langage naturel as they provide a clear and structured way to analyze and generate syntactical constructs. Each grammar is composed of:

  • Terminals : The basic symbols from which strings are formed. These are the actual characters or tokens dans la langue.
  • Non-terminaux : Symbols that can be replaced with groups of terminals and/or other non-terminals. They represent abstract syntactical categories.
  • Règles de production : Rules that define how non-terminals can be transformed into terminals or other non-terminals. Each rule has a left-hand side (a non-terminal) and a right-hand side (a combination of terminals and non-terminals).
  • Un symbole de départ : A special non-terminal that indicates the beginning of the string generation process.

CFGs are powerful because they can describe a wide variety of languages, including those with nested structures, such as parentheses in mathematical expressions or sentences in natural languages. They are fundamental in the design of compilers and interpreters, as well as in the development of parsers that analyze and understand the syntax of programming languages and natural language texts.

oEmbed (JSON) + /