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

Re: [jasspa] Groups in a regular expression for indentation?

Expand Messages
  • Jeremy Cowgar
    ... The only problem is I have about 10 similar statements, thus, I will have about 20 lines that say roughly the same thing :-/ Jeremy
    Message 1 of 5 , Jul 16, 2008
      Quoting Jon Green <jon@...>:
      > Jeremy Cowgar wrote:
      > > I have the following indent code:
      > >
      > > indent .hilight.euphoria c "[-+=*/<>,{][ \t]*$" t
      > > indent .hilight.euphoria c "[-+=*/<>,{][ \t]*--.*$" t
      > >
      > > The second is obviously a duplicate but it is to hanle those types of
      > > lines that also have a comment at the end. For instance:
      > >
      > > constant ABC=10,
      > > ....DEF=20
      > >
      > > and
      > >
      > > constant ABC=10, -- Dummy constant for this explanation
      > > ....DEF=20
      > >
      > > Can I combined those in any way? I tried (--.*)* w/no luck.
      > >
      >
      > No not really, it is OK as you have defined it.

      The only problem is I have about 10 similar statements, thus, I will have
      about 20 lines that say roughly the same thing :-/

      Jeremy
    • Jon Green
      ... Thats OK, get it working first and then come back and see if it needs to be optimised. Unfortunately the regular expression support in indent is
      Message 2 of 5 , Jul 16, 2008
        Jeremy Cowgar wrote:
        > Quoting Jon Green <jon@...>:
        >> Jeremy Cowgar wrote:
        >>> I have the following indent code:
        >>>
        >>> indent .hilight.euphoria c "[-+=*/<>,{][ \t]*$" t
        >>> indent .hilight.euphoria c "[-+=*/<>,{][ \t]*--.*$" t
        >>>
        >>> The second is obviously a duplicate but it is to hanle those types of
        >>> lines that also have a comment at the end. For instance:
        >>>
        >>> constant ABC=10,
        >>> ....DEF=20
        >>>
        >>> and
        >>>
        >>> constant ABC=10, -- Dummy constant for this explanation
        >>> ....DEF=20
        >>>
        >>> Can I combined those in any way? I tried (--.*)* w/no luck.
        >>>
        >> No not really, it is OK as you have defined it.
        >
        > The only problem is I have about 10 similar statements, thus, I will have
        > about 20 lines that say roughly the same thing :-/
        >

        Thats OK, get it working first and then come back and see if it needs to
        be optimised. Unfortunately the regular expression support in indent is
        restricted. The restrictions of the regular expressions for indent are
        documented in hilight(2).

        What you really want is a multi-character group i.e. "\(--.*\)?$" but
        you do not have that available to you in indent. Note that "[ \t]" is
        better written as "\s" (don't forget that '\' should be doubled up i.e.
        "\\s").

        Regards
        Jon.



        > Jeremy
        >
        >
        > ------------------------------------
        >
        > __________________________________________________________________________
        >
        > This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
        > any material posted to this list.
        >
        > To un-subscribe, 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
        >
        >
        >
        >
      • Steven Phillips
        This is absolutely fine, ME constructs a structure which is very efficient, it has to be as the same code is used by the hilighter. If you consider the regex
        Message 3 of 5 , Jul 17, 2008
          This is absolutely fine, ME constructs a structure which is very
          efficient, it has to be as the same code is used by the hilighter. If
          you consider the regex '\(one\|two\|three\)' you have effectively
          wrapped three words into one regex but this is also much more
          complicated to parse, the hilighter approach is to create 3 simple rules
          and make it go much faster.

          Once you realize indent uses the same code as hilight, 20 rules does not
          seem so excessive, for example C (hkc.emf) has ~280 hilight rules and
          php script has ~450!

          Steve

          Jeremy Cowgar wrote:
          >
          > Quoting Jon Green <jon@... <mailto:jon%40jasspa.com>>:
          > > Jeremy Cowgar wrote:
          > > > I have the following indent code:
          > > >
          > > > indent .hilight.euphoria c "[-+=*/<>,{][ \t]*$" t
          > > > indent .hilight.euphoria c "[-+=*/<>,{][ \t]*--.*$" t
          > > >
          > > > The second is obviously a duplicate but it is to hanle those types of
          > > > lines that also have a comment at the end. For instance:
          > > >
          > > > constant ABC=10,
          > > > ....DEF=20
          > > >
          > > > and
          > > >
          > > > constant ABC=10, -- Dummy constant for this explanation
          > > > ....DEF=20
          > > >
          > > > Can I combined those in any way? I tried (--.*)* w/no luck.
          > > >
          > >
          > > No not really, it is OK as you have defined it.
          >
          > The only problem is I have about 10 similar statements, thus, I will have
          > about 20 lines that say roughly the same thing :-/
          >
          > Jeremy
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.