当前位置:网站首页>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 ;
边栏推荐
- 报错解决 —— io.UnsupportedOperation: can‘t do nonzero end-relative seeks
- JDBC principle
- Image recognition - pyteseract TesseractNotFoundError: tesseract is not installed or it‘s not in your path
- 虚拟机Ping通主机,主机Ping不通虚拟机
- 【博主推荐】SSM框架的后台管理系统(附源码)
- Kubernetes - problems and Solutions
- [recommended by bloggers] C MVC list realizes the function of adding, deleting, modifying, checking, importing and exporting curves (with source code)
- 【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
- npm一个错误 npm ERR code ENOENT npm ERR syscall open
- Redis的基础使用
猜你喜欢
Swagger、Yapi接口管理服务_SE
A trip to Macao - > see the world from a non line city to Macao
图片上色项目 —— Deoldify
CSDN markdown editor
One click extraction of tables in PDF
【博主推荐】SSM框架的后台管理系统(附源码)
CSDN question and answer tag skill tree (I) -- Construction of basic framework
Swagger, Yapi interface management service_ SE
[recommended by bloggers] asp Net WebService background data API JSON (with source code)
Django运行报错:Error loading MySQLdb module解决方法
随机推荐
The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
Test objects involved in safety test
Install mysql5.5 and mysql8.0 under windows at the same time
Ansible practical Series III_ Task common commands
數據庫高級學習筆記--SQL語句
@Controller, @service, @repository, @component differences
Principes JDBC
Picture coloring project - deoldify
Some notes of MySQL
Knowledge Q & A based on Apache Jena
Neo4j installation tutorial
[recommended by bloggers] asp Net WebService background data API JSON (with source code)
[C language foundation] 04 judgment and circulation
图片上色项目 —— Deoldify
CSDN question and answer tag skill tree (II) -- effect optimization
In the era of DFI dividends, can TGP become a new benchmark for future DFI?
Install mongdb tutorial and redis tutorial under Windows
[recommended by bloggers] C MVC list realizes the function of adding, deleting, modifying, checking, importing and exporting curves (with source code)
[recommended by bloggers] C WinForm regularly sends email (with source code)
Postman uses scripts to modify the values of environment variables