rexical 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6b78dc8daf9900783617edca9228ca4d4640f808b6251775e7105f6f20d1e9b
4
+ data.tar.gz: 01dd220d9a85cc3236f79b6596fa6b64b9f95456b71d5340fb4284c48db20fa5
5
+ SHA512:
6
+ metadata.gz: 6fcd99b73957780f3617ddc9317d24207dd9be43c9bb42d55863c1b4f7cfa591d2a48a9f9b0e200089303dbb0c8cf64628c1514c9181220e555721b1274c28f7
7
+ data.tar.gz: d6f222da2d448cbb7b5b2a849f7a1549cde2870301e557217825e428668fd57c02eb05ffcf8332f993d8ddf14ab6dca7d5a39e2ec0bb0fa5fe444b3bfff083b2
@@ -1,4 +1,16 @@
1
- === 1.0.5 / Not released
1
+ === 1.0.7 / 2019-08-06
2
+
3
+ * Security
4
+
5
+ * prefer File.open to Kernel.open
6
+
7
+ === 1.0.6
8
+
9
+ * Bug fixes
10
+
11
+ * scanner states work better. Thanks Mat.
12
+
13
+ === 1.0.5
2
14
 
3
15
  * Bug fixes
4
16
 
@@ -1,215 +1,211 @@
1
-
2
- = REX: Ruby Lex for Racc
3
-
4
-
5
- == About
6
-
7
- Lexical Scanner Generator for Ruby, with Racc.
8
-
9
-
10
- == Usage
11
-
12
- rex [options] grammarfile
13
-
14
- -o --output-file filename designated output filename.
15
- -s --stub append stub main for debug.
16
- -i --ignorecase ignore char case
17
- -C --check-only syntax check only.
18
- --independent independent mode.
1
+ = REX: Ruby Lex for Racc
2
+
3
+
4
+ == About
5
+
6
+ Lexical Scanner Generator used with Racc for Ruby
7
+
8
+
9
+ == Usage
10
+
11
+ rex [options] grammarfile
12
+
13
+ -o --output-file filename designate output filename
14
+ -s --stub append stub main for debugging
15
+ -i --ignorecase ignore character case
16
+ -C --check-only only check syntax
17
+ --independent independent mode
19
18
  -d --debug print debug information
20
- -h --help print usage.
21
- --version print version.
22
- --copyright print copyright.
23
-
24
-
25
- == Default Output Filename
26
-
27
- It destinate from foo.rex to foo.rex.rb.
28
- This name is for a follow description.
29
-
30
- require 'foo.rex'
31
-
32
-
33
- == Grammar File Format
34
-
35
- A definition is given in order of a header part, a rule part,
36
- and the footer part. One or more sections are included in a rule part.
37
- As for each section, the head of the sentence starts by the keyword.
38
-
39
- Summary:
40
-
41
- [Header Part]
42
- "class" Foo
43
- ["option"
44
- [options] ]
45
- ["inner"
46
- [methods] ]
47
- ["macro"
48
- [macro-name regular-expression] ]
49
- "rule"
50
- [start-state] pattern [actions]
51
- "end"
52
- [Footer Part]
53
-
54
-
55
- === Grammar File Example
56
-
57
- class Foo
58
- macro
59
- BLANK \s+
60
- DIGIT \d+
61
- rule
62
- {BLANK}
63
- {DIGIT} { [:NUMBER, text.to_i] }
64
- . { [text, text] }
65
- end
66
-
67
-
68
- == Header Part ( Optional )
69
-
70
- All the contents described before the definition of a rule part are
71
- posted to head of the output file.
72
-
73
-
74
- == Footer Part ( Optional )
75
-
76
- All the contents described after the definition of a rule part are
77
- posted to tail of the output file.
78
-
79
-
80
- == Rule Part
81
-
82
- Rule part is from the line which begins from the "class" keyword
83
- to the line which begins from the "end" keyword.
84
- The class name outputted after a keyword "class" is specified.
85
- If embellished with a module name, it will become a class in a module.
86
- The class which inherited Racc::Parser is generated.
87
-
88
-
89
- === Rule Header Example
90
-
91
- class Foo
92
- class Bar::Foo
93
-
94
-
95
- == Option Section ( Optional )
96
-
97
- "option" is start keyword.
98
-
99
- "ignorecase" when pattern match, ignore char case.
100
- "stub" append stub main for debug.
101
- "independent" independent mode, for it is not inherited Racc.
102
-
103
-
104
- == Inner Section ( Optional )
105
-
106
- "inner" is start keyword.
107
- The contents defined here are defined by the inside of the class
108
- of the generated scanner.
109
-
110
-
111
- == Macro Section ( Optional )
112
-
113
- "macro" is start keyword.
114
- One regular expression is named.
115
- A blank character (0x20) can be included by escaping by \ .
116
-
117
-
118
- === Macro Section Example
119
-
120
- DIGIT \d+
121
- IDENT [a-zA-Z_][a-zA-Z0-9_]*
122
- BLANK [\ \t]+
123
- REMIN \/\*
124
- REMOUT \*\/
125
-
126
-
127
- == Rule Section
128
-
129
- "rule" is start keyword.
130
-
131
- [state] pattern [actions]
132
-
133
-
134
- === state: Start State ( Optional )
135
-
136
- A start state is expressed with the identifier which prefaces ":".
137
- When the continuing alphabetic character is a capital letter,
138
- it will be in an exclusive start state.
139
- When it is a small letter, it will be in an inclusive start state.
140
- Initial value and default value of a start state is nil.
141
-
142
-
143
- === pattern: String Pattern
144
-
145
- The regular expression for specifying a character string.
146
- The macro definition bundled with { } can be used for description
147
- of a regular expression. A macro definition is used in order to use
148
- a regular expression including a blank.
149
-
150
-
151
- === actions: Processing Actions ( Optional )
152
-
153
- Action is performed when a pattern is suited.
154
- The processing which creates a suitable token is defined.
155
- The arrangement whose token has the second clause of classification
156
- and a value, or nil.
157
- The following elements can be used in order to create a token.
158
-
159
- lineno Line number ( Read Only )
160
- text Matched string ( Read Only )
161
- state Start state ( Read/Write )
162
-
163
- Action is bundled with { }. It is the block of Ruby.
164
- Don't use the function to change the flow of control exceeding a block.
165
- ( return, exit, next, break, ... )
166
- If action is omitted, the character string which matched will be canceled
167
- and will progress to the next scan.
168
-
169
-
170
- === Rule Part Example
171
-
172
- {REMIN} { state = :REM ; [:REM_IN, text] }
173
- :REM {REMOUT} { state = nil ; [:REM_OUT, text] }
174
- :REM (.+)(?={REMOUT}) { [:COMMENT, text] }
175
- {BLANK}
176
- -?{DIGIT} { [:NUMBER, text.to_i] }
177
- {WORD} { [:word, text] }
178
- . { [text, text] }
179
-
180
- == Comment ( Optional )
181
-
182
- From "#" to the end of the line becomes a comment in each line.
183
-
184
-
185
- == Usage for Generated Class
186
-
187
- === scan_setup()
188
-
189
- The event for initializing at the time of the execution start of a scanner.
190
- It is redefined and used.
191
-
192
-
193
- === scan_str( str )
194
-
195
- Parse the string described by the defined grammar.
196
- Token is stored in an inside.
197
-
198
-
199
- === scan_file( filename )
200
-
201
- Parse the file described by the defined grammar.
202
- Token is stored in an inside.
203
-
204
-
205
- === next_token
206
-
207
- One token stored in the inside is taken out.
208
- The last returns nil.
209
-
210
-
211
- == Notice
212
-
213
- This specification is provisional and may be changed without a preliminary
214
- announcement.
215
-
19
+ -h --help print usage
20
+ --version print version
21
+ --copyright print copyright
22
+
23
+
24
+ == Default Output Filename
25
+
26
+ The destination file for foo.rex is foo.rex.rb.
27
+ To use, include the following in the Ruby source code file.
28
+
29
+ require 'foo.rex'
30
+
31
+
32
+ == Grammar File Format
33
+
34
+ A definition consists of a header section, a rule section,
35
+ and a footer section. The rule section includes one or more clauses.
36
+ Each clause starts with a keyword.
37
+
38
+ Summary:
39
+
40
+ [Header section]
41
+ "class" Foo
42
+ ["option"
43
+ [options] ]
44
+ ["inner"
45
+ [methods] ]
46
+ ["macro"
47
+ [macro-name regular-expression] ]
48
+ "rule"
49
+ [start-state] pattern [actions]
50
+ "end"
51
+ [Footer section]
52
+
53
+
54
+ === Grammar File Description Example
55
+
56
+ class Foo
57
+ macro
58
+ BLANK \s+
59
+ DIGIT \d+
60
+ rule
61
+ {BLANK}
62
+ {DIGIT} { [:NUMBER, text.to_i] }
63
+ . { [text, text] }
64
+ end
65
+
66
+
67
+ == Header Section ( Optional )
68
+
69
+ All of the contents described before the definitions in the rule section are
70
+ copied to the beginning of the output file.
71
+
72
+
73
+ == Footer Section ( Optional )
74
+
75
+ All the contents described after the definitions in the rule section are
76
+ copied to the end of the output file.
77
+
78
+
79
+ == Rule Section
80
+
81
+ The rule section starts at the line beginning with the "class" keyword
82
+ and ends at the line beginning with the "end" keyword.
83
+ The class name is specified after the "class" keyword.
84
+ If a module name is specified, the class will be included in the module.
85
+ A class that inherits Racc::Parser is generated.
86
+
87
+
88
+ === Example of Rule Section Definition
89
+
90
+ class Foo
91
+ class Bar::Foo
92
+
93
+
94
+ == Option Section ( Optional )
95
+
96
+ This section begins with the "option" keyword.
97
+
98
+ "ignorecase" ignore the character case when pattern matching
99
+ "stub" append stub main for debugging
100
+ "independent" independent mode, do not inherit Racc.
101
+
102
+
103
+ == Inner Section for User Code ( Optional )
104
+
105
+ This section begins with the "inner" keyword.
106
+ The contents defined here are defined by the contents of the class
107
+ of the generated scanner.
108
+
109
+
110
+ == Macro Section ( Optional )
111
+
112
+ This section begins with the "macro" keyword.
113
+ A name is assigned to one regular expression.
114
+ A space character (0x20) can be included by using a backslash \ to escape.
115
+
116
+
117
+ === Example of Macro Definition
118
+
119
+ DIGIT \d+
120
+ IDENT [a-zA-Z_][a-zA-Z0-9_]*
121
+ BLANK [\ \t]+
122
+ REMIN \/\*
123
+ REMOUT \*\/
124
+
125
+
126
+ == Rule Section
127
+
128
+ This section begins with the "rule" keyword.
129
+
130
+ [state] pattern [actions]
131
+
132
+
133
+ === state: Start State ( Optional )
134
+
135
+ A start state is indicated by an identifier beginning with ":", a Ruby symbol.
136
+ If uppercase letters follow the ":", the state becomes an exclusive start state.
137
+ If lowercase letters follow the ":", the state becomes an inclusive start state.
138
+ The initial value and the default value of a start state are nil.
139
+
140
+
141
+ === pattern: String Pattern
142
+
143
+ A regular expression specifies a character string.
144
+ A regular expression description may include a macro definition enclosed
145
+ by curly braces { }.
146
+ A macro definition is used when the regular expression includes whitespace.
147
+
148
+
149
+ === actions: Processing Actions ( Optional )
150
+
151
+ An action is executed when the pattern is matched.
152
+ The action defines the process for creating the appropriate token.
153
+ A token is a two-element array containing a type and a value, or is nil.
154
+ The following elements can be used to create a token.
155
+
156
+ lineno Line number ( Read Only )
157
+ text Matched string ( Read Only )
158
+ state Start state ( Read/Write )
159
+
160
+ The action is a block of Ruby code enclosed by { }.
161
+ Do not use functions that exit the block and change the control flow.
162
+ ( return, exit, next, break, ... )
163
+ If the action is omitted, the matched character string is discarded,
164
+ and the process advances to the next scan.
165
+
166
+
167
+ === Example of Rule Section Definition
168
+
169
+ {REMIN} { state = :REM ; [:REM_IN, text] }
170
+ :REM {REMOUT} { state = nil ; [:REM_OUT, text] }
171
+ :REM (.+)(?={REMOUT}) { [:COMMENT, text] }
172
+ {BLANK}
173
+ -?{DIGIT} { [:NUMBER, text.to_i] }
174
+ {WORD} { [:word, text] }
175
+ . { [text, text] }
176
+
177
+ == Comments ( Optional )
178
+
179
+ Any text following a "#" to the end of the line becomes a comment.
180
+
181
+
182
+ == Using the Generated Class
183
+
184
+ === scan_setup( str )
185
+
186
+ Initializes the scanner with the str string argument.
187
+ This is redefined and used.
188
+
189
+
190
+ === scan_str( str )
191
+
192
+ Parses the string described in the defined grammar.
193
+ The tokens are stored internally.
194
+
195
+
196
+ === scan_file( filename )
197
+
198
+ Reads in a file described in the defined grammar.
199
+ The tokens are stored internally.
200
+
201
+
202
+ === next_token
203
+
204
+ The tokens stored internally are extracted one by one.
205
+ When there are no more tokens, nil is returned.
206
+
207
+
208
+ == Notice
209
+
210
+ This specification is provisional and may be changed without prior notice.
211
+