Skip to content

AkaneMurakawa/mini-jsi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mini-jsi

Mini Java script interpreter

  • support basic arithmetic calculation and decimal calculation.
  • support arithmetic priority and parentheses parsing.

Basic structure of simple interpreter

Lexical ———Token———> Parser ———AST———> Interpreter

Example

JSI 0.0.1 Java script interpreter Windows 10 amd64
>> 1*(2+3)-(4/2)
1*(2+3)-(4/2)
[debug] token: 
Token{tokenKind='number', literal='1'}
Token{tokenKind='symbols', literal='*'}
Token{tokenKind='terminator', literal='('}
Token{tokenKind='number', literal='2'}
Token{tokenKind='symbols', literal='+'}
Token{tokenKind='number', literal='3'}
Token{tokenKind='terminator', literal=')'}
Token{tokenKind='symbols', literal='-'}
Token{tokenKind='terminator', literal='('}
Token{tokenKind='number', literal='4'}
Token{tokenKind='symbols', literal='/'}
Token{tokenKind='number', literal='2'}
Token{tokenKind='terminator', literal=')'}
[debug] ast: 
Binary{left=Binary{left=1, operator=*, right=Binary{left=2, operator=+, right=3}}, operator=-, right=Binary{left=4, operator=/, right=2}}
3.0

Reference

About

Java script interpreter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages