mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
refactor _ADD_RULE macro #773
This commit is contained in:
parent
cfc0a31c7f
commit
847278240b
|
@ -48,6 +48,12 @@ CLASS lcl_syntax_highlighter DEFINITION ABSTRACT
|
||||||
|
|
||||||
DATA mt_rules TYPE STANDARD TABLE OF ty_rule.
|
DATA mt_rules TYPE STANDARD TABLE OF ty_rule.
|
||||||
|
|
||||||
|
METHODS add_rule
|
||||||
|
IMPORTING
|
||||||
|
iv_regex TYPE string
|
||||||
|
iv_token TYPE c
|
||||||
|
iv_style TYPE string.
|
||||||
|
|
||||||
METHODS parse_line
|
METHODS parse_line
|
||||||
IMPORTING iv_line TYPE string
|
IMPORTING iv_line TYPE string
|
||||||
EXPORTING et_matches TYPE ty_match_tt.
|
EXPORTING et_matches TYPE ty_match_tt.
|
||||||
|
@ -149,23 +155,6 @@ CLASS lcl_syntax_xml DEFINITION INHERITING FROM lcl_syntax_highlighter FINAL.
|
||||||
|
|
||||||
ENDCLASS. " lcl_syntax_xml DEFINITION
|
ENDCLASS. " lcl_syntax_xml DEFINITION
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
* Macros to fill table with a regular expressions to be parsed
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
|
|
||||||
DEFINE _add_rule.
|
|
||||||
|
|
||||||
CREATE OBJECT ls_rule-regex
|
|
||||||
EXPORTING
|
|
||||||
pattern = c_regex-&1
|
|
||||||
ignore_case = abap_true.
|
|
||||||
|
|
||||||
ls_rule-token = c_token-&1.
|
|
||||||
ls_rule-style = c_css-&1.
|
|
||||||
APPEND ls_rule TO mt_rules.
|
|
||||||
|
|
||||||
END-OF-DEFINITION. " _add_rule
|
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
* CLASS lcl_syntax_highlighter IMPLEMENTATION
|
* CLASS lcl_syntax_highlighter IMPLEMENTATION
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
|
@ -187,6 +176,21 @@ CLASS lcl_syntax_highlighter IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD. " create.
|
ENDMETHOD. " create.
|
||||||
|
|
||||||
|
METHOD add_rule.
|
||||||
|
|
||||||
|
DATA ls_rule LIKE LINE OF mt_rules.
|
||||||
|
|
||||||
|
CREATE OBJECT ls_rule-regex
|
||||||
|
EXPORTING
|
||||||
|
pattern = iv_regex
|
||||||
|
ignore_case = abap_true.
|
||||||
|
|
||||||
|
ls_rule-token = iv_token.
|
||||||
|
ls_rule-style = iv_style.
|
||||||
|
APPEND ls_rule TO mt_rules.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD parse_line.
|
METHOD parse_line.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
|
@ -346,9 +350,18 @@ CLASS lcl_syntax_abap IMPLEMENTATION.
|
||||||
super->constructor( ).
|
super->constructor( ).
|
||||||
|
|
||||||
" Initialize instances of regular expression
|
" Initialize instances of regular expression
|
||||||
_add_rule keyword.
|
|
||||||
_add_rule comment.
|
add_rule( iv_regex = c_regex-keyword
|
||||||
_add_rule text.
|
iv_token = c_token-keyword
|
||||||
|
iv_style = c_css-keyword ).
|
||||||
|
|
||||||
|
add_rule( iv_regex = c_regex-comment
|
||||||
|
iv_token = c_token-comment
|
||||||
|
iv_style = c_css-comment ).
|
||||||
|
|
||||||
|
add_rule( iv_regex = c_regex-text
|
||||||
|
iv_token = c_token-text
|
||||||
|
iv_style = c_css-text ).
|
||||||
|
|
||||||
ENDMETHOD. " constructor
|
ENDMETHOD. " constructor
|
||||||
|
|
||||||
|
@ -567,9 +580,18 @@ CLASS lcl_syntax_xml IMPLEMENTATION.
|
||||||
super->constructor( ).
|
super->constructor( ).
|
||||||
|
|
||||||
" Initialize instances of regular expressions
|
" Initialize instances of regular expressions
|
||||||
_add_rule xml_tag.
|
|
||||||
_add_rule attr.
|
add_rule( iv_regex = c_regex-xml_tag
|
||||||
_add_rule attr_val.
|
iv_token = c_token-xml_tag
|
||||||
|
iv_style = c_css-xml_tag ).
|
||||||
|
|
||||||
|
add_rule( iv_regex = c_regex-attr
|
||||||
|
iv_token = c_token-attr
|
||||||
|
iv_style = c_css-attr ).
|
||||||
|
|
||||||
|
add_rule( iv_regex = c_regex-attr_val
|
||||||
|
iv_token = c_token-attr_val
|
||||||
|
iv_style = c_css-attr_val ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
@ -673,7 +695,7 @@ CLASS ltcl_syntax_cases IMPLEMENTATION.
|
||||||
ms_match-token = &1.
|
ms_match-token = &1.
|
||||||
ms_match-offset = &2.
|
ms_match-offset = &2.
|
||||||
ms_match-length = &3.
|
ms_match-length = &3.
|
||||||
append ms_match to mt_after_parse.
|
APPEND ms_match TO mt_after_parse.
|
||||||
END-OF-DEFINITION. " _generate_parse
|
END-OF-DEFINITION. " _generate_parse
|
||||||
|
|
||||||
DEFINE _generate_order.
|
DEFINE _generate_order.
|
||||||
|
@ -681,7 +703,7 @@ CLASS ltcl_syntax_cases IMPLEMENTATION.
|
||||||
ms_match-offset = &2.
|
ms_match-offset = &2.
|
||||||
ms_match-length = &3.
|
ms_match-length = &3.
|
||||||
ms_match-text_tag = &4.
|
ms_match-text_tag = &4.
|
||||||
append ms_match to mt_after_order.
|
APPEND ms_match TO mt_after_order.
|
||||||
END-OF-DEFINITION. " _generate_order
|
END-OF-DEFINITION. " _generate_order
|
||||||
|
|
||||||
DEFINE _generate_extend.
|
DEFINE _generate_extend.
|
||||||
|
@ -689,7 +711,7 @@ CLASS ltcl_syntax_cases IMPLEMENTATION.
|
||||||
ms_match-offset = &2.
|
ms_match-offset = &2.
|
||||||
ms_match-length = &3.
|
ms_match-length = &3.
|
||||||
ms_match-text_tag = &4.
|
ms_match-text_tag = &4.
|
||||||
append ms_match to mt_after_extend.
|
APPEND ms_match TO mt_after_extend.
|
||||||
END-OF-DEFINITION. " _generate_extend
|
END-OF-DEFINITION. " _generate_extend
|
||||||
|
|
||||||
METHOD do_test.
|
METHOD do_test.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user