refactor: use scalafmt to format code
This commit is contained in:
		
							
								
								
									
										12
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| end_of_line = lf | ||||
| insert_final_newline = true | ||||
|  | ||||
| [Makefile] | ||||
| indent_style = tab | ||||
| indent_size = 4 | ||||
|  | ||||
							
								
								
									
										2
									
								
								.scalafmt.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.scalafmt.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| version = 3.8.6 | ||||
| runner.dialect = scala36 | ||||
| @@ -3,13 +3,14 @@ package wacc | ||||
| import parsley.{Success, Failure} | ||||
|  | ||||
| def main(args: Array[String]): Unit = { | ||||
|     println("hello WACC!") | ||||
|   println("hello WACC!") | ||||
|  | ||||
|     args.headOption match { | ||||
|         case Some(expr) => parser.parse(expr) match { | ||||
|             case Success(x) => println(s"$expr = $x") | ||||
|             case Failure(msg) => println(msg) | ||||
|         } | ||||
|         case None => println("please enter an expression") | ||||
|     } | ||||
|   args.headOption match { | ||||
|     case Some(expr) => | ||||
|       parser.parse(expr) match { | ||||
|         case Success(x)   => println(s"$expr = $x") | ||||
|         case Failure(msg) => println(msg) | ||||
|       } | ||||
|     case None => println("please enter an expression") | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -5,12 +5,12 @@ import parsley.token.Lexer | ||||
| import parsley.token.descriptions.* | ||||
|  | ||||
| object lexer { | ||||
|     private val desc = LexicalDesc.plain.copy( | ||||
|         // your configuration goes here | ||||
|     ) | ||||
|     private val lexer = Lexer(desc) | ||||
|   private val desc = LexicalDesc.plain.copy( | ||||
|     // your configuration goes here | ||||
|   ) | ||||
|   private val lexer = Lexer(desc) | ||||
|  | ||||
|     val integer = lexer.lexeme.integer.decimal | ||||
|     val implicits = lexer.lexeme.symbol.implicits | ||||
|     def fully[A](p: Parsley[A]): Parsley[A] = lexer.fully(p) | ||||
|   val integer = lexer.lexeme.integer.decimal | ||||
|   val implicits = lexer.lexeme.symbol.implicits | ||||
|   def fully[A](p: Parsley[A]): Parsley[A] = lexer.fully(p) | ||||
| } | ||||
|   | ||||
| @@ -7,14 +7,14 @@ import lexer.implicits.implicitSymbol | ||||
| import lexer.{integer, fully} | ||||
|  | ||||
| object parser { | ||||
|     def parse(input: String): Result[String, BigInt] = parser.parse(input) | ||||
|     private val parser = fully(expr) | ||||
|      | ||||
|     private val add = (x: BigInt, y: BigInt) => x + y | ||||
|     private val sub = (x: BigInt, y: BigInt) => x - y | ||||
|   def parse(input: String): Result[String, BigInt] = parser.parse(input) | ||||
|   private val parser = fully(expr) | ||||
|  | ||||
|     private lazy val expr: Parsley[BigInt] = | ||||
|         chain.left1(integer | "(" ~> expr <~ ")")( | ||||
|             ("+" as add) | ("-" as sub) | ||||
|         ) | ||||
|   private val add = (x: BigInt, y: BigInt) => x + y | ||||
|   private val sub = (x: BigInt, y: BigInt) => x - y | ||||
|  | ||||
|   private lazy val expr: Parsley[BigInt] = | ||||
|     chain.left1(integer | "(" ~> expr <~ ")")( | ||||
|       ("+" as add) | ("-" as sub) | ||||
|     ) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user