Giter Site home page Giter Site logo

jflex's Introduction

JFLEX

A simple lexical analyzer for C

Installation

Install jflex.

Usage

jflex lexical.jflex 

That will create a java file named LexicalAnalyzer (you can change it in the jflex file)

javac LexicalAnalyzer.java 

That will create a LexicalAnalyzer.class

java LexicalAnalyzer entrada.txt  

With this command you can run the class and the file. It will show in your terminal line by line of the lexical analyzer.

Scope methods has been added
[ID 0, Scope 0, Subscope 0,"main"]
<stdio.h> library will be imported
<stdio.h> library scope has been added
[ID 1, Scope 1, Subscope 0, "printf"] 
[ID 2, Scope 1, Subscope 0, "scanf"] 
<stdio.h> library scope has been imported
<conio.h> library will be imported
<conio.h> library scope has been added
[ID 3, Scope 2, Subscope 0, "clrscr"] 
[ID 4, Scope 2, Subscope 0, "getch"] 
<conio.h> library scope has been imported
[reserved_word, void]
[ID 5, Scope 0, Subscope 0, CalculoMedia]
[L_Paren, (]
[R_Paren, )]
[L_Brace, {]
[reserved_word, float]
[ID 6, Scope 3, Subscope 0, NotaDaP1]
[Comma, ,]
[ID 7, Scope 3, Subscope 0, NotaDaP2]
[Semicolon, ;]
[reserved_word, float]
[ID 8, Scope 3, Subscope 0, Media]
[Semicolon, ;]
[ID 9, Scope 3, Subscope 0, clrscr]
[L_Paren, (]
[R_Paren, )]
[Semicolon, ;]
[ID 6, Scope 3, Subscope 0, NotaDaP1]
[Equal, =]
[num, 6.6]
[Semicolon, ;]
[ID 7, Scope 3, Subscope 0, NotaDaP2]
[Equal, =]
[num, 8.2]
[Semicolon, ;]
[ID 8, Scope 3, Subscope 0, Media]
[Equal, =]
[L_Paren, (]
[ID 6, Scope 3, Subscope 0, NotaDaP1]
[Arith_Op: +]
[ID 7, Scope 3, Subscope 0, NotaDaP2]
[R_Paren, )]
[Arith_Op: /]
[num, 2.0]
[Semicolon, ;]
[ID 10, Scope 3, Subscope 0, printf]
[L_Paren, (]
[String_literal, "Média Final : %6.3f"]
[Comma, ,]
[ID 8, Scope 3, Subscope 0, Media]
[R_Paren, )]
[Semicolon, ;]
[ID 4, Scope 2, Subscope 0, getch]
[L_Paren, (]
[R_Paren, )]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, int]
[ID 11, Scope 0, Subscope 0, VerificaNumero]
[L_Paren, (]
[R_Paren, )]
[L_Brace, {]
[reserved_word, int]
[ID 12, Scope 4, Subscope 0, num]
[Semicolon, ;]
[reserved_word, string]
[ID 13, Scope 4, Subscope 0, s]
[Semicolon, ;]
[ID 14, Scope 4, Subscope 0, printf]
[L_Paren, (]
[String_literal, "Digite um número: "]
[R_Paren, )]
[Semicolon, ;]
[ID 2, Scope 1, Subscope 0, scanf]
[L_Paren, (]
[String_literal, "%d"]
[Comma, ,]
[Address, &]
[ID 12, Scope 4, Subscope 0, num]
[R_Paren, )]
[Semicolon, ;]
[reserved_word, if]
[L_Paren, (]
[ID 12, Scope 4, Subscope 0, num]
[Relational_Op, >]
[num, 10]
[R_Paren, )]
[L_Brace, {]
[ID 14, Scope 4, Subscope 0, printf]
[L_Paren, (]
[String_literal, "\n\n O número é maior que 10"]
[R_Paren, )]
[Semicolon, ;]
[ID 13, Scope 4, Subscope 0, s]
[Equal, =]
[String_literal, "errou"]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, if]
[L_Paren, (]
[ID 12, Scope 4, Subscope 0, num]
[Relational_Op, ==]
[num, 10]
[R_Paren, )]
[L_Brace, {]
[ID 14, Scope 4, Subscope 0, printf]
[L_Paren, (]
[String_literal, "\n\n Você acertou!\n"]
[R_Paren, )]
[Semicolon, ;]
[ID 14, Scope 4, Subscope 0, printf]
[L_Paren, (]
[String_literal, "O numero é igual a 10."]
[R_Paren, )]
[Semicolon, ;]
[ID 13, Scope 4, Subscope 0, s]
[Equal, =]
[String_literal, "acertou"]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, if]
[L_Paren, (]
[ID 12, Scope 4, Subscope 0, num]
[Relational_Op, <]
[num, 10]
[R_Paren, )]
[L_Brace, {]
[ID 14, Scope 4, Subscope 0, printf]
[L_Paren, (]
[String_literal, "\n\n O número é menor que 10"]
[R_Paren, )]
[Semicolon, ;]
[ID 13, Scope 4, Subscope 0, s]
[Equal, =]
[String_literal, "errou"]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, if]
[L_Paren, (]
[ID 12, Scope 4, Subscope 0, num]
[Relational_Op, ==]
[num, 10]
[Logic_Op, &&]
[ID 13, Scope 4, Subscope 0, s]
[Relational_Op, ==]
[String_literal, "acertou"]
[R_Paren, )]
[L_Brace, {]
[reserved_word, return]
[num, 1]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, return]
[num, 0]
[Semicolon, ;]
[R_Brace, }]
[reserved_word, void]
[ID 15, Scope 0, Subscope 0, AlterarVetor]
[L_Paren, (]
[reserved_word, int]
[Pointer, *]
[ID 16, Scope 5, Subscope 0, vetor]
[Comma, ,]
[reserved_word, int]
[ID 17, Scope 5, Subscope 0, elementos]
[R_Paren, )]
[L_Brace, {]
[reserved_word, int]
[ID 18, Scope 5, Subscope 0, i]
[Semicolon, ;]
[reserved_word, if]
[L_Paren, (]
[ID 16, Scope 5, Subscope 0, vetor]
[Relational_Op, !=]
[reserved_word, NULL]
[R_Paren, )]
[L_Brace, {]
[reserved_word, for]
[L_Paren, (]
[ID 18, Scope 5, Subscope 0, i]
[Equal, =]
[num, 0]
[Semicolon, ;]
[ID 18, Scope 5, Subscope 0, i]
[Relational_Op, <]
[ID 17, Scope 5, Subscope 0, elementos]
[Semicolon, ;]
[ID 18, Scope 5, Subscope 0, i]
[Inc_Op, ++]
[R_Paren, )]
[L_Brace, {]
[Pointer, *]
[L_Paren, (]
[ID 16, Scope 5, Subscope 0, vetor]
[R_Paren, )]
[Equal, =]
[Pointer, *]
[L_Paren, (]
[ID 16, Scope 5, Subscope 0, vetor]
[R_Paren, )]
[Arith_Op: *]
[num, 2]
[Semicolon, ;]
[ID 16, Scope 5, Subscope 0, vetor]
[Inc_Op, ++]
[Semicolon, ;]
[R_Brace, }]
[R_Brace, }]
[R_Brace, }]
[reserved_word, int]
[ID 0, Scope 0, Subscope 0, main]
[L_Paren, (]
[R_Paren, )]
[L_Brace, {]
[reserved_word, int]
[ID 19, Scope 6, Subscope 0, v]
[L_Bracket, []
[R_Bracket, ]]
[Equal, =]
[L_Brace, {]
[num, 5]
[Comma, ,]
[num, 10]
[Comma, ,]
[num, 15]
[Comma, ,]
[num, 3]
[Comma, ,]
[num, 10]
[Comma, ,]
[num, 76]
[Comma, ,]
[num, 5]
[Comma, ,]
[num, 13]
[Comma, ,]
[num, 33]
[Comma, ,]
[num, 45]
[R_Brace, }]
[Semicolon, ;]
[reserved_word, int]
[Pointer, *]
[ID 20, Scope 6, Subscope 0, pt]
[Semicolon, ;]
[reserved_word, int]
[ID 21, Scope 6, Subscope 0, i]
[Semicolon, ;]
[ID 20, Scope 6, Subscope 0, pt]
[Equal, =]
[ID 19, Scope 6, Subscope 0, v]
[Semicolon, ;]
[ID 15, Scope 0, Subscope 0, AlterarVetor]
[L_Paren, (]
[ID 19, Scope 6, Subscope 0, v]
[Comma, ,]
[num, 10]
[R_Paren, )]
[Semicolon, ;]
[reserved_word, for]
[L_Paren, (]
[reserved_word, int]
[ID 22, Scope 6, Subscope 1, i]
[Equal, =]
[num, 0]
[Semicolon, ;]
[ID 22, Scope 6, Subscope 1, i]
[Relational_Op, <]
[num, 10]
[Semicolon, ;]
[ID 22, Scope 6, Subscope 1, i]
[Inc_Op, ++]
[R_Paren, )]
[L_Brace, {]
[ID 23, Scope 6, Subscope 1, printf]
[L_Paren, (]
[String_literal, "V[%i] = %i\r\n"]
[Comma, ,]
[ID 22, Scope 6, Subscope 1, i]
[Comma, ,]
[Pointer, *]
[L_Paren, (]
[ID 20, Scope 6, Subscope 0, pt]
[Arith_Op: +]
[ID 22, Scope 6, Subscope 1, i]
[R_Paren, )]
[R_Paren, )]
[Semicolon, ;]
[R_Brace, }]
[ID 5, Scope 0, Subscope 0, CalculoMedia]
[L_Paren, (]
[R_Paren, )]
[Semicolon, ;]
[ID 11, Scope 0, Subscope 0, VerificaNumero]
[L_Paren, (]
[R_Paren, )]
[Semicolon, ;]
[reserved_word, return]
[num, 0]
[Semicolon, ;]
[R_Brace, }]

Obs

You can change the txt file for your file locally

jflex's People

Contributors

vanessaschenkel 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.