当前位置:网站首页>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 ;
边栏推荐
- Deoldify project problem - omp:error 15:initializing libiomp5md dll,but found libiomp5md. dll already initialized.
- [ahoi2009]chess Chinese chess - combination number optimization shape pressure DP
- 引入了junit为什么还是用不了@Test注解
- Development of C language standard
- 解决:log4j:WARN Please initialize the log4j system properly.
- Software testing - interview question sharing
- 【博主推荐】C# Winform定时发送邮箱(附源码)
- neo4j安装教程
- CSDN Q & a tag skill tree (V) -- cloud native skill tree
- SSM整合笔记通俗易懂版
猜你喜欢

CSDN Q & a tag skill tree (V) -- cloud native skill tree

IDEA 导入导出 settings 设置文件

QT creator shape

Summary of numpy installation problems

【博主推荐】C# Winform定时发送邮箱(附源码)

1. Mx6u learning notes (VII): bare metal development (4) -- master frequency and clock configuration

Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'

基于apache-jena的知识问答

Windows cannot start the MySQL service (located on the local computer) error 1067 the process terminated unexpectedly

QT creator create button
随机推荐
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
La table d'exportation Navicat génère un fichier PDM
There are three iPhone se 2022 models in the Eurasian Economic Commission database
报错解决 —— io.UnsupportedOperation: can‘t do nonzero end-relative seeks
Software testing and quality learning notes 3 -- white box testing
Invalid default value for 'create appears when importing SQL_ Time 'error reporting solution
虚拟机Ping通主机,主机Ping不通虚拟机
JDBC原理
@controller,@service,@repository,@component区别
【博主推荐】C# Winform定时发送邮箱(附源码)
Ansible practical series I_ introduction
Neo4j installation tutorial
35 is not a stumbling block in the career of programmers
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
01 project demand analysis (ordering system)
Ansible practical Series II_ Getting started with Playbook
MySQL completely uninstalled (windows, MAC, Linux)
MySQL other hosts cannot connect to the local database
【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
Machine learning -- census data analysis