当前位置:网站首页>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 ;
边栏推荐
- Summary of numpy installation problems
- Solution: log4j:warn please initialize the log4j system properly
- 1. Mx6u learning notes (VII): bare metal development (4) -- master frequency and clock configuration
- Why is MySQL still slow to query when indexing is used?
- 35 is not a stumbling block in the career of programmers
- 安装numpy问题总结
- MySQL完全卸载(Windows、Mac、Linux)
- QT creator shape
- Idea import / export settings file
- Number game
猜你喜欢
Postman uses scripts to modify the values of environment variables
QT creator shape
打开浏览器的同时会在主页外同时打开芒果TV,抖音等网站
neo4j安装教程
Copie maître - esclave MySQL, séparation lecture - écriture
Installation and use of MySQL under MySQL 19 Linux
CSDN Q & a tag skill tree (V) -- cloud native skill tree
基于apache-jena的知识问答
windows下同时安装mysql5.5和mysql8.0
[recommended by bloggers] C WinForm regularly sends email (with source code)
随机推荐
Some problems in the development of unity3d upgraded 2020 VR
Leetcode 461 Hamming distance
Knowledge Q & A based on Apache Jena
Navicat 導出錶生成PDM文件
01 project demand analysis (ordering system)
【博主推荐】SSM框架的后台管理系统(附源码)
Did you forget to register or load this tag 报错解决方法
MySQL completely uninstalled (windows, MAC, Linux)
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
Redis的基础使用
MySQL完全卸载(Windows、Mac、Linux)
AcWing 179.阶乘分解 题解
软件测试-面试题分享
Introduction to the easy copy module
MySQL主从复制、读写分离
In the era of DFI dividends, can TGP become a new benchmark for future DFI?
Unable to call numpy in pycharm, with an error modulenotfounderror: no module named 'numpy‘
Solution: log4j:warn please initialize the log4j system properly
The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
Kubesphere - deploy the actual combat with the deployment file (3)