Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions lexers/embedded/gleam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
</rule>
<rule pattern="(type)\b">
<token type="Keyword"/>
<push state="typename"/>
</rule>
<rule pattern="(True|False)\b">
<token type="KeywordConstant"/>
Expand Down Expand Up @@ -63,39 +62,23 @@
<rule pattern="[{}()\[\],]|[#(]|\.\.|&lt;&gt;|&lt;&lt;|&gt;&gt;">
<token type="Punctuation"/>
</rule>
<rule pattern="[+\-*/%!=&lt;&gt;&amp;|.]|&lt;-">
<rule pattern=":|-&gt;">
<token type="Operator"/>
</rule>
<rule pattern=":|-&gt;">
<rule pattern="[+\-*/%!=&lt;&gt;&amp;|.]|&lt;-">
<token type="Operator"/>
<push state="typename"/>
</rule>
<rule pattern="([a-z_][A-Za-z0-9_]*)(\()">
<bygroups>
<token type="NameFunction"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="([A-Z][A-Za-z0-9_]*)(\()">
<bygroups>
<token type="NameClass"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="([a-z_]\w*[!?]?)">
<token type="Name"/>
</rule>
</state>
<state name="typename">
<rule pattern="\s+">
<token type="TextWhitespace"/>
</rule>
<rule pattern="[A-Z][A-Za-z0-9_]*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
<rule pattern="([a-z_]\w*[!?]?)">
<token type="Name"/>
</rule>
</state>
<state name="string">
Expand Down
14 changes: 14 additions & 0 deletions lexers/testdata/gleam.actual
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ pub fn main() {
io.debug(reverse_list([1, 2, 3, 4, 5]))
io.debug(reverse_list(["a", "b", "c", "d", "e"]))
}

pub fn plus_one(x: Int) -> Int {
x + 1
}

pub type Message {
RegisterFeed(String, Poller)
}

pub type Table = Subject(Message)

pub fn start() -> Table {
todo
}
75 changes: 74 additions & 1 deletion lexers/testdata/gleam.expected
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,78 @@
{"type":"Punctuation","value":"]))"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
{"type":"TextWhitespace","value":"\n\n"},
{"type":"Keyword","value":"pub"},
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"fn"},
{"type":"TextWhitespace","value":" "},
{"type":"NameFunction","value":"plus_one"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"x"},
{"type":"Operator","value":":"},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Int"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Int"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Name","value":"x"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"+"},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"Keyword","value":"pub"},
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"type"},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Message"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"NameClass","value":"RegisterFeed"},
{"type":"Punctuation","value":"("},
{"type":"NameClass","value":"String"},
{"type":"Punctuation","value":","},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Poller"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"Keyword","value":"pub"},
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"type"},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Table"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Subject"},
{"type":"Punctuation","value":"("},
{"type":"NameClass","value":"Message"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"Keyword","value":"pub"},
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"fn"},
{"type":"TextWhitespace","value":" "},
{"type":"NameFunction","value":"start"},
{"type":"Punctuation","value":"()"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"NameClass","value":"Table"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Keyword","value":"todo"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"}
]