-
-
Notifications
You must be signed in to change notification settings - Fork 445
Add Hare lexer #882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Hare lexer #882
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Hare lexer
Co-authored-by: Sebastian <sebastian@sebsite.pw> Co-authored-by: Alexey Yerin <yyp@disroot.org> Co-authored-by: Mohammed Anas <triallax@tutanota.com>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <lexer> | ||
| <config> | ||
| <name>Hare</name> | ||
| <alias>hare</alias> | ||
| <filename>*.ha</filename> | ||
| <mime_type>text/x-hare</mime_type> | ||
| </config> | ||
| <rules> | ||
| <state name="string"> | ||
| <rule pattern="""> | ||
| <token type="LiteralString"/> | ||
| <pop depth="1"/> | ||
| </rule> | ||
| <rule pattern="\\([\\0abfnrtv"']|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8})"> | ||
| <token type="LiteralStringEscape"/> | ||
| </rule> | ||
| <rule pattern="[^\\"\n]+"> | ||
| <token type="LiteralString"/> | ||
| </rule> | ||
| <rule pattern="\\"> | ||
| <token type="LiteralString"/> | ||
| </rule> | ||
| </state> | ||
| <state name="root"> | ||
| <rule pattern="[\s\n]+"> | ||
| <token type="TextWhitespace"/> | ||
| </rule> | ||
| <rule pattern="@[a-z]+"> | ||
| <token type="NameDecorator"/> | ||
triallax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </rule> | ||
| <rule pattern="//.*\n"> | ||
| <token type="CommentSingle"/> | ||
| </rule> | ||
| <rule pattern="""> | ||
| <token type="LiteralString"/> | ||
| <push state="string"/> | ||
| </rule> | ||
| <rule pattern="`[^`]*`"> | ||
| <token type="LiteralString"/> | ||
| </rule> | ||
| <rule pattern="'(\\[\\0abfnrtv"']||\\(x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8})|[^\\'])'"> | ||
| <token type="LiteralStringChar"/> | ||
| </rule> | ||
| <rule pattern="(0|[1-9]\d*)\.\d+([eE][+-]?\d+)?(f32|f64)?"> | ||
| <token type="LiteralNumberFloat"/> | ||
| </rule> | ||
| <rule pattern="(0|[1-9]\d*)([eE][+-]?\d+)?(f32|f64)"> | ||
| <token type="LiteralNumberFloat"/> | ||
| </rule> | ||
| <rule pattern="0x[0-9a-fA-F]+\.[0-9a-fA-F]+([pP][+-]?\d+(f32|f64)?)?"> | ||
| <token type="LiteralNumberFloat"/> | ||
| </rule> | ||
| <rule pattern="0x[0-9a-fA-F]+[pP][+-]?\d+(f32|f64)"> | ||
| <token type="LiteralNumberFloat"/> | ||
| </rule> | ||
| <rule pattern="0x[0-9a-fA-F]+(z|[iu](8|16|32|64)?)?"> | ||
| <token type="LiteralNumberHex"/> | ||
| </rule> | ||
| <rule pattern="0o[0-7]+(z|[iu](8|16|32|64)?)?"> | ||
| <token type="LiteralNumberOct"/> | ||
| </rule> | ||
| <rule pattern="0b[01]+(z|[iu](8|16|32|64)?)?"> | ||
| <token type="LiteralNumberBin"/> | ||
| </rule> | ||
| <rule pattern="(0|[1-9]\d*)([eE][+-]?\d+)?(z|[iu](8|16|32|64)?)?"> | ||
| <token type="LiteralNumberInteger"/> | ||
| </rule> | ||
| <rule pattern="[~!%^&*+=|?:<>/-]|[ai]s\b|\.\.\."> | ||
| <token type="Operator"/> | ||
| </rule> | ||
| <rule pattern="[()\[\],.{};]"> | ||
| <token type="Punctuation"/> | ||
| </rule> | ||
| <rule pattern="use\b"> | ||
| <token type="KeywordNamespace"/> | ||
| </rule> | ||
| <rule pattern="(_|align|break|const|continue|else|enum|export|for|if|return|static|struct|offset|union|fn|free|assert|abort|alloc|let|len|def|type|match|switch|case|append|delete|insert|defer|yield|vastart|vaarg|vaend)\b"> | ||
| <token type="Keyword"/> | ||
| </rule> | ||
| <rule pattern="(size)([\s\n]*)(\()"> | ||
| <bygroups> | ||
| <token type="Keyword" /> | ||
| <token type="TextWhitespace" /> | ||
| <token type="Punctuation" /> | ||
| </bygroups> | ||
| </rule> | ||
| <rule pattern="(str|size|rune|bool|int|uint|uintptr|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|null|void|nullable|valist|opaque|never)\b"> | ||
| <token type="KeywordType"/> | ||
| </rule> | ||
| <rule pattern="(true|false)\b"> | ||
| <token type="NameBuiltin"/> | ||
| </rule> | ||
| <rule pattern="[a-zA-Z_]\w*"> | ||
| <token type="Name"/> | ||
| </rule> | ||
| </state> | ||
| </rules> | ||
| </lexer> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // test comment | ||
| use bufio::*; | ||
| use fmt, os::exec = exec; | ||
| use time; | ||
|
|
||
| type foo = struct { | ||
| bar: str, | ||
| baz: time::duration, | ||
| }; | ||
|
|
||
| export type e = enum u8 { | ||
| a, b, c | ||
| }; | ||
|
|
||
| const arr: [_]foo= [ | ||
| foo { bar = "This is a \"string\"!", baz = 25 * time::MINUTE }, | ||
| foo { bar = `This is also a | ||
| string`, baz = 5 * time::SECOND}, | ||
| ]; | ||
|
|
||
| let c = 'a'; // char | ||
| let d = 0b1010u16; | ||
| let e: size = 32z; | ||
| let g = 0xffa31u32 + 0o3u32; | ||
|
|
||
| export fn main() void = { | ||
| fmt::println("{}", size(int))!; | ||
|
|
||
| for (let i = 0z; i < 5; i += 1) { | ||
| fmt::println("{}", i); | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.