一个简单的ANTLR 3.4示例,用于C目标运行时
A simple ANTLR 3.4 example for C target runtime
是否有人知道(或有)一个简单的ANTLR 3.4示例main()
函数的C目标?我正在尝试用C或c++开始使用ANTLR,我看到的所有例子(包括这个)都过时了,例如,它们使用的函数不再存在。似乎没有下载包本身的任何示例,Wiki上的示例已经过时了。
未经测试
#include "YourLexer.h"
#include "YourParser.h"
int main()
{
uint8_t * bufferData; // Some memory with text in it
uint32_t bufferSize; // Size of said memory
pANTLR3_UINT8 bufferName; // Name of buffer. ANTLR uses this for some default
// error messages
//Creates an input stream. If you want to parse once from multiple sources
// you can switch among these during lexing
pANTLR3_INPUT_STREAM input = antlr3StringStreamNew(
bufferData,
ANTLR3_ENC_8BIT,
bufferSize,
bufferName);
assert(input != NULL);
//Creates the lexer. Doesn't do anything until the parser(or you) tells it to.
pYourLexer lxr = YourLexerNew(input);
assert(lxr != NULL);
//Creates an empty token stream.
pANTLR3_COMMON_TOKEN_STREAM tstream = antlr3CommonTokenStreamSourceNew(
ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
assert(tstream != NULL);
//Creates a parser.
pYourParser psr = YourParserNew(tstream);
assert(psr != NULL);
//Run the parser rule. This also runs the lexer to create the token stream.
psr->some_parser_rule(psr);
}
相关文章:
- 适用于 WebView2 旧版本的示例应用程序
- Windows Toast 通知不适用于 MS CPP 示例代码
- 表达式模板玩具示例:用户定义的强制转换不适用于复杂类型
- 张量流错误:执行器无法创建内核。没有注册'Snapshot' 适用于 GPU 设备的 OpKernel 运行图像标签示例
- 需要用于Windows的Box2D DebugDraw示例
- C ++ simpleini 示例,用于从目录中获取 ini 文件
- MSDN示例中缺少用于GDI打印的文件
- std::erase 和 std::remove 组合以删除特定元素不适用于特定示例
- pocketsphinx的简单示例适用于基本的c测试,但不适用于包含在c++项目中的情况
- 尝试使用书中的最小生成树示例,但它不适用于大数据
- 生产者和使用者函数,用于在操作手册中测试C++并发的线程安全堆栈示例
- 用于并行计算的C++代码优化示例
- leveldb示例不适用于windows:错误LNK2029
- 用于对哈希进行签名并验证哈希签名不起作用的 MSDN C 示例程序
- 一个简单的ANTLR 3.4示例,用于C目标运行时
- 使用MFC编辑控件中的块字符(仅用于浮动的示例)
- 用于处理大数组的虚拟内存示例
- 用于c++应用程序的HTTPS客户端示例
- 二叉树的示例实现不适用于大量值
- 寻找在c#中创建c++ DLL然后P/Invoke的代码示例(适用于Windows CE 5/6)