-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
fumico-core/src/main/kotlin/io/typecraft/fumico/core/evaluator/expression/EvaluateIf.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.typecraft.fumico.core.evaluator.expression | ||
|
||
import io.typecraft.fumico.core.Ast | ||
import io.typecraft.fumico.core.FumicoEvaluated | ||
import io.typecraft.fumico.core.FumicoEvaluationContext | ||
|
||
|
||
fun FumicoEvaluationContext.evaluate(node: Ast.Child.Expression.If): FumicoEvaluated { | ||
TODO("boolean type should be implemented") | ||
} |
36 changes: 36 additions & 0 deletions
36
fumico-core/src/main/kotlin/io/typecraft/fumico/core/parser/IfParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.typecraft.fumico.core.parser | ||
|
||
import io.typecraft.fumico.core.Ast | ||
import io.typecraft.fumico.core.tokenizer.Token | ||
import io.typecraft.parsecom.functions.mapResult | ||
import io.typecraft.parsecom.functions.opt | ||
import io.typecraft.parsecom.functions.preceded | ||
import io.typecraft.parsecom.functions.tuple | ||
|
||
val parseIf by lazy { | ||
mapResult( | ||
tuple( | ||
token(Token.Kind.KeywordIf), | ||
skipHorizontalSpaces, | ||
::parseExpression, | ||
skipHorizontalSpaces, | ||
token(Token.Kind.PunctuationHyphenMinus), | ||
token(Token.Kind.PunctuationGreaterThanSign), | ||
skipAllSpaces, | ||
::parseExpression, | ||
opt( | ||
tuple( | ||
skipAllSpaces, | ||
token(Token.Kind.KeywordElse), | ||
skipHorizontalSpaces, | ||
token(Token.Kind.PunctuationHyphenMinus), | ||
token(Token.Kind.PunctuationGreaterThanSign), | ||
skipAllSpaces, | ||
::parseExpression, | ||
) | ||
) | ||
) | ||
) { (_, _, condition, _, _, _, _, then, otherwise) -> | ||
Ast.Child.Expression.If(condition, then, otherwise?.seventh) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters