-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
390 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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"/> | ||
</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 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.