Michael Coupland wrote:
root: letter* EOF;

No exceptions in C so that top rule can only set flags.
    

That change to the grammar works great, thanks! For reference, what
would I want to look at if I wanted to deduce what portion of the
input data the parser had consumed?
  
Well, the EOF forces the parse to progress to the EOF 'token', so the parser will look at everything, perform recovery resync and go on until it sees the EOF, when it will finally breathe a sigh of relief ;-). You override the error display (or a function earlier in that stack) and collect the errors in a form that you can then use after parsing. Generally, you don't print errors as they occur but collect them in a log/buffer/collection/kitchen sink and then decide where they should go after the parse is complete (I.E send to IDE, print to screen, email them and so on).

Maybe, but as free is a function in every C runtime that I know of,
#defining it in a system header file would break a lot more than the
ANTLR runtime. Which system are you thinking of that #defines free? The
trade off is the use of an intuitive method name vs something like
'release' or 'close'.
    

It's definitely a rarity, and something that you have to be very
careful about, but many performance-sensitive codebases do ugly/sneaky
things to hijack control of memory allocations throughout the system.
I know of at least one high-profile commercial game engine that
#defines free to be something else, and the MySQL SDK does this as
well. I understand the argument for intuitive names, but wouldn't
something like freeObject be equally intuitive, and less likely to
collide?
  
Yeah - I think that one would just need to #undef free though to be honest. I don't think that system headers ever override free, only SDKs, so you know when and where to cope. Antlr does not use free, it uses ANTLR3_FREE/MALLOC/CALLOC, so that you can predefine that and build the runtime on systems that need something different. Really, SDKs should do the same thing.

  
The docs at: http://antlr.org/api/C/index.html document
displayRecognitionError which, just like in Java, is what you must
override to implement your own error display.
    

Ok, thanks. I had noticed displayRecognitionError, but wanted to make
sure there wasn't some other error-handling mechanism that I needed to
worry about as well.
  
No. The advantage and disadvantage of the C runtime is that it is pretty raw of course and you tend to have to know a bit more about the internals than with the other targets (though not tons more). The Java and C# versions are great and in fact I always protoype with one or the other of these, but performance is an issue so tangling with the C is worth it in the end if you need the speed.

For instance, my T-SQL parser has 1100 regression tests and the timings for parsing these and walking the tree look like this:

C

jimi(50_64)-clean: time tsqlc . >out
0.19user 0.15system 0:00.34elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
8inputs+232outputs (0major+102770minor)pagefaults 0swaps

Java

jimi(50_64)-clean: time tsql2005j . >out
2.33user 0.08system 0:02.05elapsed 117%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+456outputs (0major+29634minor)pagefaults 0swaps


I think it would be helpful if there were a brief mention of this
function on the front page of the C API - something as simple as "If
you want to hook a custom error handler, override
<link>displayRecognitionError</link>." (There is no instance of the
string "error" on that main page, which was the first thing I tried
searching for...)
  
Hmm - that is supposed to be one of the first things in the "Using the C runtime" page. I will check that out.
(Also, as an aisde, the link to "displayRecognitionError" on
http://antlr.org/api/C/antlr3exception_8h.html appears broken.)
  
I'll look at it. It looks like the process of copying the doxygen stuff to the web site has thrown out relative links somehow.

  
It is download rather than downloads. From hudson just click on the
project. The first thing that comes up is a list of source code
artifacts that you can download???

http://antlr.org/hudson/job/ANTLR%20C%20Runtime/
    

http://antlr.org/download looks very useful! Is there a link to this
page from the main ANTLR webpage? Most download links seem to point to
http://antlr.org/download.html , which is different...

For the C Runtime, yes, it's pretty easy to find the download in
Hudson, but I didn't know where to go in Hudson to get the specific
file you mentioned in the other email (
antlr-master-3.1.4-SNAPSHOT-completejar.jar )  - it's not 100% clear
which Hudson job it would belong to (probably ANTLR_Tool, though), and
there don't appear to be any downloadable artifacts at
http://antlr.org/hudson/job/ANTLR_Tool/
  
I see what you are saying. You need to take the "Module Builds" link from the last successful build page:

http://antlr.org/hudson/job/ANTLR_Tool/lastSuccessfulBuild/

Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to