karan / Projects

:page_with_curl: A list of practical projects that anyone can solve in any programming language.
https://twitter.com/karangoel
MIT License
45.07k stars 10.57k forks source link

Lexer(Lexical Analyzer,for those who don't know) #70

Open jabnakar opened 9 years ago

jabnakar commented 9 years ago

Have anyone suggested a part of script interpreter(or specifically lexical analyzer) yet? without the use of third party tools of course. To make it simple , focus on a target scripting language to do lexing, for example a tiny version of BASIC.

alexandre commented 8 years ago

even simpler: a calculator (e.g. solving expressions like 1 + 5 * 3 * (10 + 1))

popey456963 commented 8 years ago

@alexandre eval(input())

But no, in all honesty. That's a very cool idea. We could perhaps get it to work on reverse polish notation here. Basically, you have 3 4 + to get to 7.

jabnakar commented 8 years ago

I already found a way to do this from a youtube video tutorial, the guy made it in python, no explosion of terms, use of libraries and regex too.

alexandre commented 8 years ago

@alexandre eval(input())

if you think that in this way you will to learn something, go ahead. :)

popey456963 commented 8 years ago

@alexandre Aha, I realise. It was a joke, hence the "But no, in all honesty" part.

I feel like a calculator though would be an incredibly awesome idea, there are so many ways to solve it.

sbelidhe commented 6 years ago

One can develop lexical analyzer using jflex library.If one is looking to develop lexical analyzer without third party libraries One can use lexical analyzer classes java provides like stringtokenizer or streamtokenzier as part of implementation.Please refer to https://www.javaworld.com/article/2076874/learn-java/lexical-analysis-and-java--part-1.html link for more details

sbelidhe commented 6 years ago

Please refer to code ArithmeticLexer written in java which can be extended later based on the requirement