如何匹配 ANTLR 解析器(不是词法分析器)中的任何符号?

编程入门 行业动态 更新时间:2024-10-14 02:18:52
本文介绍了如何匹配 ANTLR 解析器(不是词法分析器)中的任何符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如何匹配 ANTLR 解析器(不是词法分析器)中的任何符号?ANTLR4 解析器的完整语言描述在哪里?

How to match any symbol in ANTLR parser (not lexer)? Where is the complete language description for ANTLR4 parsers?

更新

答案是不可能"吗?

推荐答案

首先需要了解每个部分在解析中的作用:

You first need to understand the roles of each part in parsing:

词法分析器:这是标记输入字符串的对象.标记化意味着将输入字符流转换为抽象标记符号(通常只是一个数字).

The lexer: this is the object that tokenizes your input string. Tokenizing means to convert a stream of input characters to an abstract token symbol (usually just a number).

解析器:这是仅与标记一起工作以确定语言结构的对象.一种语言(编写为一个或多个语法文件)定义了有效的标记组合.

The parser: this is the object that only works with tokens to determine the structure of a language. A language (written as one or more grammar files) defines the token combinations that are valid.

如您所见,解析器甚至不知道字母是什么.它只知道令牌.所以你的问题已经错了.

As you can see, the parser doesn't even know what a letter is. It only knows tokens. So your question is already wrong.

话虽如此,了解为什么要在解析器中跳过单个输入字母可能会有所帮助.看起来您的基本概念需要调整.

Having said that it would probably help to know why you want to skip individual input letters in your parser. Looks like your base concept needs adjustments.

这篇关于如何匹配 ANTLR 解析器(不是词法分析器)中的任何符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-20 07:24:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/980019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词法   分析器   符号   ANTLR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!