Skip to content
Draft
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
3 changes: 2 additions & 1 deletion grammars/silver/compiler/definition/core/QName.sv
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ attribute typeScheme {} occurs on a,
annotation sourceLocation occurs on a =>
top::QNameLookup<a> ::= kindOfLookup::String dcls::[a] name::String l::Location
{
top.dcls = dcls;
top.dcls = uniqBy(\l::a r::a -> l.fullName == r.fullName,
sortBy(\l::a r::a -> l.fullName <= r.fullName, dcls));
top.found = !null(top.dcls); -- currently accurate
top.dcl =
if top.found then head(top.dcls)
Expand Down
5 changes: 4 additions & 1 deletion grammars/silver/compiler/definition/env/Env.sv
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ top::Env ::= d::[OccursDclInfo] e::Decorated Env
----------------------------------------------------------------------------------------------------

function searchEnvAll
attribute fullName {} occurs on a =>
[a] ::= search::String e::[EnvTree<a>]
{
return flatMap(searchEnvTree(search, _), e);
return uniqBy(\l::a r::a -> l.fullName == r.fullName,
sortBy(\l::a r::a -> l.fullName <= r.fullName,
flatMap(searchEnvTree(search, _), e)));
}

function searchEnv
Expand Down
2 changes: 1 addition & 1 deletion grammars/silver/compiler/driver/BuildProcess.sv
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ IOErrorable<Decorated Compilation> ::=

{--
- Given an environment and a grammar to build, returns a Compilation.
- Note that it's the caller's responsibility to actually evaluation that
- Note that it's the caller's responsibility to actually evaluate that
- compilation's actions.
-}
function buildRun
Expand Down
15 changes: 15 additions & 0 deletions grammars/silver/core/List.sv
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,21 @@ function mergeBy -- do not use
else head(l2) :: mergeBy(lte, l1, tail(l2));
}

function uniq

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc comment for this function, maybe? Also I'm not sure I understand what this does - remove only sequential duplicates in a list? Couldn't you just use nubBy instead of uniqBy(sortBy(...))? The list should be small enough in the typical case that sorting first is probably slower, anyway.

Eq a => [a] ::= l::[a]
{ return uniqBy(eq, l); }
function uniqBy
[a] ::= eq::(Boolean ::= a a) l::[a]
{
return case l of
| [] -> []
| [x] -> [x]
| x1::x2::xs -> if eq(x1, x2)
then uniqBy(eq, x2::xs)
else x1::uniqBy(eq, x2::xs)
end;
}

function groupBy
[[a]] ::= eq::(Boolean ::= a a) l::[a]
{
Expand Down
8 changes: 4 additions & 4 deletions support/vim/syntax/sv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ hi def link svlangDocParam Function
hi def link svlangDocSeeTagParam Function
hi def link svlangTermAttr Keyword

set autoindent
set expandtab
set shiftwidth=2
set softtabstop=2
setlocal autoindent
setlocal expandtab
setlocal shiftwidth=2
setlocal softtabstop=2

let b:current_syntax = "sv"