Skip to content

Refactor string parser and lexer: mainly for webapp usage #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ryukinix opened this issue Mar 4, 2019 · 5 comments
Open

Refactor string parser and lexer: mainly for webapp usage #25

ryukinix opened this issue Mar 4, 2019 · 5 comments

Comments

@ryukinix
Copy link
Owner

ryukinix commented Mar 4, 2019

  • It should tokenize tokens first based on operations, supporting concatenated (without whitespaces) exps like this: p^q.
  • It should use a LL(1) parser
  • It should supports parenthesis without any problem
  • It should fail early instead of trying be clever.

Example:

In: "p^q=>r" 
Out: (=> (^ p q) r)
@ryukinix ryukinix changed the title Refactor lexer Refactor parser and lexer Mar 4, 2019
@ryukinix ryukinix changed the title Refactor parser and lexer Refactor parser and lexer: mainly for webapp usage Mar 4, 2019
@leonardohn
Copy link

leonardohn commented Mar 4, 2019

Well, you could use an LL(1) parser to read the expression precedence and give you a polish notation expression. Try using this website to test this grammar:

D' -> v C D'
D' -> ''
C -> I C'
C' -> ^ I C'
C' -> ''
I -> E I'
I' -> => E I'
I' -> ''
E -> N E'
E' -> <=> N E'
E' -> ''
N -> ~ A
N -> A
A -> ( P )
A -> id

@ryukinix
Copy link
Owner Author

ryukinix commented Mar 4, 2019

Thank you for this contribution! A formal parser will be really useful!

@ryukinix ryukinix self-assigned this Mar 4, 2019
@ryukinix
Copy link
Owner Author

ryukinix commented Mar 4, 2019

The parsing table it is:

image

@ryukinix
Copy link
Owner Author

ryukinix commented Mar 4, 2019

image

Runtime parsing steps.

@ryukinix
Copy link
Owner Author

ryukinix commented Mar 5, 2019

Maybe can be useful: https://github.com/vy/meta-sexp

@ryukinix ryukinix changed the title Refactor parser and lexer: mainly for webapp usage Refactor string parser and lexer: mainly for webapp usage Mar 5, 2019
@ryukinix ryukinix removed their assignment Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants