Loading ...
Sorry, an error occurred while loading the content.

45535Re: syntax region match with braces

Expand Messages
  • Peter Hodge
    Nov 1, 2006
      --- Виктор Кожухаров <vkojouharov@...> wrote:

      > В ср, 2006-11-01 в 10:53 +1100, Peter Hodge написа:
      > > --- ÐикÑоѬ ÐaожђÑ&аѬов
      > <vkojouharov@...> wrote:
      > >
      > > > Hello,
      > > >
      > > > I'm working on a syntax file for .edc files. The problem before me is
      > > > that I want to use a different syntax file for a "script" part. I've
      > > > created the syntax file for the script syntax, and I've read how yto use
      > > > "syn include".
      > > >
      > > > The real problem is, that in the .edc files, scripts are located within:
      > > > script {
      > > > SCRIPT HERE
      > > > }
      > > > ,however, the scripts themselves can also have {} braces. I've written
      > > > the following, but it only uncludes the script syntax upto the first "}"
      > > > brace, and I have no idea how to make it end on the _matching_ "}" brace
      > > > instead:
      > > >
      > > > -----------------------------------------------------------------------
      > > > syn include @edcEmbryo syntax/embryo.vim
      > > > unlet b:current_syntax
      > > > syn region edcScript start="\<script\>\s*\n*\s*{" end="}"
      > > > contains=@edcEmbryo,edcScriptTag
      > > > syn keyword edcScriptTag contained script
      > > > -----------------------------------------------------------------------
      > > >
      > > > So the question is, if I have:
      > > > script {
      > > > if (foo) {
      > > > bar;
      > > > } else {
      > > > baz;
      > > > }
      > > > }
      > > > how do I make vim use the script syntax all the way up to the closing }
      > > > brace for the "script"?
      > >
      > > Hello,
      > >
      > > Your syntax file 'embryo.vim' will need regions match up all {} pairs as
      > well.
      > >
      > > syn region embryoBraces matchgroup=Delimiter start=/{/ end=/}/
      > transparent
      > >
      > > regards,
      > > Peter
      > >
      >
      > actually, after adding this region, what really happens, is that all the
      > '}' in the script part are of group Delimeter, including the '}' for the
      > 'script {' itself. so, if there's another '}' after that, it becomes of
      > region edcScript (even though logically it's out of the script's scope).
      > There are times however, where a '}' won't follow the script's own
      > closing '}', thus the edcScript region will never end, as I observed in
      > the first case.

      try:

      syn region edcScript matchgroup=edcScriptTag start="\<script\_s*{" end="}"
      keepend contains=@edcEmbryo

      syn region embryoBraces matchgroup=Delimiter start=/{/ end=/}/ transparent
      keepend extend

      I'm not sure if 'transparent' is going to mess things up ... if it does, take
      out 'transparent' and use 'contains=@edcEmbryo'

      regards,
      Peter


      Send instant messages to your online friends http://au.messenger.yahoo.com
    • Show all 9 messages in this topic