1
假設我有這個代碼的語法文件。如何讓代碼@header和@members在Lexer中不與ANTLR解析器?
// START:members
@header {
using System.Collections.Generic;
}
@members {
public static Dictionary<string, string> memory = new Dictionary<string, string>();
}
ANTLR將代碼放入Parser中,像這樣。
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解析器?