在点之前阅读 [英] Reading Before A Point

查看:61
本文介绍了在点之前阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我正在学校开办一个如何制作编程语言课程,一位朋友问我这个问题。让我们用我的编程语言来定义变量,你只需输入''string var =Hello World''。我能够做到这一点,但如果我要把代码''var =其他东西'',我怎么能做到这一点。我想到的方法之一是



hey guys,

i am running a ''how to make a programming language'' class at school and a friend asked me this one question. lets say in my programming language, to define a variable, you just put in ''string var = "Hello World"''. I am able to do that, but if i were to put in the code ''var = "Something else"'', how am i able to do this. one of the ways that i thought of doing it is

if (a.Contains("="))
{

}





但问题是,我不知道如何制作它以便它可以之前读取等于符号。你能帮我么?谢谢。



but the thing is, i don''t know how to make it so that it can read before that equals sign. can you please help me? Thanks.

推荐答案

说真的吗?你有很多更大的问题,在等号前阅读,而这个问题的具体解决方案对你的时间来说不是一个好的投资。



查看编写其他编译器,解释器等的方式:大多数使用名为令牌化的过程[< a href =http://en.wikipedia.org/wiki/Tokeniztarget =_ blanktitle =New Window> ^ ]识别输入的各个部分,然后解析令牌用于句法分析。

我认为如果你花了一些时间阅读,在启动代码之前,这可能是一个好主意。这是一个良好的开端: Google:编写编译器 [ ^ ]
Seriously? You have much, much bigger problems coming up that "read before the equals sign", and a specific solution to this one problem would not be a good investment of your time.

Look at the way other compilers, interpreters and so forth are written: most of them use a process called tokenisation[^] to identify the various parts of the input, and then parse the tokens for syntactical analysis.
I think it would probably be a good idea if you spent some time reading, before launching into code. This is a good start: Google: Writing a compiler[^]


这篇关于在点之前阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆