Scripal
Scripal
Scripal is a tool for string matching and text mining, meant to be an alternative to regular expressions. It tries to offer a very readable syntax, allowing comments and offering debugging facilities.
It comes as a standalone tool, as well as libraries or modules for programming languages like C++, C, Python, Java, JavaScript or C#.
Many operands are constructs used in modern programming languages, for example loops and conditionals.
Basic concepts
Scripal is a domain-specific language that compiles sources into bytecode.
It's optimized for speed and large strings or files. Scripal has a complexity of O(n), a significant advantage over regular expressions using backtracking. Next to matching and finding text in strings or files, Scripal may find similar text portions and calculate, how similar text fragments are, using string metrics.
Scripal can interpret numbers (hex, octal...), number ranges and other lexical elements. It allows templates for often used code.
Syntax
find a word that begins with the letter 'a':
match find(bow 'a')
match hex number in the range 0x0001-0xff00:
match ( hex [1,ff00] )
Find all telephone numbers in NANP format:
match find( '(' repeat[3]( digit ) ') ' repeat[3]( digit ) '-' repeat[4]( digit )); end; loop
Find the first integer number in the range 1 to 200:
match find ( [1,200] )
do we have an IPv4?:
match ( pure[0,255] '.' pure[0,255] '.' pure[0,255] '.' pure[0,255] )
find URLs:
match find( any( ~'http://'~'https://' ))
ifMatch {
match find( any( ',' space eol eos ))
endlast
}
loop;
Syntax errors are reported by the compiler.
Debug information
Set the debug switch and watch how the engine steps through the code. This feature supports the developer, in quickly finding flaws in sources or performance issues.
set operator 'match' at(0) start group set operator 'null' at(1) ...
Language support
Next to the standalone binary, there are language integrations for C++, C, Python, Java, JavaScript or C#.
See also
External links
References
This article "Scripal" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Scripal. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.
