GithubHelp home page GithubHelp logo

arafatrohan93 / compiler-h Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 58 KB

This is a compiler project designed for Compiler Design course.

C 89.76% Lex 1.35% C++ 2.36% Yacc 6.53%
compiler-design lexical-analysis bison-yacc flex c yacc

compiler-h's Introduction

Compiler-H

It is Built with Flex and Bison.

This is a compiler project designed for Compiler Design course.

Clone

https://github.com/ArafatRohan93/Compiler-H

Syntax

  • Calling Main Function
void_main ( )
{{ ... }}

  • Statement Terminator
<br>
  • Declaring Variables
$_int_$  a:=50
  • Operators
Symbol Action
:= Assignment
^ Power
+ Plus
- Minus
* Multipliation
/ Division
> Greater Than
< Lesser Than
== Is Equal
>= Greater or Equal
<= Lesser or Equal
!= Not Equal
! Factorial
  • Scope Resolution Operator
Symbol Action
{{ Start of scope
}} End of scope
  • if-else Supports Nested if properties
 if (1):
       {{ 5 }}
   else:
       {{ 7 }}
if (2 > 3):
   	{{ 1 }}
    else:
      {{
        if (0):
          {{ 5 }}
         else:
           {{ 7 }}
    }}    
  • Loops
  • For Loop
for ( x := 0 , x <= 4, x ++ ) 
{{
 print(5) <br>
}}
  • While Loop
while(i<5):
{{
 z<br>
 i++<br>
}}
  • Function
  • Declaration Must be inside Main()
return_type function name()
{{ 
 ...
}}

Example :

$_int_$ function oddeven1 ( )
       {{
          13 <br>
       }}
  • Calling Function
function oddeven1 ( )

Installation

Compilation and Execution

1.Open Command prompt and switch to your working directory where you have stored your lex file (“.l“) and yacc file (“.y“).

2.Let your lex and yacc files be “rhn.l” and “rhn.y“. Now, follow the preceding steps to compile and run your program.

  • For Compiling Lex file only:
flex hello.l
gcc lex.yy.c
  • For Compiling Lex & Yacc file both:
flex hello.l
bison -dy hello.y
gcc lex.yy.c y.tab.c
  • For Executing the Program
a.exe

compiler-h's People

Contributors

arafatrohan93 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.