PHP:如何跳过注释? [英] PHP: How are comments skipped?

查看:98
本文介绍了PHP:如何跳过注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,如果我评论的东西,它在所有语言跳过,但他们如何跳过和读什么?

Well if I comment something it's skipped in all languages, but how are they skipped and what is readed?

示例:

// This is commented out

现在PHP读取整个注释去下一行或只读取 //

Now does PHP reads the whole comment to go to next lines or just reads the //?

推荐答案

您的问题没有意义。读取//后,必须继续阅读换行符才能找到它。没有选择。

Your question doesn't make sense. Having read the '//', it then has to keep reading to the newline to find it. There's no choice about this. There is no other way to find the newline.

从概念上讲,编译有几个阶段,逻辑上在解析之前:

Conceptually, compiling has several phases that are logically prior to parsing:




  1. b $ b

(1)基本上意味着从左到右逐个字符读取文件。
(2)意味着抛弃没有兴趣的东西,例如。将多个换行/空白序列折叠到单个空间。
(3)表示将剩下的内容组合到令牌中,例如。标识符,关键字,文字,标点符号。

(1) basically means reading the file character by character from left to right. (2) means throwing things away of no interest, e.g. collapsing multiple newline/whitespace sequences to a single space. (3) means combining what's left into tokens, e.g. identifiers, keywords, literals, punctuation.

在(2)期间屏蔽了评论。在现代编译器中,这一切都由确定性自动机一次完成。

Comments are screened out during (2). In modern compilers this is all done at once by a deterministic automaton.

这篇关于PHP:如何跳过注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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