⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.g

📁 SRI international 发布的OAA框架软件
💻 G
字号:
/* This is test.g which tests a simple DLG-based scanner
 * with user-defined tokens
 */

/* Here, we use #tokdefs to define token types, but still let DLG do the
 * lexing. ANTLR will not create a tokens.h file.
 */
#tokdefs "mytokens.h"

<<
#include "DLGLexer.h"		/* include definition of DLGLexer.
							 * This cannot be generated automatically because
							 * ANTLR has no idea what you will call this file
							 * with the DLG command-line options.
							 */

typedef ANTLRCommonToken ANTLRToken;

int main()
{
	ANTLRTokenPtr aToken = new ANTLRToken;
	DLGFileInput in(stdin);
	DLGLexer scan(&in);
	ANTLRTokenBuffer pipe(&scan);
	scan.setToken(mytoken(aToken));
	Expr parser(&pipe);
	parser.init();

	parser.e();
	return 0;
}
>>

#token "[\ \t\n]+"	<<skip();>>

class Expr {				/* Define a grammar class */

e	:	IDENTIFIER NUMBER "@"
		<<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
	;

}

#token IDENTIFIER	"[a-z]+"
#token NUMBER		"[0-9]+"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -