📜  代币和终端的区别

📅  最后修改于: 2022-05-13 01:57:02.895000             🧑  作者: Mango

代币和终端的区别

令牌和终端是相似的词,经常互换使用。但是这两个术语之间存在概念上的差异,本文讨论了这些差异。

代币

标记是字母数字字符。它是编程语言中最小的语法单位。当我们向词法分析器提供输入时,它会读取字符并将它们转换为标记,然后再进行进一步的编译阶段。标记分为多种类型:关键字、运算符、字符串、常量、特殊字符和标识符。示例:A、@、b、(、) 等。

终端

终结符是出现在产生式规则右侧的符号,不能使用语法规则进行更改。终端符号基本上是一组标记,基本上是生成字符串的字符。它们基本上用小写字母表示。示例 a、b、c 等。

代币和终端的区别

S.NoTokenTerminal
1.Tokens are a set of strings used in a programming language. Terminals are a set of characters used in production rules. 
2.The compiler breaks a program into the smallest units known as tokens which are passed through various stages of the compiler. Symbols or tokens are called terminals when they are used in formal languages.
3.Tokens can be written in upper case letters. Terminals are written only in lower case letters. 
4.It can have letters, numbers, and special characters. It has only alphabets. 
5.They are generated by a lexical analyzer. They are defined by formal languages. 
6.Tokens are used to describe the corresponding characters in the source. Terminals are used to describe the working of the parser that is with which it is working. 
7.Examples are A, @, b, (, ), etcExamples are a, b, c, d, etc.