diff --git a/lexers/embedded/beef.xml b/lexers/embedded/beef.xml new file mode 100644 index 000000000..031a220f2 --- /dev/null +++ b/lexers/embedded/beef.xml @@ -0,0 +1,120 @@ + + + Beef + beef + *.bf + text/x-beef + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lexers/testdata/beef.actual b/lexers/testdata/beef.actual new file mode 100644 index 000000000..1b02c9dcf --- /dev/null +++ b/lexers/testdata/beef.actual @@ -0,0 +1,22 @@ +using System; + +class Program +{ + public static void Main() + { + Console.WriteLine("Hello, World!"); + } + + // Try! propagates file and parsing errors down the call stack + static Result Parse(StringView filePath, List outValues) + { + var fs = scope FileStream(); + Try!(fs.Open(filePath)); + for (var lineResult in scope StreamReader(fs).Lines) + { + for (let elem in Try!(lineResult).Split(',')) + outValues.Add(Try!(float.Parse(elem))); + } + return .Ok; + } +} \ No newline at end of file diff --git a/lexers/testdata/beef.expected b/lexers/testdata/beef.expected new file mode 100644 index 000000000..2171f8def --- /dev/null +++ b/lexers/testdata/beef.expected @@ -0,0 +1,141 @@ +[ + {"type":"Keyword","value":"using"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"System"}, + {"type":"Punctuation","value":";"}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"class"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Program"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordDeclaration","value":"public"}, + {"type":"Text","value":" "}, + {"type":"KeywordDeclaration","value":"static"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"void"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Main"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"Console"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"WriteLine"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"Hello, World!\""}, + {"type":"Punctuation","value":");"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n "}, + {"type":"CommentSingle","value":"// Try! propagates file and parsing errors down the call stack"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordDeclaration","value":"static"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Result"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"Keyword","value":"void"}, + {"type":"Punctuation","value":"\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Parse"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"StringView"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"filePath"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"List"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"KeywordType","value":"float"}, + {"type":"Punctuation","value":"\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"outValues"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"var"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"fs"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"scope"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"FileStream"}, + {"type":"Punctuation","value":"();"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"Try"}, + {"type":"Punctuation","value":"!("}, + {"type":"Name","value":"fs"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"Open"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"filePath"}, + {"type":"Punctuation","value":"));"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"for"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"KeywordType","value":"var"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"lineResult"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"in"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"scope"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"StreamReader"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"fs"}, + {"type":"Punctuation","value":")."}, + {"type":"Name","value":"Lines"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"for"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"elem"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"in"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Try"}, + {"type":"Punctuation","value":"!("}, + {"type":"Name","value":"lineResult"}, + {"type":"Punctuation","value":")."}, + {"type":"Name","value":"Split"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringChar","value":"','"}, + {"type":"Punctuation","value":"))"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"outValues"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"Add"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"Try"}, + {"type":"Punctuation","value":"!("}, + {"type":"KeywordType","value":"float"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"Parse"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"elem"}, + {"type":"Punctuation","value":")));"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"return"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"Ok"}, + {"type":"Punctuation","value":";"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"} +]