[英]How do I make the code @header and @members be in Lexer not Parser with ANTLR?
假設我有一個包含此代碼的語法文件。
// START:members
@header {
using System.Collections.Generic;
}
@members {
public static Dictionary<string, string> memory = new Dictionary<string, string>();
}
ANTLR這樣將代碼放入解析器中。
public partial class Eval : TreeParser
{
...
/** Map variable name to Integer object holding value */
//HashMap memory = new HashMap();
Dictionary<string, int> memory = new Dictionary<string, int>();
有沒有辦法將代碼放在Lexer中而不是使用ANTLR的Parser中?
@header
和@members
是@parser::header
和@parser::members
。
要將代碼放入lexer中,請執行: @lexer::header
和@lexer::members
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.