Skip to content

Commit

Permalink
Merge branch 'boolean_parser' into number_parser
Browse files Browse the repository at this point in the history
# Conflicts:
#	compiler-access/src/main/scala/org/alephium/ralph/lsp/access/compiler/parser/soft/ExpressionParser.scala
  • Loading branch information
simerplaha committed Jan 13, 2025
2 parents 537f0e7 + dde53f1 commit e78775b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import org.alephium.ralph.lsp.access.compiler.parser.soft.ast.{SoftAST, Token}

object BooleanParser {

def parseOrFail[Unknown: P]: P[SoftAST.TokenDocumented[Token.PrimitiveBoolean]] =
P(TokenParser.parseOrFail(Token.True) | TokenParser.parseOrFail(Token.False))
def parseOrFail[Unknown: P]: P[SoftAST.TokenExpression[Token.PrimitiveBoolean]] =
P(boolean) map (SoftAST.TokenExpression(_))

def parseOrFailExpression[Unknown: P]: P[SoftAST.TokenExpression[Token.PrimitiveBoolean]] =
P(parseOrFail) map (SoftAST.TokenExpression(_))
private def boolean[Unknown: P]: P[SoftAST.TokenDocumented[Token.PrimitiveBoolean]] =
P(TokenParser.parseOrFail(Token.True) | TokenParser.parseOrFail(Token.False))

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private object ExpressionParser {
AnnotationParser.parseOrFail |
TupleParser.parseOrFail |
NumberParser.parseOrFail |
BooleanParser.parseOrFailExpression |
BooleanParser.parseOrFail |
IdentifierParser.parseOrFail
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import org.scalatest.OptionValues._
class BooleanParserSpec extends AnyWordSpec with Matchers {

"true" in {
parseBoolean("true") shouldBe True(indexOf(">>true<<"))
parseBoolean("true").token shouldBe True(indexOf(">>true<<"))
}

"false" in {
parseBoolean("false") shouldBe False(indexOf(">>false<<"))
parseBoolean("false").token shouldBe False(indexOf(">>false<<"))
}

"boolean with comments" in {
Expand All @@ -24,7 +24,7 @@ class BooleanParserSpec extends AnyWordSpec with Matchers {
parseBoolean {
s"""// comment
|$bool""".stripMargin
}
}.token

// has comment
result.documentation.value.comments should have size 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object TestParser {
def parseIdentifier(code: String): SoftAST.IdentifierAST =
runSoftParser(IdentifierParser.parseOrFail(_))(code)

def parseBoolean(code: String): SoftAST.TokenDocumented[Token.PrimitiveBoolean] =
def parseBoolean(code: String): SoftAST.TokenExpression[Token.PrimitiveBoolean] =
runSoftParser(BooleanParser.parseOrFail(_))(code)

def parseNumber(code: String): SoftAST.Number =
Expand Down

0 comments on commit e78775b

Please sign in to comment.