小编Ang*_*gie的帖子

从解析器切换Antlr词法分析器模式

如何Antlr从解析器操作中控制切换词法分析器模式?我扩展所产生的解析器和词法所以我可以调用pushModepopMode从解析器巫在合适依次调用pushModepopMode词法分析器的,但没有效果.我有什么办法可以激活这个功能吗?

antlr antlr4

6
推荐指数
1
解决办法
1140
查看次数

c#用子类类型的参数实现接口方法

我有这个所需的类层次结构:

interface IClass
{
    string print(IClass item);
}

class MyClass : IClass
{
    // invalid interface implementation
    // parameter type should be IClass not MyClass
    string print(MyClass item)
    { return item.ToString(); }
}
Run Code Online (Sandbox Code Playgroud)

我尝试通过使用泛型类型解决接口实现问题,但没有成功:

interface IClass
{
    string print<T>(T item) where T : IClass;
}

class MyClass : IClass
{
    string print<T>(T item) where T : MyClass
    { return item.ToString(); }
}
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

c# class-hierarchy

4
推荐指数
2
解决办法
3551
查看次数

如何在Antlr 4/c中控制错误处理和同步#

我正在使用带有c#目标的Antlr 4.这是我的语法的一个子集:

/*
 * Parser Rules
 */
text : term+  EOF;
term : a1 a2 a3;
a1: ....
...
...
Run Code Online (Sandbox Code Playgroud)

我想接受有效数据块作为(term)s,当出现错误时我想搜索下一个有效术语并打印出导致错误的整个文本,供用户手动分析.

如何将输入同步到下一个有效期限?以及如何获取被忽略的文本?

grammar antlr antlr4

2
推荐指数
1
解决办法
4049
查看次数

标签 统计

antlr ×2

antlr4 ×2

c# ×1

class-hierarchy ×1

grammar ×1