Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can't understand how to parse an input string using a written grammar using "BNF".

What I have tried:

Hello, I'm puppysss and built a simple script language with a lexer recently.
I was about to think about making a parser for it but my try made my head blown up. let me tell you an entire story of my idea for my own script...

1. Analyze a code with lexer for dividing words.
ex) "var a=1,b=1,c c=a+b print c" => "var\a\=\1\b\=\1\c\c\=\a\+\b\print\c\"

2. Build a grammar for a simple script using BNF or something ...

but I was hit by the wall of number two so googled many articles about "BNF"
thinking "it's pretty cool to success two" and
finally I understood "BNF". that was a method to describe a grammar.

however I was hit again by the wall of number three
that is how to parse an input string with a written grammar using "BNF"

Is there anyone who could explain that to me?
Posted
Updated 17-Jun-17 9:09am
Comments
[no name] 17-Jun-17 7:01am    
Read e.g. this:
[^] and here on CP e.g. this:a Tiny Parser Generator v1.2[^]

1 solution

Here is an interesting project to make writing a parser easier in C#: GitHub - sprache/Sprache: Tiny C# Monadic Parser Framework[^]
Also see this CodeProject article for more information about Sprache: Sprache.Calc: building yet another expression evaluator[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900