@@ -130,8 +130,9 @@ type CompileError struct {
130
130
type Label struct {
131
131
// Label's level (e.g: "error", "warning", "info", "note", "help").
132
132
Level string
133
+ // Origin of the code where the error occurred.
133
134
CodeOrigin string
134
- // The code span covered by the label.
135
+ // The code span highlighted by this label.
135
136
Span Span
136
137
// Text associated to the label.
137
138
Text string
@@ -204,7 +205,21 @@ func (c *Compiler) initialize() error {
204
205
205
206
// AddSource adds some YARA source code to be compiled.
206
207
//
207
- // This function can be called multiple times.
208
+ // This method may be invoked multiple times to add several sets of
209
+ // YARA rules. If the rules provided in src contain errors that prevent
210
+ // compilation, the first error encountered will be returned. Additionally,
211
+ // the compiler will store this error, along with any others discovered
212
+ // during compilation, which can be accessed using [Compiler.Errors].
213
+ //
214
+ // Even if a previous invocation resulted in a compilation error, you can
215
+ // continue calling this method for adding more rules. In such cases, any
216
+ // rules that failed to compile will not be included in the final compiled
217
+ // [Rules].
218
+ //
219
+ // When adding rules to the compiler you can also provide a string containing
220
+ // information about the origin of the rules using the [WithOrigin] option.
221
+ // The origin is usually the path of the file containing the rules, but it can
222
+ // be any string that conveys information about the origin of the rules.
208
223
//
209
224
// Examples:
210
225
//
@@ -361,7 +376,7 @@ func (c *Compiler) Errors() []CompileError {
361
376
// Build creates a [Rules] object containing a compiled version of all the
362
377
// YARA rules previously added to the compiler.
363
378
//
364
- // Once this function is called the compiler is reset to its initial state
379
+ // Once this method is called the compiler is reset to its initial state
365
380
// (i.e: the state it had after NewCompiler returned).
366
381
func (c * Compiler ) Build () * Rules {
367
382
r := & Rules {cRules : C .yrx_compiler_build (c .cCompiler )}
0 commit comments