User:GermanDev/sandbox

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 co

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


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.