| Module | Voodoo::Validator |
| In: |
voodoo/validator.rb
|
Functionality for validating Voodoo code.
| BINOPS | = | [:add, :and, :asr, :bsr, :div, :'get-byte', :'get-word', :mod, :mul, :or, :rol, :ror, :shl, :shr, :sub, :xor] | Expressions that take two arguments | |
| VARARG_EXPRS | = | [:call, :'tail-call'] | Expressions that take zero or more parameters | |
| EXPRS | = | BINOPS + VARARG_EXPRS + [:not] | Symbols that may occur as the first word of an expression | |
| STATEMENTS | = | [:block, :call, :goto, :ifeq, :ifge, :ifgt, :ifle, :iflt, :ifne, :label, :let, :return, :set, :'set-byte', :'set-word', :'tail-call'] | Symbols that are a valid start of a statement | |
| TOP_LEVELS | = | [:align, :byte, :export, :function, :import, :section, :string, :word] + STATEMENTS | Symbols that are valid at top-level | |
| NTH | = | ['First', 'Second', 'Third'] |
Tests that an expression has at least n parameters. Raises a ValidationError if this is not the case.
Tests that an expression has exactly n parameters. Raises a ValidationError if this is not the case.
Tests that parameters to an expression are values (integers, symbols, or at-expressions), and raises ValidationError if this is not the case. If ns is nil (default) all parameters should me values. Alternatively, ns may be a range or array containing the indices of the parameters that should be values.
Validates an expression. Returns true if the expression is valid. Raises ValidationError if the expression is not valid.
Validates a statement. Returns true if the statement is valid. Raises ValidationError if the statement is not valid.
Validates a top-level directive. Returns true if the directive is valid. Raises ValidationError if the directive is not valid.