本文介绍了为脚本创建解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解如何使用BNF使用书面语法解析输入字符串。



我尝试过:



您好,我是小狗,并且最近用词法分析器构建了一个简单的脚本语言。

我正考虑制作一个为它解析,但我的尝试让我头晕目眩。让我告诉你一个关于我自己的脚本的想法的完整故事...



1.用词法分析代码分析单词。

ex)var a = 1,b = 1,cc = a + b print c=> var\\ = = \\\\b\ = \\\\c\c\ = \\\\ + + \\\\\\\\\ >


2.使用BNF或其他东西构建一个简单脚本的语法......



但是我遇到了第二号墙上搜索了很多关于BNF的文章

认为这对成功两个来说很酷和

最后我理解了BNF。这是一种描述语法的方法。



然而我被三号墙再次击中

这是如何解析一个使用BNF输入带有书面语法的字符串



有没有人可以向我解释这个?

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?

推荐答案

这篇关于为脚本创建解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 21:23