Giter VIP home page Giter VIP logo

scanner's Introduction

Token Class-

Our Token class constructors hold the values of the type and the character value of that type.
These constructors take string or integer values.
The method getTokenNum retrieves the type of the token. The following methods use a simple
state machine design to check if a certain string is a reserved word. The isInt method 
checks for valid integers between -2^32 through 2^32-1.

Scanner Class-

Contained in the Scanner class is a main function to scan a given file and pick out tokens.
The scanner takes in a file with a scanner and uses a push back input stream to read the data.
When retrieving and creating tokens the getNextToken function checks each byte and decides if it
is part of the grammar's symbol list (defined in isSymbol). If this is the case, a token is created 
with that symbol. If this is NOT the case, each byte is read in until whitespace or a symbol is found
and stored into a variable to return as a token.

Compiling-

in compiler/src/ directory, run
	$ javac Scanner.java

Running- 

The main exists in the Scanner.java and will be executed when running the file.
The main also runs the test file automatically.

in compiler/src/ directory, run
	$ java Scanner.java

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.