Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0fd9d99
Semantic highlighting support
JonasAlaif May 15, 2023
e89c730
Initial work to add lsp support
JonasAlaif May 31, 2023
a57e307
Add even more features
JonasAlaif Jun 9, 2023
bf34ffb
Merge
JonasAlaif Jul 18, 2023
00611a7
Fix merge issues
JonasAlaif Jul 18, 2023
4d66c5c
Improve some parsing errors
JonasAlaif Jul 18, 2023
14a1c09
Update failing cases, add parsing edge case
JonasAlaif Jul 19, 2023
b5bd646
Fix parsing error, due to ambiguity between typed call and bracketed exp
JonasAlaif Jul 19, 2023
7217062
Crazy cuts everywhere
JonasAlaif Jul 19, 2023
44b9931
Merge with more cuts version
JonasAlaif Jul 19, 2023
23fb785
Start work on cleaning up to merge
JonasAlaif Sep 14, 2023
580d869
Merge update
JonasAlaif Sep 14, 2023
f6b9b24
Finish reworking FastParser
JonasAlaif Sep 18, 2023
f834348
Almost done
JonasAlaif Sep 19, 2023
b4fadb2
Compiling
JonasAlaif Sep 20, 2023
b44cd21
Actually compiles
JonasAlaif Sep 20, 2023
1765fc3
Merge in master
JonasAlaif Jan 16, 2024
fbff41c
Fix merge issues
JonasAlaif Jan 16, 2024
db65342
Clean up document symbol story
JonasAlaif Jan 16, 2024
d565779
Fix parsing issue
JonasAlaif Jan 16, 2024
c379b5f
Fix some bugs
JonasAlaif Jan 17, 2024
e10bc6f
Various fixes
JonasAlaif Jan 18, 2024
cb50467
Many small fixes
JonasAlaif Jan 19, 2024
9a7b8e3
Tests pass
JonasAlaif Feb 5, 2024
69cce40
Separate out LSP features
JonasAlaif Feb 5, 2024
1fe8211
Add brackets and fix bug
JonasAlaif Feb 5, 2024
5d790d5
Merge branch 'master' into sem-highlight
JonasAlaif Feb 5, 2024
2ea6b5a
Fix tests
JonasAlaif Feb 5, 2024
87e0cfc
Fix test annotations
JonasAlaif Feb 5, 2024
a019534
Remove LSP features
JonasAlaif Feb 5, 2024
ba47657
Clean up PR
JonasAlaif Feb 5, 2024
00810c5
Clean up tests code
JonasAlaif Feb 5, 2024
190a7e0
Update test to remove `Rational`
JonasAlaif Feb 5, 2024
b74d831
Fix macro issues
JonasAlaif Feb 7, 2024
edf9ba2
Fix issue with macros
JonasAlaif Feb 8, 2024
899478e
Fix issue with directly nested macros
JonasAlaif Feb 8, 2024
0ef69a4
Parse members in order and keep parsing after error
JonasAlaif Feb 8, 2024
4653da0
Merge branch 'master' into sem-highlight
JonasAlaif Feb 8, 2024
b8dfd93
Fix warnings in 2 test cases
JonasAlaif Feb 9, 2024
61b94bd
Return source position in parse error
JonasAlaif Feb 9, 2024
f0ccd0c
Clear up `PAssign` error message
JonasAlaif Feb 9, 2024
0930905
Minor cleanup
marcoeilers Feb 11, 2024
9f67812
Adapted test annotation
marcoeilers Feb 11, 2024
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
19 changes: 17 additions & 2 deletions src/main/scala/viper/silver/ast/Position.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import java.nio.file.Path
import viper.silver.parser.FastParser

/** A trait describing the position of occurrence of an AST node. */
sealed trait Position
sealed trait Position {
def deltaColumn(delta: Int): Position
}

/** Describes ''no location'' for cases where a `Position` is expected, but not available. */
case object NoPosition extends Position {
override def deltaColumn(delta: Int): Position = this
override def toString = "<no position>"
}

Expand All @@ -25,6 +28,7 @@ trait HasLineColumn extends Position {

def column: Int

def deltaColumn(delta: Int): HasLineColumn
override def toString = s"$line.$column"
}

Expand All @@ -35,7 +39,9 @@ trait HasIdentifier extends HasLineColumn {
def id: String
}

case class LineColumnPosition(line: Int, column: Int) extends HasLineColumn
case class LineColumnPosition(line: Int, column: Int) extends HasLineColumn {
override def deltaColumn(delta: Int): HasLineColumn = LineColumnPosition(line, column + delta)
}

/** Represents a source code position by referencing a file, a line and a column.
* Optionally, an additional end position can be specified.
Expand All @@ -57,6 +63,7 @@ trait AbstractSourcePosition extends HasLineColumn {
private def lineColComponent(lc_pos: HasLineColumn) =
s"${lc_pos.line}.${lc_pos.column}"

override def deltaColumn(delta: Int): AbstractSourcePosition
override def toString: String = end match {
case None =>
s"$fileComponent${lineColComponent(start)}"
Expand All @@ -79,12 +86,16 @@ object AbstractSourcePosition {
class SourcePosition(val file: Path, val start: HasLineColumn, val end: Option[HasLineColumn])
extends AbstractSourcePosition with StructuralEquality {

override def deltaColumn(delta: Int): SourcePosition =
new SourcePosition(file, start.deltaColumn(delta), end.map(_.deltaColumn(delta)))
protected val equalityDefiningMembers: Seq[Object] =
file :: start :: end :: Nil
}

class IdentifierPosition(val file: Path, val start: HasLineColumn, val end: Option[HasLineColumn], val id: String)
extends AbstractSourcePosition with StructuralEquality with HasIdentifier {
override def deltaColumn(delta: Int): IdentifierPosition =
new IdentifierPosition(file, start.deltaColumn(delta), end.map(_.deltaColumn(delta)), id)
protected val equalityDefiningMembers: Seq[Object] =
file :: start :: end :: id :: Nil
}
Expand Down Expand Up @@ -122,13 +133,16 @@ case class TranslatedPosition(pos: AbstractSourcePosition) extends AbstractSourc
val file: Path = pos.file
val start: HasLineColumn = pos.start
val end: Option[HasLineColumn] = pos.end
override def deltaColumn(delta: Int): TranslatedPosition =
new TranslatedPosition(pos.deltaColumn(delta))
}

case class FilePosition(file: Path, vline: Int, col: Int) extends util.parsing.input.Position with HasLineColumn {
override lazy val line: Int = vline
override lazy val column: Int = col
override lazy val lineContents: String = toString
override lazy val toString: String = s"${file.getFileName}@$vline.$col"
override def deltaColumn(delta: Int): FilePosition = FilePosition(file, vline, col + delta)
}

/**
Expand All @@ -138,4 +152,5 @@ case class FilePosition(file: Path, vline: Int, col: Int) extends util.parsing.i
*/
case class VirtualPosition(identifier: String) extends Position {
override def toString: String = identifier
override def deltaColumn(delta: Int): VirtualPosition = this
}
4 changes: 2 additions & 2 deletions src/main/scala/viper/silver/ast/Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ case class Program(domains: Seq[Domain], fields: Seq[Field], functions: Seq[Func

lazy val groundTypeInstances = DomainInstances.findNecessaryTypeInstances(this)

lazy val members: Seq[Member with Serializable] = domains ++ fields ++ functions ++ predicates ++ methods
val members: Seq[Member with Serializable] = domains ++ fields ++ functions ++ predicates ++ methods ++ extensions
Comment thread
marcoeilers marked this conversation as resolved.

def findFieldOptionally(name: String): Option[Field] = this.fieldsByName.get(name)

Expand Down Expand Up @@ -826,7 +826,7 @@ object BackendFunc {
/**
* The Extension Member trait provides the way to expand the Ast to include new Top Level declarations
*/
trait ExtensionMember extends Member{
trait ExtensionMember extends Member with Serializable {
def extensionSubnodes: Seq[Node]
def prettyPrint: PrettyPrintPrimitives#Cont
}
6 changes: 4 additions & 2 deletions src/main/scala/viper/silver/ast/utility/Consistency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,15 @@ object Consistency {
val argVars = args.map(_.localVar).toSet
var s = Seq.empty[ConsistencyError]

for (a@LocalVarAssign(l, _) <- b if argVars.contains(l)) {
// Suppressing "pattern var a in value $anonfun is never used: use a wildcard `_` or suppress this warning with `a@_`" warning using `(true || a == a)`
for (a@LocalVarAssign(l, _) <- b if argVars.contains(l) && (true || a == a)) {
s :+= ConsistencyError(s"$a is a reassignment of formal argument $l.", a.pos)
}
for (c@MethodCall(_, _, targets) <- b; t <- targets if argVars.contains(t)) {
s :+= ConsistencyError(s"$c is a reassignment of formal argument $t.", c.pos)
}
for (n@NewStmt(l, _) <- b if argVars.contains(l)){
// Suppressing "pattern var n in value $anonfun is never used: use a wildcard `_` or suppress this warning with `n@_`" warning using `(true || n == n)`
for (n@NewStmt(l, _) <- b if argVars.contains(l) && (true || n == n)) {
Comment thread
marcoeilers marked this conversation as resolved.
Outdated
s :+= ConsistencyError(s"$n is a reassignment of formal argument $l.", n.pos)
}
s
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/viper/silver/ast/utility/Expressions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ object Expressions {
| _: MultisetExp
| _: MapExp
| _: ForPerm
| _: Exists
Comment thread
marcoeilers marked this conversation as resolved.
Outdated
| _: Forall
=> true
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/scala/viper/silver/ast/utility/FileLoader.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package viper.silver.ast.utility

import java.nio.file.Path
import scala.io.Source
import scala.util.{Using, Try}

trait FileLoader {
def loadContent(path: Path): Try[String]
}

trait DiskLoader extends FileLoader {
override def loadContent(path: Path): Try[String] = {
Using(Source.fromFile(path.toFile()))(_.mkString)
}
}

object DiskLoader extends DiskLoader
Loading