当前位置:网站首页>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 ;
边栏推荐
- One click extraction of tables in PDF
- MySQL主從複制、讀寫分離
- Remember a company interview question: merge ordered arrays
- 导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
- CSDN问答模块标题推荐任务(一) —— 基本框架的搭建
- Some notes of MySQL
- JDBC原理
- Remember the interview algorithm of a company: find the number of times a number appears in an ordered array
- 软件测试与质量学习笔记3--白盒测试
- Neo4j installation tutorial
猜你喜欢

Image recognition - pyteseract TesseractNotFoundError: tesseract is not installed or it‘s not in your path
![[recommended by bloggers] background management system of SSM framework (with source code)](/img/7f/a6b7a8663a2e410520df75fed368e2.png)
[recommended by bloggers] background management system of SSM framework (with source code)

MySQL主从复制、读写分离

AI benchmark V5 ranking

Deoldify项目问题——OMP:Error#15:Initializing libiomp5md.dll,but found libiomp5md.dll already initialized.
![[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP](/img/7d/8cbbd2f328a10808319458a96fa5ec.jpg)
[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP

Introduction and use of automatic machine learning framework (flaml, H2O)

Navicat 導出錶生成PDM文件

基于apache-jena的知识问答

机器学习--人口普查数据分析
随机推荐
Detailed reading of stereo r-cnn paper -- Experiment: detailed explanation and result analysis
SSM整合笔记通俗易懂版
Django running error: error loading mysqldb module solution
JDBC principle
虚拟机Ping通主机,主机Ping不通虚拟机
A brief introduction to the microservice technology stack, the introduction and use of Eureka and ribbon
MySQL master-slave replication, read-write separation
安全测试涉及的测试对象
Introduction and use of automatic machine learning framework (flaml, H2O)
QT creator specifies dependencies
Postman uses scripts to modify the values of environment variables
Why is MySQL still slow to query when indexing is used?
01项目需求分析 (点餐系统)
[recommended by bloggers] C WinForm regularly sends email (with source code)
Ansible practical series I_ introduction
AI benchmark V5 ranking
[BMZCTF-pwn] 12-csaw-ctf-2016-quals hungman
Install mysql5.5 and mysql8.0 under windows at the same time
记某公司面试算法题:查找一个有序数组某个数字出现的次数
MySQL other hosts cannot connect to the local database