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

Indent Mode Question

Expand Messages
  • cp200205
    I am creating a mode for the programming language Icon. In it, you can do: if 1 = 1 then write( Good ) else write( Bad ) write( All done with if ) or if 1 =1
    Message 1 of 6 , Nov 27, 2006
    • 0 Attachment
      I am creating a mode for the programming language Icon. In it, you can do:

      if 1 = 1 then write("Good") else write("Bad")
      write("All done with if")

      or

      if 1 =1 then {
      write("Good")
      } else {
      write("bad")
      }
      write("All done with if")

      Now, those two I can handle just fine. The following is what I don't know how to handle:

      if 1 =1 then
      write("Good")
      else
      write("Bad")
      write("All done with if")

      See on the last how only the next line is indented? Nothing more after that?

      Any help would be appriciated,

      Jeremy
    • jon@jasspa.com
      ... This is exactly what the problem is with the current indent mechanism. Unfortunately there is not a known work around when a language does not include a
      Message 2 of 6 , Nov 27, 2006
      • 0 Attachment
        > I am creating a mode for the programming language Icon. In it, you can do:
        >
        > if 1 = 1 then write("Good") else write("Bad")
        > write("All done with if")
        >
        > or
        >
        > if 1 =1 then {
        > write("Good")
        > } else {
        > write("bad")
        > }
        > write("All done with if")
        >
        > Now, those two I can handle just fine. The following is what I don't know
        > how to handle:
        >
        > if 1 =1 then
        > write("Good")
        > else
        > write("Bad")
        > write("All done with if")
        >
        > See on the last how only the next line is indented? Nothing more after
        > that?
        >
        > Any help would be appriciated,
        >
        > Jeremy
        >

        This is exactly what the problem is with the current indent mechanism.
        Unfortunately there is not a known work around when a language does not
        include a closing token (this is actually why 'c' mode is burnt into the
        editor and is not implemented with indent tokens).

        You could take a look at the hkjava.emf. Bryan created a 'indent' only
        indentation scheme rather than basing it on c-mode. I do not think that it
        handles the case you cite above.

        To handle the if/then stuff then you could try using multiple indent
        schemes, but you would have to use \n as a closing token (i.e. end of
        line).

        To be honest I do not think you will be able to do it - specifically
        because of dangling else's which are difficult to handle.

        We have been looking at the indent mechanism with a view to fixing this
        very problem. I think you will have to use a regular indent. If the syntax
        of the language allowed terminating ';' then you could have probably used
        cmode with some tweaks.

        Sorry.
        Jon.
      • Bryan Schofield
        I don t know Icon syntax, but could have indent look for if and else on a line by itself as a continue rule as well as {} brace rule? indent
        Message 3 of 6 , Nov 27, 2006
        • 0 Attachment
          I don't know Icon syntax, but could have indent look for "if" and
          "else" on a line by itself as a "continue" rule as well as "{}" brace
          rule?

          indent .hilight.icon n "{" t
          indent .hilight.icon o "}" -t
          indent .hilight.icon c "^\\s*else\\s*$" t
          indent .hilight.icon c "^\\s*if\\s*$" t

          Just a thought...
          -- bryan

          On 11/27/06, jon@... <jon@...> wrote:
          > > I am creating a mode for the programming language Icon. In it, you can do:
          > >
          > > if 1 = 1 then write("Good") else write("Bad")
          > > write("All done with if")
          > >
          > > or
          > >
          > > if 1 =1 then {
          > > write("Good")
          > > } else {
          > > write("bad")
          > > }
          > > write("All done with if")
          > >
          > > Now, those two I can handle just fine. The following is what I don't know
          > > how to handle:
          > >
          > > if 1 =1 then
          > > write("Good")
          > > else
          > > write("Bad")
          > > write("All done with if")
          > >
          > > See on the last how only the next line is indented? Nothing more after
          > > that?
          > >
          > > Any help would be appriciated,
          > >
          > > Jeremy
          > >
          >
          > This is exactly what the problem is with the current indent mechanism.
          > Unfortunately there is not a known work around when a language does not
          > include a closing token (this is actually why 'c' mode is burnt into the
          > editor and is not implemented with indent tokens).
          >
          > You could take a look at the hkjava.emf. Bryan created a 'indent' only
          > indentation scheme rather than basing it on c-mode. I do not think that it
          > handles the case you cite above.
          >
          > To handle the if/then stuff then you could try using multiple indent
          > schemes, but you would have to use \n as a closing token (i.e. end of
          > line).
          >
          > To be honest I do not think you will be able to do it - specifically
          > because of dangling else's which are difficult to handle.
          >
          > We have been looking at the indent mechanism with a view to fixing this
          > very problem. I think you will have to use a regular indent. If the syntax
          > of the language allowed terminating ';' then you could have probably used
          > cmode with some tweaks.
          >
          > Sorry.
          > Jon.
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > __________________________________________________________________________
          >
          > This is an unmoderated list. JASSPA is not responsible for the content of
          > any material posted to this list.
          >
          > To unsubscribe, send a mail message to
          >
          > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > or visit http://groups.yahoo.com/group/jasspa and
          > modify your account settings manually.
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
        • Jeremy Cowgar
          That works great. Thanks! Jeremy
          Message 4 of 6 , Nov 27, 2006
          • 0 Attachment
            That works great. Thanks!

            Jeremy

            On Nov 27, 2006, at 9:46 AM, Bryan Schofield wrote:

            > I don't know Icon syntax, but could have indent look for "if" and
            > "else" on a line by itself as a "continue" rule as well as "{}" brace
            > rule?
            >
            > indent .hilight.icon n "{" t
            > indent .hilight.icon o "}" -t
            > indent .hilight.icon c "^\\s*else\\s*$" t
            > indent .hilight.icon c "^\\s*if\\s*$" t
            >
            > Just a thought...
            > -- bryan
            >
            > On 11/27/06, jon@... <jon@...> wrote:
            >>> I am creating a mode for the programming language Icon. In it,
            >>> you can do:
            >>>
            >>> if 1 = 1 then write("Good") else write("Bad")
            >>> write("All done with if")
            >>>
            >>> or
            >>>
            >>> if 1 =1 then {
            >>> write("Good")
            >>> } else {
            >>> write("bad")
            >>> }
            >>> write("All done with if")
            >>>
            >>> Now, those two I can handle just fine. The following is what I
            >>> don't know
            >>> how to handle:
            >>>
            >>> if 1 =1 then
            >>> write("Good")
            >>> else
            >>> write("Bad")
            >>> write("All done with if")
            >>>
            >>> See on the last how only the next line is indented? Nothing more
            >>> after
            >>> that?
            >>>
            >>> Any help would be appriciated,
            >>>
            >>> Jeremy
            >>>
            >>
            >> This is exactly what the problem is with the current indent
            >> mechanism.
            >> Unfortunately there is not a known work around when a language
            >> does not
            >> include a closing token (this is actually why 'c' mode is burnt
            >> into the
            >> editor and is not implemented with indent tokens).
            >>
            >> You could take a look at the hkjava.emf. Bryan created a 'indent'
            >> only
            >> indentation scheme rather than basing it on c-mode. I do not think
            >> that it
            >> handles the case you cite above.
            >>
            >> To handle the if/then stuff then you could try using multiple indent
            >> schemes, but you would have to use \n as a closing token (i.e. end of
            >> line).
            >>
            >> To be honest I do not think you will be able to do it - specifically
            >> because of dangling else's which are difficult to handle.
            >>
            >> We have been looking at the indent mechanism with a view to fixing
            >> this
            >> very problem. I think you will have to use a regular indent. If
            >> the syntax
            >> of the language allowed terminating ';' then you could have
            >> probably used
            >> cmode with some tweaks.
            >>
            >> Sorry.
            >> Jon.
            >>
            >>
            >>
            >>
            >>
            >>
            >>
            >>
            >>
            >> _____________________________________________________________________
            >> _____
            >>
            >> This is an unmoderated list. JASSPA is not responsible for the
            >> content of
            >> any material posted to this list.
            >>
            >> To unsubscribe, send a mail message to
            >>
            >> mailto:jasspa-unsubscribe@yahoogroups.com
            >>
            >> or visit http://groups.yahoo.com/group/jasspa and
            >> modify your account settings manually.
            >>
            >>
            >>
            >> Yahoo! Groups Links
            >>
            >>
            >>
            >>
            >
            >
            > ______________________________________________________________________
            > ____
            >
            > This is an unmoderated list. JASSPA is not responsible for the
            > content of
            > any material posted to this list.
            >
            > To unsubscribe, send a mail message to
            >
            > mailto:jasspa-unsubscribe@yahoogroups.com
            >
            > or visit http://groups.yahoo.com/group/jasspa and
            > modify your account settings manually.
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
          • Jeremy Cowgar
            One more question and I think I then have a basic working mode for Icon! Yippie! In Icon, you can extend a string onto multiple lines by making the last
            Message 5 of 6 , Nov 27, 2006
            • 0 Attachment
              One more question and I think I then have a basic working mode for
              Icon! Yippie!

              In Icon, you can extend a string onto multiple lines by making the
              last character a _

              i.e.

              "John Doe had a dog"

              is the *exact* same as:

              "John Doe_
              had a dog"

              _ says skip everything until the next non-whitespace.

              So, my problem lies in the fact that I am ignoring comments inside of
              quotes:

              indent .hilight.icon e "\"" "\"" "\\"

              Any thoughts on a workaround for this? I'd like _ to cause a
              continuation indent.

              Jeremy

              On Nov 27, 2006, at 9:46 AM, Bryan Schofield wrote:

              > I don't know Icon syntax, but could have indent look for "if" and
              > "else" on a line by itself as a "continue" rule as well as "{}" brace
              > rule?
              >
              > indent .hilight.icon n "{" t
              > indent .hilight.icon o "}" -t
              > indent .hilight.icon c "^\\s*else\\s*$" t
              > indent .hilight.icon c "^\\s*if\\s*$" t
              >
              > Just a thought...
              > -- bryan
              >
              > On 11/27/06, jon@... <jon@...> wrote:
              >>> I am creating a mode for the programming language Icon. In it,
              >>> you can do:
              >>>
              >>> if 1 = 1 then write("Good") else write("Bad")
              >>> write("All done with if")
              >>>
              >>> or
              >>>
              >>> if 1 =1 then {
              >>> write("Good")
              >>> } else {
              >>> write("bad")
              >>> }
              >>> write("All done with if")
              >>>
              >>> Now, those two I can handle just fine. The following is what I
              >>> don't know
              >>> how to handle:
              >>>
              >>> if 1 =1 then
              >>> write("Good")
              >>> else
              >>> write("Bad")
              >>> write("All done with if")
              >>>
              >>> See on the last how only the next line is indented? Nothing more
              >>> after
              >>> that?
              >>>
              >>> Any help would be appriciated,
              >>>
              >>> Jeremy
              >>>
              >>
              >> This is exactly what the problem is with the current indent
              >> mechanism.
              >> Unfortunately there is not a known work around when a language
              >> does not
              >> include a closing token (this is actually why 'c' mode is burnt
              >> into the
              >> editor and is not implemented with indent tokens).
              >>
              >> You could take a look at the hkjava.emf. Bryan created a 'indent'
              >> only
              >> indentation scheme rather than basing it on c-mode. I do not think
              >> that it
              >> handles the case you cite above.
              >>
              >> To handle the if/then stuff then you could try using multiple indent
              >> schemes, but you would have to use \n as a closing token (i.e. end of
              >> line).
              >>
              >> To be honest I do not think you will be able to do it - specifically
              >> because of dangling else's which are difficult to handle.
              >>
              >> We have been looking at the indent mechanism with a view to fixing
              >> this
              >> very problem. I think you will have to use a regular indent. If
              >> the syntax
              >> of the language allowed terminating ';' then you could have
              >> probably used
              >> cmode with some tweaks.
              >>
              >> Sorry.
              >> Jon.
              >>
              >>
              >>
              >>
              >>
              >>
              >>
              >>
              >>
              >> _____________________________________________________________________
              >> _____
              >>
              >> This is an unmoderated list. JASSPA is not responsible for the
              >> content of
              >> any material posted to this list.
              >>
              >> To unsubscribe, send a mail message to
              >>
              >> mailto:jasspa-unsubscribe@yahoogroups.com
              >>
              >> or visit http://groups.yahoo.com/group/jasspa and
              >> modify your account settings manually.
              >>
              >>
              >>
              >> Yahoo! Groups Links
              >>
              >>
              >>
              >>
              >
              >
              > ______________________________________________________________________
              > ____
              >
              > This is an unmoderated list. JASSPA is not responsible for the
              > content of
              > any material posted to this list.
              >
              > To unsubscribe, send a mail message to
              >
              > mailto:jasspa-unsubscribe@yahoogroups.com
              >
              > or visit http://groups.yahoo.com/group/jasspa and
              > modify your account settings manually.
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
            • Bryan Schofield
              hmmm... you may have to use 2 indent schemes and switch when you encounter a Off the top of my head something like this may work... ; define a new indent
              Message 6 of 6 , Nov 27, 2006
              • 0 Attachment
                hmmm... you may have to use 2 indent schemes and switch when you encounter a "

                Off the top of my head something like this may work...

                ; define a new indent scheme for quoted strings
                set-variable .indent.icon-q &pinc .hilight.next 1
                0 indent .indent.icon-q 1 20

                ; have the indent scheme change to quoted scheme
                ; when a " is encountered and change back when a
                ; another non-escaped " is encountered
                indent .indent.icon t "\"" .indent.icon-q
                indent .indent.icon-q t "[^\\]\"" .indent.icon

                ; continue a line if a trailing _ is found
                indent .indent.icon-q c "_\s*$" t


                On 11/27/06, Jeremy Cowgar <jeremy@...> wrote:
                >
                > One more question and I think I then have a basic working mode for
                > Icon! Yippie!
                >
                > In Icon, you can extend a string onto multiple lines by making the
                > last character a _
                >
                > i.e.
                >
                > "John Doe had a dog"
                >
                > is the *exact* same as:
                >
                > "John Doe_
                > had a dog"
                >
                > _ says skip everything until the next non-whitespace.
                >
                > So, my problem lies in the fact that I am ignoring comments inside of
                > quotes:
                >
                > indent .hilight.icon e "\"" "\"" "\\"
                >
                > Any thoughts on a workaround for this? I'd like _ to cause a
                > continuation indent.
                >
                > Jeremy
              Your message has been successfully submitted and would be delivered to recipients shortly.