
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
weyland
Advanced tools
Weyland provides a way to define computing languages and a generic lexer to lex/tokenize/perform lexical analysis on them.
Install with: pip install weyland
Weyland offers the class Language to define the languages.
A language is initialized with:
Token types are defined by a name and a list of matching patterns. A pattern is a standard Python regular expression.
Weyland comes with a list of predefined patterns stored in the dictionary PATTERNS for standard definitions like string, integer and float.
The unwanted definitions are a list of matched tokens which do not belong to the language. For example, 18A will be matched by the two tokens integer, identifier if we define only these two. By adding a token type wrong_integer corresponding to it, we will prevent this behavior but we must declare that is an error. We do that by putting wrong_integer in the list of unwanted definitions.
The last dictionary is a dictionary of tags to apply on lists of token types. It can help for syntax coloration for example.
Below is a short example:
LANGUAGES['ash'] = Language('ash',
{
'keyword' : [ 'if', 'else', 'end', 'elif'],
'boolean' : ['true', 'false'],
'nil' : ['nil'],
'identifier': PATTERNS['IDENTIFIER'],
'number' : ['\\d+', '\\d+\\.\\d+'],
'string' : PATTERNS['STRINGS'],
'operator' : ['\\+', '\\*', '-', '/', '%', '\\^'],
'separator' : ['\\(', '\\)', ','],
'comment' : ['--(?!\\[\\[).*(\n|$)'],
'newline' : PATTERNS['NEWLINES'],
'blank' : PATTERNS['BLANKS'],
'wrong_int' : PATTERNS['WRONG_INTEGER'],
},
['wrong_integer'],
{
'ante_identifier': ['function'],
}
)
Pattern with [\\s\\S] (anything including new line) are treated as multiline regex.
Weyland provides also a lexer class to perform lexical analysis on a text given a defined language.
A lexer is initialized with a language definition (an instance of the class Language) and a list of tokens to discard when lexing.
The function lex transform a given text to a list of tokens.
The algorithm is rather simple:
The lexer can emit a html representation of the tokens: each tokens is emitted in a span of class language name - token type except raws tokens which are emitted as their value.
The tokens are defined by:
A set of lexers and associated languages are available in the package:
List of websites about Weyland:
FAQs
An alternative way to write regular expression and a lexer using them.
We found that weyland demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.