• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Notepad++ Ruby Syntax enhancement

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 4 Posters 2.8k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    thomthom
    last edited by 20 Oct 2009, 09:05

    I use Notepad++ to write plugins. Great editor. But there's something with the ruby syntax highlighting that's always bothered me; inline if and unless statements isn't highlighted. Is there a way to configure the language to do so?
    np++ruby.png

    I tried the User-Defined window to create a new Ruby style - but it didn't seem possible to set up the language to match the existing.

    Thomas Thomassen — SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund

    1 Reply Last reply Reply Quote 0
    • N Offline
      NewOne
      last edited by 20 Oct 2009, 10:03

      😄

      it doesn't highlight if it's placed after something... I think it's not recognized as expression


      npp.png

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 20 Oct 2009, 10:14

        Yes, but I'm wondering if it's possible to change the syntax highlighting so it does recognize it.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 20 Oct 2009, 12:51

          I also use Notepad++ and I just live with it...

          The Ruby Style would need to find not only '^if ' and ' if '... but also ' if*' or '* if ' or ')if ' or '^if(' or ' if(' or ')if(' etc whilst avoiding 'if' as in 'difference'... Perhaps a request to the author ?

          User defined language styles would mean you recreating ALL of the other Ruby stuff and THEN adding this !

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 20 Oct 2009, 12:58

            @tig said:

            User defined language styles would mean you recreating ALL of the other Ruby stuff and THEN adding this !

            Is it possible at all to define that? I had a look at Format->User-Defined Dialouge... But I wasn't able to find such control. 😕

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 20 Oct 2009, 13:26

              @thomthom said:

              @tig said:

              User defined language styles would mean you recreating ALL of the other Ruby stuff and THEN adding this !

              Is it possible at all to define that? I had a look at Format->User-Defined Dialouge... But I wasn't able to find such control. 😕

              See this for help http://weblogs.asp.net/jgalloway/archive/2006/11/25/creating-a-user-defined-language-in-notepad.aspx

              TIG

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 20 Oct 2009, 13:29

                That's what I've been trying to use - but not been able to create the result I want. I even tried to open the XML file where it's defined, in-case I should find an alternative way.

                Only other option I can find is writing a custom lexer - but that requires C knowledge - which I don't have....

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • M Offline
                  MartinRinehart
                  last edited by 20 Oct 2009, 15:12

                  @thomthom said:

                  Only other option I can find is writing a custom lexer - but that requires C knowledge - which I don't have....

                  C isn't required. I've got lexers in Java, Perl and Python if you want to have a look.

                  Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 20 Oct 2009, 15:26

                    Can a Python lexer work with NP++?

                    I've not used Java, Perl or Python - but I hear the leap from Ruby isn't that big. And in any case, the next V-Ray for Sketchup is written in Python so I will need to learn it anyway.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      MartinRinehart
                      last edited by 20 Oct 2009, 18:52

                      @thomthom said:

                      Can a Python lexer work with NP++?

                      I've no idea. Took a look. My lexer is a Decaf lexer, written in Python. Decaf (Java without the Jitters) is a beginners language I've designed and am working on, but not often enough.

                      Decaf is quite like Python in most things, except suites. I actually have decided to implement suites:

                      
                      if condition
                          no braces
                          around this
                          block of code
                      
                      # no braces, no begin/end
                      
                      

                      Fortunately for your requirement, Decaf's lexer still looks for {} around statement blocks.

                      Unfortunately, Ruby persuaded me to add trailing IF and UNLESS but they're not there yet, either. I could add those soon.

                      Here's the language description. Before you go here, "lexical analysis" and "lexing" are Decaf-described as "breaking the language into WORDS" (not tokens). Parsing is picking out PHRASES (not expressions) and SENTENCES (aka statements). The code and doc is in various stages of being converted to Decaf-speak.

                      
                      # Decaf's EBNF grammar
                      
                      # grammar of the grammar;
                      #     'x'     the character 'x'
                      #     'xxx'   the character string 'xxx' (as a separate word)
                      #     x | y   either x or y
                      #     [ x ]   0 or 1 x
                      #     x*      0 or more x
                      #     x+      1 or more x
                      #     {}      grouping, example;
                      #               "exp{',' exp}+" - "exp" followed by one or more "',' exp"
                      #     < xx >  comment (documentation of the grammar)
                      #     full_name, nm ;;=
                      #         x   'full_name' is defined as 'x', 'nm' is short for 'full_name' 
                      #
                      #     xxx;    definition continued, next line
                      #
                      #     name ;;=
                      #         x
                      #         y   'name' is defined as 'x | y'
                      #
                      #     xxx_operator, xx ;;=
                      #           < operators of type 'xxx' listed here >
                      
                      #---------------------- words -----------------------
                      
                      constant_e, con_e ;;=
                          'E' = 2.71828182845904523536
                      
                      constant_pi, con_pi ;;=
                          'PI' = 3.14159265358979323846
                      
                      comment_eol_word, cmt_w ;;=
                          COMMENT_EOL
                      
                      end_of_line_word, eol_w ;;=
                          END_OF_LINE
                      
                      end_of_input_word, eoi_w ;;=
                          END_OF_INPUT
                      
                      end_of_statement_word, eos_w ;;=
                          END_OF_STATEMENT
                      
                      line_continuation_word, lcon_w ;;=
                          LINE_CONTINUATION
                      
                      whitespace_word, white_w ;;=
                          WHITESPACE
                      
                      constant_integer_word, con_i_w ;;=
                          CONSTANT_INTEGER
                      
                      constant_decimal_word, con_d_w ;;=
                          CONSTANT_DECIMAL
                      
                      lbrace_word, lbrace_w ;;=
                          LBRACE
                      
                      lbracket_word, lbrkt_w ;;=
                          LBRACKET
                      
                      lparen_word, lprn_w ;;=
                          LPAREN
                      
                      malformed_number_word, m_num_w ;;=
                          MALFORMED_NUMBER
                      
                      multiline_string_word, ml_str_w ;;=
                          MULTILINE_STRING
                      
                      name_word, name_w ;;=
                          NAME
                      
                      operator_word, op_w ;;=
                          OPERATOR
                      
                      rbrace_word, rbrace_w ;;=
                          RBRACE
                      
                      rbracket_word, rbrkt_w ;;=
                          RBRACKET
                      
                      reserved_word_word, res_wrd_w ;;=
                          RESERVED_WORD
                      
                      rparen_word, rprn_w ;;=
                          RPAREN
                      
                      string_word, str_w ;;=
                          STRING
                      
                      unclosed_multiline_string_word, unc_mls_w ;;=
                          UNCLOSED_MULTILINE_STRING
                      
                      unclosed_string_word, unc_str_w ;;=
                          UNCLOSED_STRING
                      
                      unknown_character_word, unk_chr_w ;;=
                          UNKNOWN_CHARACTER
                      
                      #------------------- expressions --------------------    
                      
                      arithmetic_operator, arth_op_p ;;=
                          '+' | '-' | '*' | '/' | '^' | '%' 
                      
                      copula_operator, cop_op_p ;;=
                          '=>'
                      
                      comparison_operator, cmp_op_p ;;= 
                          'GT' | 'GE' | 'EQ' | 'LE' | 'LT' | 'NE' | 'IN'
                      
                      binary_logical_operator, log_op_p ;;=
                          'AND' | 'OR'
                      
                      unary_logical_operator, not_op_p ;;=
                          'NOT'
                      
                      other_operator, oth_op_p ;;=
                          '.' | ',' | ';'
                      
                      expression, expr ;;=
                          arithmetic_expression
                          comparison_expression
                          logical_expression
                          parenthesized_expression
                          list_expression
                          range_expression
                          subscript_expression
                          function_call
                          selection_expression
                      
                      arithmetic_expression, arth_exp ;;=
                          operand arithmetic_operator operand
                          '-' operand
                      
                      comparison_expression, cmp_exp ;;=
                          operand comparison_operator operand
                      
                      logical_expression, log_exp ;;=
                          operand binary_logical_operator operand
                          unary_logical_operator operand
                          'TRUE' | 'FALSE'
                          comparison_expression
                      
                      parenthesized_expression, paren_exp ;;=
                          '(' expression ')'
                      
                      list_expression, lst_exp ;;=
                          expression {',' expression}+
                      
                      range_expression, rng_exp ;;=
                          operand ';' [operand]
                          ';' operand < operands must be integers >
                      
                      subscript_expression, sub_exp ;;=
                          '[' range_expression{',' range_expression}* ']'
                      
                      function_call, func_exp ;;=
                          parenthesized_expression function_name
                      
                      function_name, func_nm ;;=
                          NAME < name of defined or imported function >
                      
                      selection_expression, sel_exp ;;=
                          NAME{'.' NAME}+
                      
                      operand, oprand ;;=
                      	NAME
                      	constant
                      	expression
                      
                      constant, cnstnt ;;=
                      	CONSTANT_INTEGER | CONSTANT_DECIMAL | STRING | MULTILINE_STRING
                      
                      #-------------------------- other phrases ----------------------------
                      
                      address, addr_p ;;=
                          PATHNAME < address on local machine >
                          URL < address on any machine >
                      
                      capability_name, cp_nm_p ;;=
                          NAME < of capability type >
                      
                      right_hand_side, rhs_p ;;=
                          rhs_qualifiers [type_name] variable_name
                      
                      rhs_qualifiers, rhs_ql_p ;;=
                          [ 'LOCAL' | 'GLOBAL' ] [ 'RW' | 'RO' ] [range_expression]
                      
                      return_types_list, rt_tps_p ;;=
                          type_name{, type_name}*
                      
                      type_name, tp_nm_p ;;=
                          base_type
                          built_in_type
                          defined_type
                      
                      base_type, bs_tp_p ;;=
                          'BIT' | 'BYTE' | 'CHAR' | 'DEC' | 'GROUP' |;
                          'INT' | 'NAMELIST' | 'TYPE' | 'SUB'
                      
                      built_in_type, bi_tp_p ;;=
                          < see http://www.MartinRinehart.com/posters/decaf-object-library.html >        
                      
                      defined_type, def_tp_p ;;=
                          < types defined in page or imported from other pages >
                      
                      variable_name, vr_nm_p ;;=
                          NAME < word, type==NAME, textValue contains name >
                      
                      condition, cond_p ;;=
                          logical_expression
                      
                      list_name, ls_nm_p ;;=
                          NAME < that identifies a list, array, NAMELIST or group >
                      
                      self_name_p, self_p ;;=
                          'ME'
                      
                      #--------------------- statements -----------------------	
                      
                      statement, smt ;;=
                          declaration_statement
                          action_statement
                      
                      declaration_statement, dec_smt ;;=
                          var_declaration_statement
                          include_statement
                          type_declaration_statement
                          sub_declaration_statement
                      
                      action_statement, act_smt ;;=
                          expression_statement
                          block_statement
                          if_statement
                          foreach_statement
                          while_statement
                          loop_statement
                          break_statement
                          return_statement
                      
                      var_declaration_statement, vr_dec_smt ;;=
                          rhs_qualifiers type_name variable_name
                      
                      include_statement, incl_smt ;;=
                          'INCLUDE' address {',' address}*
                      
                      type_declaration_statement, tp_dec_smt ;;=
                          { 'CLASS' | 'CAPABILITY' } NAME1;
                              [ 'EXTENDS' NAME2 ];
                              ['CANDO' capability_name [, capability_name]* ];
                              [ MULTILINE_STRING ] < documentation >;
                              action_statement
                      
                      sub_declaration_statement, sb_dec_smt ;;=
                          'SUB' '(' [ list_expression ] ')' NAME '(' [ return_types_list ] ')';
                      	action_statement
                      
                      expression_statement, exp_smt ;;=
                          expression [ copula_operator right_hand_side{',' right_hand_side}* ]
                      
                      block_statement, blk_smt ;;=
                          INDENT;
                              [ MULTILINE_STRING ] < documentation >;
                              statement*;
                              UNINDENT
                      
                      if_statement, if_smt ;;=
                          'IF' condition 'THEN' action_statement [ 'ELSE' action_statement ]
                      
                      foreach_statement, for_smt ;;=
                          'FOR' 'EACH' variable_name IN list_name DO action_statement
                      
                      while_statement, whl_smt ;;=
                          'WHILE' condition 'DO' action_statement
                      
                      loop_statement, loop_smt ;;=
                          'LOOP'
                      
                      break_statement, brk_smt ;;=
                          'BREAK'
                      
                      return_statement, ret_smt ;;=
                          'RETURN' expression < expression may be expression_list >
                      
                      #---------------------- program -----------------------
                      
                      program, prgrm ;;=
                          [ MULTILINE_STRING ] < documentation >;
                          statement*;
                          END_OF_INPUT
                          
                      # end of decaf.bnf
                      
                      

                      This is drifting off-topic. Unless someone (anyone?) else is interested, maybe we could do this via Email. MartinRinehart at gmail dot com.

                      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        1/10
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement