Skip to content

kochetov-dmitrij/YACC_C99

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YACC_C99

Structure:

.
├── README.md
├── input.txt
├── lex.l
├── node.h
├── parser
├── run.sh
└── yacc.y

run.sh does the following:

Process the yacc grammar file:
yacc.y -> (bison) -> yacc.cpp, yacc.hpp

Process the lex specification file:
lex.l -> (flex) -> lex.cpp

Compile and link the two C language source files:
yacc.cpp, lex.cpp -> parser

Run the program
./parser input.txt

Input (input.txt):

int main()
{
  printf("Hello World\n");
  return 0;
}

Output:

===== Tree =====

└──translation unit
    └──Function definition
        ├──int
        ├──Direct declarator
        │   └──Identifier
        │       └──main
        └──Block item list
            └──Block item list
                ├──Block item
                │   └──Expression statement
                │       └──Expression
                │           └──Postfix expression
                │               ├──Identifier
                │               │   └──printf
                │               └──String literal
                │                   └──"Hello World\n"
                └──Return
                    └──Constant
                        └──0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published