Skip to content

Commit

Permalink
Token: KwTrue/KwFalse extends Constant[Boolean]
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Mar 7, 2024
1 parent 92068bf commit 3d15f9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
case _: Constant.Symbol if !dialect.allowSymbolLiterals =>
syntaxError("Symbol literals are no longer allowed", at = token)
case Constant.Symbol(value) => Lit.Symbol(value)
case _: KwTrue => Lit.Boolean(true)
case _: KwFalse => Lit.Boolean(false)
case x: BooleanConstant => Lit.Boolean(x.value)
case _: KwNull => Lit.Null()
case t => unreachable(t)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ object Token {
val value: A
}
@branch abstract class NumericConstant[A <: ScalaNumber] extends Constant[A]
@branch abstract class BooleanConstant(val value: Boolean) extends Constant[Boolean]

@branch trait Keyword extends Token
@branch trait ModifierKeyword extends Keyword
Expand Down Expand Up @@ -61,7 +62,7 @@ object Token {
@fixed("enum") class KwEnum extends Keyword
@fixed("export") class KwExport extends Keyword
@fixed("extends") class KwExtends extends Keyword
@fixed("false") class KwFalse extends Literal
@fixed("false") class KwFalse extends BooleanConstant(false)
@fixed("final") class KwFinal extends ModifierKeyword
@fixed("finally") class KwFinally extends Keyword
@fixed("for") class KwFor extends Keyword
Expand All @@ -87,7 +88,7 @@ object Token {
@fixed("this") class KwThis extends Keyword
@fixed("throw") class KwThrow extends Keyword
@fixed("trait") class KwTrait extends Keyword
@fixed("true") class KwTrue extends Literal
@fixed("true") class KwTrue extends BooleanConstant(true)
@fixed("try") class KwTry extends Keyword
@fixed("type") class KwType extends Keyword
@fixed("val") class KwVal extends Keyword
Expand Down

0 comments on commit 3d15f9e

Please sign in to comment.