JavaCC How to limit one-time occurrence clause
来源:互联网 发布:java常用的类选择器 编辑:程序博客网 时间:2024/06/02 04:18
How to support a set of clause whose orderis meaningless, but each can only be specified once. For example, non-terminalP() may contain 3 sub-clause( A(), B(), C()), but each can only occur one time, so followingare valid input:
- C
- B C
- A B C
- C A B
And following are invalue
- A A //A is specified twice
- C B C //C is specified twice
JavaCC grammar
P() : {}
{
(A() B() C() )?
}
This grammar will support only one clause A(),B(), or C(), but will not their combination.
P() : {}
{
(A() B() C() )+
}
This grammar will support any combinationof A(), B(), or C(), no onetime only limitation.
It seems grammar itself cannot have this limitation;however, we can use user-action to support this limitation; following grammarhas been reconstructed:
void P() :
{
SimpleNode[]ABCClause = new SimpleNode[3];
}
{
A()
{
if (ABCClause[0] != null)
throw new Exception("A() specified more than one");
ABCClause[0] = value;
}
| B()
{
if (ABCClause[1] != null)
throw new Exception("B() specified more than one");
ABCClause[1] = value;
}
| C()
{
if (ABCClause[2] != null)
throw new Exception("C() specified more than one");
ABCClause[2] = value;
}
}
- JavaCC How to limit one-time occurrence clause
- how to print the spend time of one function
- Title: How to limit instantialization?
- PostgreSQL / GIST index require "LIMIT" clause to trigger the index.
- How to use time...
- JavaCC How to access non-terminal's TOKEN child
- Limit the current thread to one processor
- How to increase MySQL memory limit?
- How to modify linux time
- How to create more time?
- How to define One-Many and One-One relationships
- How to limit an array of similar hashes to those that have more than one of the same key:value pair
- how to convert UTC to local time
- One way to improve running time
- another one: how to do research?
- FFMPEG -- How to add one new CODEC
- How to test only one benchmark function?
- Occurrence
- LCA详解
- IOS - Property list
- JSTL之格式化标签<fmt:formatDate>
- 最小生成树(prim和kruskal)
- MySQL 初级助记笔记和标准文档里不会说到的但是也可以用的不规范用法
- JavaCC How to limit one-time occurrence clause
- 数独游戏(leetcode) dfs 回溯
- Android学习——AutoCompleteTextView组件
- 从VB6进阶到PowerBASIC的快速指引
- 谈谈Activity
- 60款很酷的 jQuery 幻灯片演示和下载【转】
- ansible 配置 linux 主机ssh免密访问
- TF-IDF与余弦相似性的应用(一):自动提取关键词
- DB2数据库补丁升级 FixPacks