mirror of
				https://github.com/GayPizzaSpecifications/pork.git
				synced 2025-11-04 01:49:39 +00:00 
			
		
		
		
	fn -> func
This commit is contained in:
		@ -1,5 +1,5 @@
 | 
				
			|||||||
/* fibonacci sequence */
 | 
					/* fibonacci sequence */
 | 
				
			||||||
fn fib(n) {
 | 
					func fib(n) {
 | 
				
			||||||
  if n == 0
 | 
					  if n == 0
 | 
				
			||||||
    then 0
 | 
					    then 0
 | 
				
			||||||
  else if n == 1
 | 
					  else if n == 1
 | 
				
			||||||
@ -7,7 +7,7 @@ fn fib(n) {
 | 
				
			|||||||
  else fib(n - 1) + fib(n - 2)
 | 
					  else fib(n - 1) + fib(n - 2)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main() {
 | 
					func main() {
 | 
				
			||||||
  result = fib(20)
 | 
					  result = fib(20)
 | 
				
			||||||
  println(result)
 | 
					  println(result)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
fn main() {
 | 
					func main() {
 | 
				
			||||||
  three = 3
 | 
					  three = 3
 | 
				
			||||||
  two = 2
 | 
					  two = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -170,7 +170,7 @@ class Parser(source: PeekableSource<Token>, val attribution: NodeAttribution) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private fun readFunctionDeclaration(): FunctionDeclaration = within {
 | 
					  private fun readFunctionDeclaration(): FunctionDeclaration = within {
 | 
				
			||||||
    expect(TokenType.Fn)
 | 
					    expect(TokenType.Func)
 | 
				
			||||||
    val name = readSymbolRaw()
 | 
					    val name = readSymbolRaw()
 | 
				
			||||||
    expect(TokenType.LeftParentheses)
 | 
					    expect(TokenType.LeftParentheses)
 | 
				
			||||||
    val arguments = collect(TokenType.RightParentheses, TokenType.Comma) { readSymbolRaw() }
 | 
					    val arguments = collect(TokenType.RightParentheses, TokenType.Comma) { readSymbolRaw() }
 | 
				
			||||||
@ -181,7 +181,7 @@ class Parser(source: PeekableSource<Token>, val attribution: NodeAttribution) {
 | 
				
			|||||||
  fun readDeclaration(): Declaration {
 | 
					  fun readDeclaration(): Declaration {
 | 
				
			||||||
    val token = peek()
 | 
					    val token = peek()
 | 
				
			||||||
    return when (token.type) {
 | 
					    return when (token.type) {
 | 
				
			||||||
      TokenType.Fn -> readFunctionDeclaration()
 | 
					      TokenType.Func -> readFunctionDeclaration()
 | 
				
			||||||
      else -> throw RuntimeException(
 | 
					      else -> throw RuntimeException(
 | 
				
			||||||
        "Failed to parse token: ${token.type} '${token.text}' as" +
 | 
					        "Failed to parse token: ${token.type} '${token.text}' as" +
 | 
				
			||||||
          " declaration (index ${unsanitizedSource.currentIndex})"
 | 
					          " declaration (index ${unsanitizedSource.currentIndex})"
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ enum class TokenType(vararg properties: TokenTypeProperty) {
 | 
				
			|||||||
  If(Keyword("if"), KeywordFamily),
 | 
					  If(Keyword("if"), KeywordFamily),
 | 
				
			||||||
  Then(Keyword("then"), KeywordFamily),
 | 
					  Then(Keyword("then"), KeywordFamily),
 | 
				
			||||||
  Else(Keyword("else"), KeywordFamily),
 | 
					  Else(Keyword("else"), KeywordFamily),
 | 
				
			||||||
  Fn(Keyword("fn"), KeywordFamily),
 | 
					  Func(Keyword("func"), KeywordFamily),
 | 
				
			||||||
  Whitespace(CharConsumer { it == ' ' || it == '\r' || it == '\n' || it == '\t' }),
 | 
					  Whitespace(CharConsumer { it == ' ' || it == '\r' || it == '\n' || it == '\t' }),
 | 
				
			||||||
  BlockComment(CommentFamily),
 | 
					  BlockComment(CommentFamily),
 | 
				
			||||||
  LineComment(CommentFamily),
 | 
					  LineComment(CommentFamily),
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user