Where is the TextMate Language Parser? - textmate

Does anyone know where the code TextMate uses for syntax highlighting is burried? If not, do you know how they parse their language syntaxes, or how you would parse their language syntaxes?
That would be awesome to look into.
Thanks!
Lance

I believe TextMate uses Antlr for parsing. Look for it inside the package. Antlr has an Objective-C target, but this doesn't mean that Allen Odgaard chose that particular language, but it is highly likely, given that TextMate is a Cocoa application.
Terrence Parr, the creator of Antlr, has written two books on/using Antlr:
The Definitive Antlr Reference
Language Implementation Patterns
Both are worth reading if you are interested in parsing, etc.... Of course, one should eventually move on to the dragon book,, but these books, along with Antlr, will allow you to get moving quickly.

Related

Is there nice yaml documentation documenting most of functionality, written without yaml?

Official and most of yaml documentation is written in yaml itself. That is nice demonstration of language power. I get it, that's the main point of this documentation. But documenting language by using that yet unknown language is like solving puzzle. At least for me. Searching in this style of documentation really hard: "which operators can I use for string indentation?" In traditional documentating style one would use chapter say "string indentation". But here, while it's a nice demo, you need to read it all, and understand it all, which is extra subpar if you don't work with yaml daily. And yaml language spec is great, if you want to practice context (free?) grammar definition, but greatly unfit for quick search for basic questions.
My question is. Is there yaml documentation, using traditional structure, documenting most of features, not just very few? One html page, sections and paragraphs? I cannot find one, and I'm always struggling/wasting so much time trying to find something in this style of documentation. And every time I read anything, I feel I'm missing so much information, which is not shown, constantly learning X using not yet explained constructs.

Lazarus coding style guide

Style Guide?
Other than http://wiki.freepascal.org/Coding_style is there a style guide that represents the style followed by a notable and large body of work in Lazarus ( and/or FPC and/or Delphi) or some sort of widespread concensus.
Example
I'm looking for things that say something such as
Names of literal constants should be in all uppercase.
Names of variables should use camelCase with initial lowercase
Indent a begin on the line after an if
The above is just an example. I'm aware of well-supported conventions in languages like Java and Perl but not of a predominant convention for programs written using Lazarus or Delphi.
Purpose
My intent is
Try to adopt a common style for all the code I write
Have this style not be too much of a surprise for the majority of programmers who might one day read it.
I'm not working in a business that has established standards.
As a good detailed style guide I'm considering the Object Pascal Style Guide by Charles Calvert. It's for Object Pascal which the Free Pascal is a child of. In fact, most of the FPC units respect the rules mentioned there.
This article documents a standard style for formatting Delphi code. It is based on the conventions developed by the Delphi team.
You will probably yield the most info on this subject with the search term "delphi coding conventions" or something. These are very loose standards that are not enforced but can be very helpful to keep your code readable. Delphi and Lazarus are very interchangeable. Same would apply with Delphi as Lazarus in this regard. Much more info on Delphi.Old Delphi books are a great resource even.

How to understand scripting language like Ruby from a C/C++/VBNET programmer perspective?

I have been C/C++/VBNET programmer for a long time. Now Ruby advanced concept is attracting me. So I decided to learn how to use it.But the "Behavior" of Ruby used to confused me. I usually feel like can't completely control my Ruby program.
Can you help me get clearly about this ?
(Maybe some of your favorite guide about "Ideas" and "Styles" in Ruby may help >:D< . Thank)
Ruby is quite an unusual programming language if you are more used to static/declarative style languages like C/C++.
I suspect it's the highly dynamic nature of the language which is causing you a problem, it can be difficult to get your head around this when you encounter it for the first time after having used only the more static languages. Ideas like Duck Typing can seem weird if you are used to declaring variables as strict types before use.
I would thoroughly recommend working your way through one of the excellent books about ruby that are out there. Don't just mess around writing code without really understanding the concepts.
Personally I really liked "The Ruby Programming Language" from O'Reilly, but I have experiance of a lot of different languages so I'm used to some of the more dynamic features in Ruby.
However you may prefer to start with something less terse such as Dave Thomas' "Programming Ruby" (make sure you get the 1.9 version).
Work through one of these books, do the examples, play around with the code. That way you will get a thorough understanding of the language.
Best of luck. Once you get your head around it, Ruby can be a very powerful language.
I think that the book Design Patterns in Ruby might help you. The first chapter describes the syntax of Ruby (which I guess that you won't need), but the rest of the book goes through the classic design patterns and shows you a Ruby way of approaching them. It's very clearly written and I learned a lot about Ruby idioms from it.
If you can talk to a Rubyist then that will probably help a lot - from experience, a code review or pairing session with someone else can get you over mental blocks better than anything else. If you don't know anyone, try writing some code then post a link to it to the Ruby Talk mailing list with questions. This is a very friendly community, and people are happy to help.
I recommend reading Why's Poignant Guide to Ruby. It will open your mind to the wonders of working in a dynamic language. Or it will piss you off with its cartoons of talking foxes. Either way it will change your thinking about Ruby :)

Which is the best counterpart to ANTLR to create parsers in ruby?

I've used antlr and javacc/freecc for a while.
Now I need to write a bunch of parsers using antlr grammars but such parsers need to be written in ruby lang.
I googled but nothing found. Is there any ruby parser generator that takes antlr grammars and create a parser? If there are many, which is the best one in your opinion?
TIA
Paolo
You might get away easy by using JRuby and keeping your ANTLR parsers in java.
If PEGs are enough for your job, treetop and the newer citrus are common tools used by rubyists.
Other parsers I dug while researching for a project are: peggy, Kanocc, Racc.
For my project I chosed treetop (citrus was not born yet).
Why not to use ANTLR Ruby: http://www.antlr.org/wiki/display/ANTLR3/Antlr3RubyTarget (http://split-s.blogspot.com/2005/12/antlr-for-ruby.html)
There is also some beta here: http://rubyforge.org/projects/antlr3/
You could also generate the parser with ANTLR for Java or C and call it from your Ruby program with JRuby or FFI.
This should also give you a performance boost which might be a big advantage if you have a lot of input to parse.

Bison (and flex) coding conventions

What are coding conventions and guidelines you suggest for writing Bison (.y) and flex (.lex) files?
Please address the length of the code sections and their style.
Thanks,
Asaf
P.S.,
There's an old thread about it here, but I'm looking for a more detailed answer (and to have it on SO!).
For questions like this in general I would typically see what other people have done. Good resources for this are Google Code Search and Koders. Both support searching by a specific programming language; however it appears that only Google has lex as a listed language.
Other than that, I generally try to keep to either 79 or 96 columns in source code, to make sure I can view at least 2 windows-worth of code side by side.

Resources