Skip to content

Commit

Permalink
try to get operators in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Jun 17, 2024
1 parent 0a4a8bf commit 387dc64
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
25 changes: 24 additions & 1 deletion editors/emacs/swarm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,30 @@
"Syntax table for `swarm-mode'.")

(defvar swarm-mode-operators-regexp
(regexp-opt '(":" "->" "=" "<-" "+" "*" "/" "-") t)
(regexp-opt
'(
"-"
"=="
"!="
"<"
">"
"<="
">="
"||"
"&&"
"+"
"-"
"*"
"/"
"\\"
":"
"^"
"++"
"$"
"->"
"<-"
"=")
t)
"Regexp that recognizes operators for swarm language.")

(defvar swarm-mode-commands-regexp
Expand Down
3 changes: 2 additions & 1 deletion editors/vim/swarm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syn keyword Builtins self parent base if inl inr case fst snd force undefined fa
syn keyword Command noop wait selfdestruct move backup volume path push stride turn grab harvest sow ignite place ping give equip unequip make has equipped count drill use build salvage reprogram say listen log view appear create halt time scout whereami waypoint structure floorplan hastag tagmembers detect resonate density sniff chirp watch surveil heading blocked scan upload ishere isempty meet meetall whoami setname random run return try swap atomic instant installkeyhandler teleport as robotnamed robotnumbered knows
syn keyword Direction east north west south down forward left back right
syn keyword Type "\<[A-Z][a-zA-Z_]*\>"
syn keyword Operators - == != < > <= >= || && + - * / \ : ^ ++ $ -> <- =


syn match Comment "//.*$"
Expand All @@ -20,5 +21,5 @@ hi def link Comment Comment
hi def link MultilineComment Comment
hi def link Brackets Keyword
hi def link Colon Keyword
hi def link String String
hi def link String String
hi def link Number Number
13 changes: 6 additions & 7 deletions src/swarm-doc/Swarm/Doc/Gen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ generateDocs = \case
generateEditorKeywords :: EditorType -> IO ()
generateEditorKeywords = \case
Emacs -> do
putStrLn "(x-builtins '("
T.putStr $ builtinFunctionList Emacs
putStrLn "))\n(x-commands '("
putStrLn "(defvar swarm-mode-builtins '("
T.putStr $ builtinFunctionList Emacs <> "))"
putStrLn "\n(defvar swarm-mode-commands '("
T.putStr $ keywordsCommands Emacs
T.putStr $ keywordsDirections Emacs
putStrLn "))\n(x-operators '("
T.putStr $ operatorNames Emacs
putStrLn "))"
T.putStr $ keywordsDirections Emacs <> "))"
putStrLn "\n (defvar swarm-mode-operators '("
T.putStr $ operatorNames Emacs <> "))"
VSCode -> do
putStrLn "Functions and commands:"
T.putStrLn $ builtinFunctionList VSCode <> "|" <> keywordsCommands VSCode
Expand Down
2 changes: 1 addition & 1 deletion test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ testEditorFiles =
"editors"
[ testGroup
"VS Code"
[ testTextInVSCode "operators" (const Keyword.operatorNames)
[ testTextInVSCode "operators" Keyword.operatorNames
, testTextInVSCode "builtin" Keyword.builtinFunctionList
, testTextInVSCode "commands" Keyword.keywordsCommands
, testTextInVSCode "directions" Keyword.keywordsDirections
Expand Down

0 comments on commit 387dc64

Please sign in to comment.