Projects icon indicating copy to clipboard operation
Projects copied to clipboard

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

Open jabnakar opened this issue 9 years ago • 7 comments

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.

jabnakar avatar Mar 20 '15 01:03 jabnakar

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

alexandre avatar Feb 16 '16 15:02 alexandre

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

popey456963 avatar Feb 17 '16 15:02 popey456963

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.

jabnakar avatar Feb 17 '16 15:02 jabnakar

@alexandre eval(input())

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

alexandre avatar Feb 18 '16 03:02 alexandre

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

popey456963 avatar Feb 18 '16 15:02 popey456963

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 avatar Nov 09 '17 20:11 sbelidhe

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

sbelidhe avatar Nov 12 '17 10:11 sbelidhe