c*****t 发帖数: 1879 | 1 This is a long post...
I am trying to update CookCC (a lexer / parser generator in Java) for
a new feature.
One existing CookCC feature is that one can specify the lexer pattern
and parser grammar in Java annotations. For example:
@CookCCOption
class MyParser extends GeneratedParser
{
@Lex (pattern = "[_A-Za-z][_A-Za-z0-9]*", state = "INITIAL")
String scanIdentifier ()
{
return yyText ();
}
@Rules (rules = {
@Rule (lhs = "Expr", rhs = "Expr '+' Expr"),
|
m******t 发帖数: 2416 | 2 I finished reading the long post, but this stuff is so specialized that
the only question I can come up with is - how did you manage the
indentation in these code snippets?
【在 c*****t 的大作中提到】 : This is a long post... : I am trying to update CookCC (a lexer / parser generator in Java) for : a new feature. : One existing CookCC feature is that one can specify the lexer pattern : and parser grammar in Java annotations. For example: : @CookCCOption : class MyParser extends GeneratedParser : { : @Lex (pattern = "[_A-Za-z][_A-Za-z0-9]*", state = "INITIAL") : String scanIdentifier ()
|
A**o 发帖数: 1550 | 3 lol. returned all my compiler knowledge to my teacher already. //blush
【在 m******t 的大作中提到】 : I finished reading the long post, but this stuff is so specialized that : the only question I can come up with is - how did you manage the : indentation in these code snippets?
|
c*****t 发帖数: 1879 | 4 I just typed it in the terminal.
Kinda stuck for the project. |
c*****t 发帖数: 1879 | 5 这个问题并不是在问 compiler 的问题啊。问的是 design 类的问题。
也就是说,有 N 个 interface / impl,因为某个原因,其中的 impl 需要
call 某个 class (generated)的一系列 function (lexer functions),
问的是,如何简单有效的将这些 impl 和该 class 联系起来,尽量减少
impl 得写的部分。
【在 A**o 的大作中提到】 : lol. returned all my compiler knowledge to my teacher already. //blush
|