diff --git a/examples/fib.pork b/examples/fib.pork index 34e2345..050d712 100644 --- a/examples/fib.pork +++ b/examples/fib.pork @@ -1,5 +1,5 @@ /* fibonacci sequence */ -fn fib(n) { +func fib(n) { if n == 0 then 0 else if n == 1 @@ -7,7 +7,7 @@ fn fib(n) { else fib(n - 1) + fib(n - 2) } -fn main() { +func main() { result = fib(20) println(result) } diff --git a/examples/syntax.pork b/examples/syntax.pork index a141a20..c876612 100644 --- a/examples/syntax.pork +++ b/examples/syntax.pork @@ -1,4 +1,4 @@ -fn main() { +func main() { three = 3 two = 2 diff --git a/src/main/kotlin/gay/pizza/pork/parse/Parser.kt b/src/main/kotlin/gay/pizza/pork/parse/Parser.kt index ad3d34a..1238198 100644 --- a/src/main/kotlin/gay/pizza/pork/parse/Parser.kt +++ b/src/main/kotlin/gay/pizza/pork/parse/Parser.kt @@ -170,7 +170,7 @@ class Parser(source: PeekableSource, val attribution: NodeAttribution) { } private fun readFunctionDeclaration(): FunctionDeclaration = within { - expect(TokenType.Fn) + expect(TokenType.Func) val name = readSymbolRaw() expect(TokenType.LeftParentheses) val arguments = collect(TokenType.RightParentheses, TokenType.Comma) { readSymbolRaw() } @@ -181,7 +181,7 @@ class Parser(source: PeekableSource, val attribution: NodeAttribution) { fun readDeclaration(): Declaration { val token = peek() return when (token.type) { - TokenType.Fn -> readFunctionDeclaration() + TokenType.Func -> readFunctionDeclaration() else -> throw RuntimeException( "Failed to parse token: ${token.type} '${token.text}' as" + " declaration (index ${unsanitizedSource.currentIndex})" diff --git a/src/main/kotlin/gay/pizza/pork/parse/TokenType.kt b/src/main/kotlin/gay/pizza/pork/parse/TokenType.kt index 4d2b059..c2177ee 100644 --- a/src/main/kotlin/gay/pizza/pork/parse/TokenType.kt +++ b/src/main/kotlin/gay/pizza/pork/parse/TokenType.kt @@ -28,7 +28,7 @@ enum class TokenType(vararg properties: TokenTypeProperty) { If(Keyword("if"), KeywordFamily), Then(Keyword("then"), KeywordFamily), Else(Keyword("else"), KeywordFamily), - Fn(Keyword("fn"), KeywordFamily), + Func(Keyword("func"), KeywordFamily), Whitespace(CharConsumer { it == ' ' || it == '\r' || it == '\n' || it == '\t' }), BlockComment(CommentFamily), LineComment(CommentFamily),