什么是魔术逃亡(\\)字符背后 [英] What's the Magic Behind Escape(\) Character

查看:143
本文介绍了什么是魔术逃亡(\\)字符背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C / C ++编译器操纵源$ C ​​$ C转义字符[\\]?如何编译器的语法来处理这​​个角色写的?什么是编译器遇到此字符后怎么办?

How does the C/C++ compiler manipulate the escape character ["\"] in source code? How is compiler grammar written for processing that character? What does the compiler do after encountering that character?

推荐答案

大多数编译器分为部分:编译器前端被称为的词法分析器或扫描仪。编译器的这部分读取实际的字符并创建令牌。它有一个状态机,它决定,在看到一个转义字符,是否是正品(例如,当它出现在字符串中),或者修改一个字符。令牌是输出相应的转义字符或其他一些标记(如标签或换行)编译器的下一个部分(解析器)。状态机可以组几个字符到一个令牌。

Most compilers are divided into parts: the compiler front-end is called a lexical analyzer or a scanner. This part of the compiler reads the actual characters and creates tokens. It has a state machine which decides, upon seeing an escape character, whether it is genuine (for example when it appears inside a string) or it modifies the next character. The token is output accordingly as the escape character or some other token (such as a tab or a newline) to the next part of the compiler (the parser). The state machine can group several characters into a token.

这篇关于什么是魔术逃亡(\\)字符背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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