Git Product home page Git Product logo

go-lexer-token-simple's Introduction

mylex: go-lexer-token-simple

Simple Go lexer: Lex own syntax and read it's from file.

Features

  • Tokenizer
  • Position analyzer (line and offset)
  • Ident
  • Int
  • Comments # ...
  • Operators (+ - * / =)

Example / Syntax

# Max Base
# simple lexer written in GoLang
# 2021-03-21

int main() {
	a = 5;
	b = a + 6;
	c + 123;
	5+12;
	ret c;
}

Using

git clone https://github.com/BaseMax/go-lexer-token-simple
cd go-lexer-token-simple
go build
./go-lexer-token-simple

or using go get:

go get github.com/BaseMax/go-lexer-token-simple
cd /path/to/go-lexer-token-simple
go build
./go-lexer-token-simple

Output

5:1	IDENT	int
5:5	IDENT	main
5:9	(	
5:10	)	
5:12	{	
6:2	IDENT	a
6:4	=	
6:6	INT	5
6:7	;	
7:2	IDENT	b
7:4	=	
7:6	IDENT	a
7:8	+	
7:10	INT	6
7:11	;	
8:2	IDENT	c
8:4	+	
8:6	INT	123
8:9	;	
9:2	INT	5
9:3	+	
9:4	INT	12
9:6	;	
10:2	RET	
10:6	IDENT	c
10:7	;	
11:1	}	

TODO

  • Support \r\n
  • Support floating numbers

My references

© Copyright Max Base

go-lexer-token-simple's People

Stargazers

 avatar  avatar

Watchers

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