From 91e30d927cb979b65857d5ec9b456ccc0c603f6c Mon Sep 17 00:00:00 2001 From: Oscar Creator Date: Wed, 24 Apr 2024 19:13:52 +0200 Subject: [PATCH] feat: add support for Expect and update Tcl --- README.md | 1 + languages.json | 12 +++++++++--- tests/data/Expect.exp | 44 +++++++++++++++++++++++++++++++++++++++++++ tests/data/Tcl.tcl | 29 ++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 tests/data/Expect.exp create mode 100644 tests/data/Tcl.tcl diff --git a/README.md b/README.md index 1c9e55a06..c6e5a85a9 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,7 @@ Elvish EmacsDevEnv Emojicode Erlang +Expect Factor FEN Fish diff --git a/languages.json b/languages.json index efdd6de45..857955232 100644 --- a/languages.json +++ b/languages.json @@ -433,6 +433,12 @@ "line_comment": ["%"], "extensions": ["erl", "hrl"] }, + "Expect": { + "name": "Expect", + "line_comment": [["#", ";#"]], + "quotes": [["\\\"", "\\\""]], + "extensions": ["exp"] + }, "Factor": { "line_comment": ["!", "#!"], "multi_line_comments": [["/*", "*/"]], @@ -1434,9 +1440,9 @@ "extensions": ["sv", "svh"] }, "Tcl": { - "name": "TCL", - "line_comment": ["#"], - "quotes": [["\\\"", "\\\""], ["'", "'"]], + "name": "Tcl", + "line_comment": [["#", ";#"]], + "quotes": [["\\\"", "\\\""]], "extensions": ["tcl"] }, "Tera": { diff --git a/tests/data/Expect.exp b/tests/data/Expect.exp new file mode 100644 index 000000000..c46d707a5 --- /dev/null +++ b/tests/data/Expect.exp @@ -0,0 +1,44 @@ +# 44 lines 27 code 9 comments 10 blanks + +## +# foo function doing stuff +# +proc foo {bar {baz 5} \ + {not_used "hi mom"}} { + puts $bar ;# print out bar + # sum bar + baz + set foo_res [expr $bar + $baz] + return $foo_res +} + +proc #weird {} { + return -code 5 +} + + +puts "hello world ####" + +puts #Alsovalid# ;# comment here! +puts {;#and this} +puts {really anything -$#;/ /\ \ -_'@?` "\".$?"!'][¨@ is allowed in curly braces} + +puts "3 == [foo 1 2] and 6 == [foo 2]" + +set function "#weird" +set code [catch {[$function]}] +puts "$code == 5" + +# And now onto expect specific +spawn "bash" "-c" "sleep 2; echo regex_pattern" + +set timeout 5 ;# this is 5 seconds +expect { + -re "regex_pattern" { + puts "and then this when it's found 'match' == $expect_out(0,string)" + } + timeout { + # if no match after 5 seconds + } +} + +after 500 diff --git a/tests/data/Tcl.tcl b/tests/data/Tcl.tcl new file mode 100644 index 000000000..5c35712df --- /dev/null +++ b/tests/data/Tcl.tcl @@ -0,0 +1,29 @@ +# 29 lines 17 code 6 comments 7 blanks + +## +# foo function doing stuff +# +proc foo {bar {baz 5} \ + {not_used "hi mom"}} { + puts $bar ;# print out bar + # sum bar + baz + set foo_res [expr $bar + $baz] + return $foo_res +} + +proc #weird {} { + return -code 5 +} + + +puts "hello world ####" + +puts #Alsovalid# ;# comment here! +puts {;#and this} +puts {really anything -$#;/ /\ \ -_'@?` "\".$?"!'][¨@ is allowed in curly braces} + +puts "3 == [foo 1 2] and 6 == [foo 2]" + +set function "#weird" +set code [catch {[$function]}] +puts "$code == 5"