Hi all-
I'm working on a language grammar for Forth, and am hoping I could get some advice or pointers for my work. I've read the TextMate manual, and James Gray's fine book, although I'm sure I haven't extracted every nugget of info from those texts.
As some of you may be aware, Forth is a stateful language, and there are certain keywords that are valid only when Forth is compiling. For example, some words, like IF, THEN and ELSE, can be used only within a word (function) definition.
So it would be nice to capture this in the scope, and assign these compile-only words to an "invalid" scope when they are used outside a function definition. The question is, how to (best) do this?
I've looked at the C language definition a bit, and clearly there are two modes there: "preprocessing", and "not". But with Forth, I should be able to assign an invalid scope to the top-level; in essence, have an invalid scope for source.forth.
Any thoughts?
Best, Charles
On 31 Aug 2008, at 20:46, Charles Turner wrote:
Any thoughts?
The one line restriction on matches can mean you're in for some mind bending, but, do these help?
http://pastie.textmate.org/private/bxpst8dviixlz9szg5r1a http://pastie.textmate.org/private/fww4lukln4nwn0r72h6a
Cheers, Simon
On Sun, 31 Aug 2008 21:23:56 +0100, Simon Gregory wrote:
The one line restriction on matches can mean you're in for some mind bending, but, do these help?
Hey thanks, Simon! I think I'm only interested in flagging keyword use outside word definitions, so the one-line issue may be irrelevant.
Best, Charles
Charles Turner wrote:
So it would be nice to capture this in the scope, and assign these compile-only words to an "invalid" scope when they are used outside a function definition. The question is, how to (best) do this?
Hi Charles. 2 bits of advice.
1. The best way to do this is probably to set up begin/end rules which define the extent of a function definition.
2. If you're having trouble with something specific in making a grammar (or command, etc.), and reading the manual isn't helping, paste what you've got so far to a pastebin (easiest way is ⌃⇧⌥V), and then come into the IRC channel: irc://irc.freenode.net/##textmate and someone can help you sort things out in real time. :-)
-Jacob