ABOUT TREE

Context Free Grammar

Parse Tree Visualization

boy

What is CFG ?


Context-free grammars (CFGs) are used to describe context-free languages. A context-free grammar is a set of recursive rules used to generate patterns of strings. A context-free grammar can describe all regular languages and more, but they cannot describe all possible languages.
Context-free grammars are studied in fields of theoretical computer science, compiler design, and linguistics. CFG’s are used to describe programming languages and parser programs in compilers can be generated automatically from context-free grammars.
A context-free grammar can be described by a four-element tuple (V,∑,R,S) where

  • V is a finite set of variables (which are non-terminal).
  • is a finite set (disjoint from V) of terminal symbols.
  • R is a set of production rules where each production rule maps a variable to a string.
  • S (which is in V) which is a start symbol.
  • For more info -> Context Free Grammar


    w =

    
        
    
    
        
          Sample Grammar
        
    
        
    
        
    S → aSa | +aEa
    E → aEa | =

    Parse Tree

    This text is displayed if your browser does not support the Canvas HTML element.

    A parse tree is an ordered, rooted tree representing the structure of a sentence, broken down to parts-of-speech.