File size: 8,331 Bytes
f1ff2be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==========================================================================\
|
|   To learn how to make your own language parser, please check the following
|   link:
|       https://npp-user-manual.org/docs/function-list/
|
\=========================================================================== -->
<NotepadPlus>
	<functionList>
		<!-- ======================================================= [ BaanC ] -->
		
		<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		|	Based on:
		|		https://notepad-plus-plus.org/community/topic/14494/functionlist-classrange-question
		|
		|	Note(s):
		|	1.	Boost::Regex 1.58-1.59 do not correctly handle quantifiers on subroutine calls
		|		therefore the additional non-capturing group i.e. "(?:(?&amp;COMMENT))?" instead
		|		of simply "(?&amp;COMMENT)?"
		\-->
		<parser
			displayName="BaanC Sections"
			id         ="baanc_section"
		>
			<classRange
				mainExpr="(?x)                                              # free-spacing (see `RegEx - Pattern Modifiers`)
						(?im)                                               # case-insensitive, ^ and $ match at line breaks
						(?(DEFINE)                                          # definition of sub-routines
							(?'SECTION'
								^\h*                                        # optional leading whitespace at start-of-line
								(?:                                         # known section names
									(?:after|before)\.(?:report\.\d+|\w+(?:\.\w+)*\.\d+)
								|	(?:field|zoom\.from)\.(?:all|other|\w+(?:\.\w+)*)
								|	(?:footer|group|header)\.\d+
								|	choice\.\w+(?:\.\w+)*
								|	detail\.\d+
								|	form\.(?:all|other|\d+)
								|	functions
								|	main\.table\.io
								):                                          # end-of-section-header indicator
							)
							(?'SECTION_EMPTY'
								^\h*                                        # optional leading whitespace at start-of-line
								(?:                                         # known `empty` section names
									after\.(?:form\.read|program|receive\.data|update\.db\.commit)
								|	before\.(?:(?:display|new)\.object|program)
								|	declaration
								|	on\.(?:display\.total\.line|error)
								):                                          # end-of-section-header indicator
							)
						)
						(?&amp;SECTION)                                     # section header
						(?s:.*?)                                            # whatever,
						(?=                                                 # ...up till
							\s*
							(?:
								(?&amp;SECTION)                             # ...next section header,
							|   (?&amp;SECTION_EMPTY)                       # ...next `empty` section header
							|   \Z                                          # ...or end-of-text
							)
						)
					"
			>
				<className>
					<nameExpr expr="^\h*\K\w+(?:\.\w+)*:" />
				</className>
				<function
					mainExpr="(?x)                                          # free-spacing (see `RegEx - Pattern Modifiers`)
							(?im)                                           # case-insensitive, ^ and $ match at line breaks
							(?(DEFINE)                                      # definition of sub-routines
								(?'COMMENT'
									\s*\x7C[^\r\n]*                         # trailing comment
									(?:                                     # optional subsequent comment
										(?:\r?\n|\n?\r)                     # - mandatory line-break
										\s*\x7C[^\r\n]*                     # - `trailing` comment
									)*
								)
							)
							^\h*                                            # optional leading whitespace at start-of-line
							(?:
								\K                                          # discard text matched so far
								(?:                                         # known sub-section names
									after\.(?:choice|d(?:elete|isplay)|f(?:ield|orm)|group|input|layout|re(?:ad|write)|skip\.(?:delete|(?:re)?write)|write|zoom)
								|	before\.(?:ch(?:ecks|oice)|d(?:elete|isplay)|f(?:ield|orm)|group|input|layout|print|re(?:ad|write)|write|zoom)
								|	check\.input
								|	domain\.error
								|	init\.(?:f(?:ield|orm)|group)
								|	on\.(?:choice|e(?:ntry|xit)|input)
								|	read\.view
								|	ref\.(?:display|input)
								|	selection\.filter
								|	when\.field\.changes
								):                                          # end-of-sub-section-header indicator
							|
								function                                    # keyword, start-of-function-header indicator
								(?:(?&amp;COMMENT))?                        # optional `embedded` comment
								(?:                                         # optional storage-class specifier
									\s+extern
									(?:(?&amp;COMMENT))?                    # ...with optional `embedded` comment
								)?
								(?:                                         # optional function type specifier
									\s+(?:
										boolean
									|	double
									|	long
									|	string
									|	void
									|	domain
										(?:(?&amp;COMMENT))?                # ...with optional `embedded` comment
										\s+\w+(?:\.\w+)*
									)
									(?:(?&amp;COMMENT))?                    # ...with optional `embedded` comment
								)?
								\s+
								\K                                          # discard text matched so far
								\w+(?:\.\w+)*                               # function identifier
								(?:(?&amp;COMMENT)(?:\r?\n|\n?\r))?         # optional `embedded` comment
								\s*\(                                       # start-of-parameter-list indicator
							)
						"
				>
					<functionName>
						<funcNameExpr expr="\w+(?:\.\w+)*(?:\h*:)?" />
					</functionName>
				</function>
			</classRange>
			<function
				mainExpr="(?x)                                              # free-spacing (see `RegEx - Pattern Modifiers`)
						(?im)                                               # case-insensitive, ^ and $ match at line breaks
						(?(DEFINE)                                          # definition of sub-routines
							(?'COMMENT'
								\s*\x7C[^\r\n]*                             # trailing comment
								(?:                                         # optional subsequent comment
									(?:\r?\n|\n?\r)                         # - mandatory line-break
									\s*\x7C[^\r\n]*                         # - `trailing` comment
								)*
							)
						)
						^\h*                                                # optional leading whitespace at start-of-line
						(?:
							\K                                              # discard text matched so far
							(?:                                             # known `empty` section names
								after\.(?:form\.read|program|receive\.data|update\.db\.commit)
							|	before\.(?:display\.object|new\.object|program)
							|	declaration
							|	on\.(?:display\.total\.line|error)
							):                                              # end-of-section-header indicator
						|
							function                                        # keyword, start-of-function-header indicator
							(?:(?&amp;COMMENT))?                            # optional `embedded` comment
							(?:                                             # optional storage-class specifier
								\s+extern
								(?:(?&amp;COMMENT))?                        # ...with optional `embedded` comment
							)?
							(?:                                             # optional function type specifier
								\s+(?:
									boolean
								|	double
								|	long
								|	string
								|	void
								|	domain
									(?:(?&amp;COMMENT))?                    # ...with optional `embedded` comment
									\s+\w+(?:\.\w+)*
								)
								(?:(?&amp;COMMENT))?                        # ...with optional `embedded` comment
							)?
							\s+
							\K                                              # discard text matched so far
							\w+(?:\.\w+)*                                   # function identifier
							(?:(?&amp;COMMENT)(?:\r?\n|\n?\r))?             # optional `embedded` comment
							\s*\(                                           # start-of-parameter-list indicator
						)
					"
			>
				<functionName>
					<nameExpr expr="\w+(?:\.\w+)*(?:\h*:)?" />
				</functionName>
			</function>
		</parser>
	</functionList>
</NotepadPlus>