void getline(char* line)
{ int n=0;
while((line[n]=getchar()) != '\n')
{ n++; }
line[n]=0;
}
You shouldn't use broken code examples.
parse ws
[ anychar[] Wo
anyindex an
-> Wo Wo[ Wo[an]==' ' || Wo[an]=='\t' || Wo[an]=='\n' ]
[ return true; ]
]
This is _extremely_ verbose for something that just parses whitespace. I'm pretty sure that's simpler to do in other parser generators, and more readable. For example, with ANTLR (and I might be buggy here, I haven't seen ANTLR myself except on IRC channels), you would just see something like
WS : (' '|'\t'|'\f'|'\n'|'\r')+ { $channel=HIDDEN; };
For a parser combinator library like Parsec, it would just be
ws = skipMany1 (satisfy isSpace)
Last edited by Rashakil Fol; Dec 14th, 2008 at 7:32 pm.