Created
March 14, 2015 13:00
-
-
Save Kakadu/0b5aa7118fcf17f21391 to your computer and use it in GitHub Desktop.
Scala code with FastParsers library and macro expanding with `-Ymacro-debug-lite`
This file contains hidden or 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
| Piece of code which was expanded. | |
| val trueValue = "true".toCharArray | |
| val falseValue = "false".toCharArray | |
| object KParser1 { | |
| import fastparsers.framework.implementations.FastParsersCharArray._ | |
| val kparser = FastParsersCharArray { | |
| def func1: Parser[Any] = func1 | falseValue | |
| } | |
| } | |
| Expanding starts here: | |
| performing macro expansion fastparsers.framework.implementations.FastParsersCharArray.FastParsersCharArray({ | |
| def func1: fastparsers.parsers.Parser[Any] = fastparsers.framework.implementations.FastParsersCharArray.baseParsers[Any](func1).|[Any](fastparsers.framework.implementations.FastParsersCharArray.lit(Hw.this.falseValue)); | |
| () | |
| }) at source-/home/kakadu/prog/ocaml/ppx_parsers/scala/hello1/src/main/scala/hw.scala,line-26,offset=820 | |
| { | |
| class fresh$macro$16 extends fastparsers.framework.implementations.FinalFastParserImpl { | |
| def <init>() = { | |
| super.<init>(); | |
| () | |
| }; | |
| import scala.collection.mutable.ListBuffer; | |
| import scala.reflect.runtime.universe._; | |
| @new scala.annotation.compileTimeOnly("can\'t be used outside of FastParser") def func1: fastparsers.parsers.Parser[Any] = $qmark$qmark$qmark; | |
| def func1(input$macro$1: Array[Char], fresh$macro$6: Int = 0): fastparsers.framework.parseresult.ParseResult[Any, String] @fastparsers.framework.saveAST(fastparsers.framework.implementations.FastParsersCharArray.baseParsers[Any](fastparsers.framework.implementations.FastParsersCharArray.call[Any]("func1")).$bar[Any](fastparsers.framework.implementations.FastParsersCharArray.lit(Hw.this.falseValue))) = { | |
| var error = " "; | |
| { | |
| var inputpos$macro$2 = fresh$macro$6; | |
| val inputsize$macro$3 = input$macro$1.size; | |
| { | |
| val inputpositioned$macro$4 = new fastparsers.tools.ToPosition.IndexedCharSeqToPosition(input$macro$1); | |
| { | |
| var success$macro$5 = false; | |
| var fresh$macro$7: Any = null; | |
| var fresh$macro$10: Any = null; | |
| var fresh$macro$15: Array[Char] = null; | |
| { | |
| val fresh$macro$8 = inputpos$macro$2; | |
| { | |
| { | |
| val fresh$macro$9 = func1(input$macro$1, inputpos$macro$2); | |
| success$macro$5 = fresh$macro$9.success; | |
| if (success$macro$5) | |
| { | |
| inputpos$macro$2 = fresh$macro$9.inputPos; | |
| fresh$macro$10 = fresh$macro$9.result | |
| } | |
| else | |
| error = fresh$macro$9.error | |
| }; | |
| if (success$macro$5.unary_$bang) | |
| { | |
| inputpos$macro$2 = fresh$macro$8; | |
| { | |
| val fresh$macro$14 = inputpos$macro$2; | |
| { | |
| var fresh$macro$13 = 0; | |
| val fresh$macro$12 = Hw.this.falseValue.length; | |
| while$2(){ | |
| if (inputpos$macro$2.$less(inputsize$macro$3).$amp$amp(input$macro$1(inputpos$macro$2).$eq$eq(' ').$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\t')).$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\n')).$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\r')))) | |
| { | |
| inputpos$macro$2 = inputpos$macro$2.$plus(1); | |
| while$2() | |
| } | |
| else | |
| () | |
| }; | |
| while$1(){ | |
| if (inputpos$macro$2.$less(inputsize$macro$3).$amp$amp(fresh$macro$13.$less(fresh$macro$12)).$amp$amp(input$macro$1(inputpos$macro$2).$eq$eq(Hw.this.falseValue.charAt(fresh$macro$13)))) | |
| { | |
| { | |
| fresh$macro$13 = fresh$macro$13.$plus(1); | |
| inputpos$macro$2 = inputpos$macro$2.$plus(1) | |
| }; | |
| while$1() | |
| } | |
| else | |
| () | |
| }; | |
| if (fresh$macro$13.$eq$eq(fresh$macro$12)) | |
| { | |
| success$macro$5 = true; | |
| fresh$macro$15 = Hw.this.falseValue | |
| } | |
| else | |
| { | |
| success$macro$5 = false; | |
| (); | |
| inputpos$macro$2 = fresh$macro$14 | |
| } | |
| } | |
| }; | |
| if (success$macro$5) | |
| fresh$macro$7 = fresh$macro$15 | |
| else | |
| () | |
| } | |
| else | |
| fresh$macro$7 = fresh$macro$10 | |
| } | |
| }; | |
| fastparsers.framework.parseresult.ParseResult(success$macro$5, error, if (success$macro$5) | |
| fresh$macro$7 | |
| else | |
| null, inputpos$macro$2) | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| val fresh$macro$17 = 0; | |
| new fresh$macro$16() | |
| } | |
This file contains hidden or 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
| package kakadu | |
| import fastparsers.input.InputWindow | |
| import fastparsers.parsers.Parser | |
| import scala.util.parsing.combinator._ | |
| import scala.util.parsing.input._ | |
| object Hw { | |
| val trueValue = "true".toCharArray | |
| val falseValue = "false".toCharArray | |
| object KParser1 { | |
| import fastparsers.framework.implementations.FastParsersCharArray._ | |
| val kparser = FastParsersCharArray { | |
| def func1: Parser[Any] = func1 | falseValue | |
| } | |
| } | |
| def main(args: Array[String]) = println("Hi!") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment