[antlr-interest] Re: C++ input
kordeul
tom_kra at hotmail.com
Thu Mar 21 02:00:54 PST 2002
Thanks
BCB has all stram support. As I mentioned in my other reply, it
seems there's some other problem, since the VC works!
BR Tom
--- In antlr-interest at y..., Ric Klaren <klaren at c...> wrote:
> On Thu, Mar 21, 2002 at 09:31:04AM -0000, kordeul wrote:
> > I use version 2.7.1 of ANTLR and there's no main2.cpp in the
> > cpp/calc example. Can you write the actual code?
>
> As I said in the 2.7.2a1 distribution but anyway..
>
> It's stripped from all the fluff (error handling, namespace stuff
and some
> other details)
>
> int main( int argc, char*argv[] )
> {
> // write the argv strings to a ostringstream...
> ostringstream expr;
> for( int i = 1; i < argc; i++ )
> {
> if( i > 1 && i != (argc-1))
> expr << ' ';
> expr << argv[i];
> }
>
> istringstream input(expr.str()); // prepare istringstream
with input
> CalcLexer lexer(input);
> CalcParser parser(lexer);
> parser.expr();
> }
>
> With a file:
>
> ifstream input("somefile.txt");
>
> And then use Lexer and parser as above.
>
> > Also I forgot to mention: I use Borland C++ Builder 5 if this
> > changes something.
>
> Dunno if C++ builder has istringstream support if not you'd better
search
> the archives for the CharInputBuffer stuff.
>
> Ric
> --
> -----
+++++*****************************************************+++++++++--
-----
> ---- Ric Klaren ----- klaren at c... ----- +31 53 4893722 ----
> -----
+++++*****************************************************+++++++++--
-----
> Wit is cultured insolence. --- Aristotle
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list