Projects
Projects copied to clipboard
Lexer(Lexical Analyzer,for those who don't know)
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.
even simpler: a calculator (e.g. solving expressions like 1 + 5 * 3 * (10 + 1))
@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.
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 eval(input())
if you think that in this way you will to learn something, go ahead. :)
@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.
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
Please refer to code ArithmeticLexer written in java which can be extended later based on the requirement