[TxMt] Re: Composable grammars

fukurokujo fukurokujoe at googlemail.com
Wed Apr 6 20:31:57 UTC 2016


The whole grammar system should really be changed to some BNF, EBNF kinda parser system.
Regex should never be used for grammars.


> On 06 Apr 2016, at 22:14, Jacob Carlborg <doob at me.com> wrote:
> 
> I've been working for quite a while with trying to rewrite the grammar for the D bundle to be more accurate to the official grammar. The grammar for D is quite complex, that in the combination with the syntax for grammars in TextMate doesn't allow any good ways to reuse or compose rules making it very difficult to describe a grammar. I know it's possible to reuse rules with the repository, but that seems to be mostly useful when matching with "begin" and "end".
> 
> For example, this is the grammar for a function declaration from the official D grammar:
> 
> FuncDeclaration:
>    StorageClasses(opt) BasicType FuncDeclarator FunctionBody
>    AutoFuncDeclaration
> 
> AutoFuncDeclaration:
>    StorageClasses Identifier FuncDeclaratorSuffix FunctionBody
> 
> FuncDeclarator:
>    BasicType2(opt) Identifier FuncDeclaratorSuffix
> 
> FuncDeclaratorSuffix:
>    Parameters MemberFunctionAttributes(opt)
>    TemplateParameters Parameters MemberFunctionAttributes(opt) Constraint(opt)
> 
> Each of these parts/rules of the grammar consists of several other rules, many levels deep.
> 
> It would be really nice if the TextMate grammar syntax allowed, somehow, to define rules, or parts of a rule, which the other rules can be composed of, similar to above.
> 
> Or is there a way to already do something similar with the current syntax?
> 
> -- 
> /Jacob Carlborg
> 
> 
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate



More information about the textmate mailing list