Re: [code] Factor lexer for Textadept

From: John Benediktsson <>
Date: Wed, 3 Apr 2013 07:43:43 -0700

> A stack declaration is ( words words words -- words words words ). It may
>> be nested as well. So you could have ( words words ( words -- words ) --
>> words words ). All of the words are optional, incidentally. The only
>> fixed parts are (, ) and --. Those *must* be there.
>> Like Forth, Factor is, indeed, whitespace delimited so ( must have
>> whitespace before and after it as must ) and --. This is what I tried in
>> earlier attempts to leverage, but failed with. I just don't know LPEG well
>> enough yet to figure out even where to begin with this.
Some other ideas:

Can you make a stateful parser, processing tokens and when "(" is seen, go
into "stack effect" mode, looking for ")" and consider if it is a valid
stack effect?

Or maybe a regexp parser, looking for something
like "\(\s+(\S*\s+)*\-\-(\s+\S*)*\s+\)". Highlighting nested stack effects
might require a bit more work, though.

If it is helpful, you can see a FactorLexer[1] in Pygments that is used to
highlight source code on Github.

Or take a look at our VIM syntax file[2], which is fairly complete.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Wed 03 Apr 2013 - 10:43:43 EDT

This archive was generated by hypermail 2.2.0 : Thu 04 Apr 2013 - 06:36:20 EDT