当前位置:网站首页>Antlr4 uses keywords as identifiers
Antlr4 uses keywords as identifiers
2022-07-06 11:15:00 【Antivirus Alchemist】
When defining lexical files , You need to define keywords first , Rules for redefining identifiers , For example, the following example
// Match keyword CREATE
K_CREATE: 'CREATE' ;
// Match identifier -- A string of alphanumeric underscores , But it must start with a letter or an underscore
ID: [a-zA-Z_]+[a-zA-Z0-9_]* ;
In the grammar file , We define the syntax of a variable name , The variable name rule is the identifier
varName: ID ;
There's a problem : When using "CREATE" As varName Time cannot be recognized , Although it satisfies morphology "ID" The rules of , as a result of "CREATE" It is recognized as morphology "K_CREATE"
How to use keywords as identifiers
Just add the keywords you need to use under the corresponding rules , as follows
varName: ID | K_CREATE ;
边栏推荐
- Swagger, Yapi interface management service_ SE
- Kubesphere - deploy the actual combat with the deployment file (3)
- TCP/IP协议(UDP)
- Navicat 導出錶生成PDM文件
- CSDN question and answer module Title Recommendation task (I) -- Construction of basic framework
- The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
- Install mysql5.5 and mysql8.0 under windows at the same time
- 项目实战-后台员工信息管理(增删改查登录与退出)
- Windows下安装MongDB教程、Redis教程
- 软件测试与质量学习笔记3--白盒测试
猜你喜欢
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
[free setup] asp Net online course selection system design and Implementation (source code +lunwen)
Did you forget to register or load this tag
Csdn-nlp: difficulty level classification of blog posts based on skill tree and weak supervised learning (I)
Windows cannot start the MySQL service (located on the local computer) error 1067 the process terminated unexpectedly
IDEA 导入导出 settings 设置文件
CSDN markdown editor
Generate PDM file from Navicat export table
When you open the browser, you will also open mango TV, Tiktok and other websites outside the home page
Machine learning -- census data analysis
随机推荐
Swagger、Yapi接口管理服务_SE
FRP intranet penetration
frp内网穿透那些事
Ansible实战系列二 _ Playbook入门
@controller,@service,@repository,@component区别
Use dapr to shorten software development cycle and improve production efficiency
Introduction and use of automatic machine learning framework (flaml, H2O)
@Controller, @service, @repository, @component differences
Software testing and quality learning notes 3 -- white box testing
解决:log4j:WARN Please initialize the log4j system properly.
35 is not a stumbling block in the career of programmers
SSM integrated notes easy to understand version
Django运行报错:Error loading MySQLdb module解决方法
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
Mysql 其他主机无法连接本地数据库
02 staff information management after the actual project
NPM an error NPM err code enoent NPM err syscall open
数据库高级学习笔记--SQL语句
【博主推荐】asp.net WebService 后台数据API JSON(附源码)