multi-line tests
This commit is contained in:
		
							parent
							
								
									638548c37b
								
							
						
					
					
						commit
						c496ae5cdd
					
				| 
						 | 
				
			
			@ -224,11 +224,37 @@ describe("parsing new line", ()=>{
 | 
			
		|||
   y=2
 | 
			
		||||
   y }
 | 
			
		||||
  x`, "{:x = {:y = {2}; :y}; :x}")
 | 
			
		||||
  MySkip.testParse(`
 | 
			
		||||
  testParse(`
 | 
			
		||||
  x={
 | 
			
		||||
   y=2
 | 
			
		||||
   y 
 | 
			
		||||
   }
 | 
			
		||||
  x`, "{:x = {:y = {2}; :y}; :x}") //FIXME: Bracket after new line is not parsed
 | 
			
		||||
  x`, "{:x = {:y = {2}; :y}; :x}")
 | 
			
		||||
  testParse(`
 | 
			
		||||
  x=1
 | 
			
		||||
  y=2
 | 
			
		||||
  z=3
 | 
			
		||||
  `, "{:x = {1}; :y = {2}; :z = {3}}")
 | 
			
		||||
  testParse(`
 | 
			
		||||
  f={
 | 
			
		||||
    x=1
 | 
			
		||||
    y=2
 | 
			
		||||
    z=3
 | 
			
		||||
    x+y+z
 | 
			
		||||
  }
 | 
			
		||||
  `, "{:f = {:x = {1}; :y = {2}; :z = {3}; (::add (::add :x :y) :z)}}")
 | 
			
		||||
  testParse(`
 | 
			
		||||
    a |>
 | 
			
		||||
    b |>
 | 
			
		||||
    c |>
 | 
			
		||||
    d 
 | 
			
		||||
  `, "{(::d (::c (::b :a)))}")
 | 
			
		||||
  testParse(`
 | 
			
		||||
    a |>
 | 
			
		||||
    b |>
 | 
			
		||||
    c |>
 | 
			
		||||
    d +
 | 
			
		||||
    e
 | 
			
		||||
  `, "{(::add (::d (::c (::b :a))) :e)}")
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -676,7 +676,7 @@ function peg$parse(input, options) {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  function peg$parseinnerBlockOrExpression() {
 | 
			
		||||
    var s0, s1, s2, s3, s4, s5, s6;
 | 
			
		||||
    var s0, s1;
 | 
			
		||||
 | 
			
		||||
    var key = peg$currPos * 56 + 3;
 | 
			
		||||
    var cached = peg$resultsCache[key];
 | 
			
		||||
| 
						 | 
				
			
			@ -687,96 +687,7 @@ function peg$parse(input, options) {
 | 
			
		|||
      return cached.result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    s0 = peg$currPos;
 | 
			
		||||
    if (input.charCodeAt(peg$currPos) === 123) {
 | 
			
		||||
      s1 = peg$c0;
 | 
			
		||||
      peg$currPos++;
 | 
			
		||||
    } else {
 | 
			
		||||
      s1 = peg$FAILED;
 | 
			
		||||
      if (peg$silentFails === 0) { peg$fail(peg$e0); }
 | 
			
		||||
    }
 | 
			
		||||
    if (s1 !== peg$FAILED) {
 | 
			
		||||
      s2 = peg$parse_nl();
 | 
			
		||||
      s3 = peg$parsearray_statements();
 | 
			
		||||
      if (s3 !== peg$FAILED) {
 | 
			
		||||
        s4 = peg$currPos;
 | 
			
		||||
        s5 = peg$parsestatementSeparator();
 | 
			
		||||
        if (s5 !== peg$FAILED) {
 | 
			
		||||
          s6 = peg$parseexpression();
 | 
			
		||||
          if (s6 !== peg$FAILED) {
 | 
			
		||||
            s4 = s6;
 | 
			
		||||
          } else {
 | 
			
		||||
            peg$currPos = s4;
 | 
			
		||||
            s4 = peg$FAILED;
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          peg$currPos = s4;
 | 
			
		||||
          s4 = peg$FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        if (s4 !== peg$FAILED) {
 | 
			
		||||
          s5 = peg$parse_();
 | 
			
		||||
          if (input.charCodeAt(peg$currPos) === 125) {
 | 
			
		||||
            s6 = peg$c1;
 | 
			
		||||
            peg$currPos++;
 | 
			
		||||
          } else {
 | 
			
		||||
            s6 = peg$FAILED;
 | 
			
		||||
            if (peg$silentFails === 0) { peg$fail(peg$e1); }
 | 
			
		||||
          }
 | 
			
		||||
          if (s6 !== peg$FAILED) {
 | 
			
		||||
            peg$savedPos = s0;
 | 
			
		||||
            s0 = peg$f3(s3, s4);
 | 
			
		||||
          } else {
 | 
			
		||||
            peg$currPos = s0;
 | 
			
		||||
            s0 = peg$FAILED;
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          peg$currPos = s0;
 | 
			
		||||
          s0 = peg$FAILED;
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        peg$currPos = s0;
 | 
			
		||||
        s0 = peg$FAILED;
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      peg$currPos = s0;
 | 
			
		||||
      s0 = peg$FAILED;
 | 
			
		||||
    }
 | 
			
		||||
    if (s0 === peg$FAILED) {
 | 
			
		||||
      s0 = peg$currPos;
 | 
			
		||||
      if (input.charCodeAt(peg$currPos) === 123) {
 | 
			
		||||
        s1 = peg$c0;
 | 
			
		||||
        peg$currPos++;
 | 
			
		||||
      } else {
 | 
			
		||||
        s1 = peg$FAILED;
 | 
			
		||||
        if (peg$silentFails === 0) { peg$fail(peg$e0); }
 | 
			
		||||
      }
 | 
			
		||||
      if (s1 !== peg$FAILED) {
 | 
			
		||||
        s2 = peg$parse_nl();
 | 
			
		||||
        s3 = peg$parseexpression();
 | 
			
		||||
        if (s3 !== peg$FAILED) {
 | 
			
		||||
          s4 = peg$parse_();
 | 
			
		||||
          if (input.charCodeAt(peg$currPos) === 125) {
 | 
			
		||||
            s5 = peg$c1;
 | 
			
		||||
            peg$currPos++;
 | 
			
		||||
          } else {
 | 
			
		||||
            s5 = peg$FAILED;
 | 
			
		||||
            if (peg$silentFails === 0) { peg$fail(peg$e1); }
 | 
			
		||||
          }
 | 
			
		||||
          if (s5 !== peg$FAILED) {
 | 
			
		||||
            peg$savedPos = s0;
 | 
			
		||||
            s0 = peg$f4(s3);
 | 
			
		||||
          } else {
 | 
			
		||||
            peg$currPos = s0;
 | 
			
		||||
            s0 = peg$FAILED;
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          peg$currPos = s0;
 | 
			
		||||
          s0 = peg$FAILED;
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        peg$currPos = s0;
 | 
			
		||||
        s0 = peg$FAILED;
 | 
			
		||||
      }
 | 
			
		||||
    s0 = peg$parsequotedInnerBlock();
 | 
			
		||||
    if (s0 === peg$FAILED) {
 | 
			
		||||
      s0 = peg$currPos;
 | 
			
		||||
      s1 = peg$parseexpression();
 | 
			
		||||
| 
						 | 
				
			
			@ -786,7 +697,6 @@ function peg$parse(input, options) {
 | 
			
		|||
      }
 | 
			
		||||
      s0 = s1;
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -832,7 +742,7 @@ function peg$parse(input, options) {
 | 
			
		|||
          s4 = peg$FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        if (s4 !== peg$FAILED) {
 | 
			
		||||
          s5 = peg$parse_();
 | 
			
		||||
          s5 = peg$parse_nl();
 | 
			
		||||
          if (input.charCodeAt(peg$currPos) === 125) {
 | 
			
		||||
            s6 = peg$c1;
 | 
			
		||||
            peg$currPos++;
 | 
			
		||||
| 
						 | 
				
			
			@ -872,7 +782,7 @@ function peg$parse(input, options) {
 | 
			
		|||
        s2 = peg$parse_nl();
 | 
			
		||||
        s3 = peg$parseexpression();
 | 
			
		||||
        if (s3 !== peg$FAILED) {
 | 
			
		||||
          s4 = peg$parse_();
 | 
			
		||||
          s4 = peg$parse_nl();
 | 
			
		||||
          if (input.charCodeAt(peg$currPos) === 125) {
 | 
			
		||||
            s5 = peg$c1;
 | 
			
		||||
            peg$currPos++;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,19 +76,15 @@ outerBlock
 | 
			
		|||
    { return nodeBlock([finalExpression])}
 | 
			
		||||
    
 | 
			
		||||
innerBlockOrExpression  
 | 
			
		||||
  = '{' _nl statements:array_statements  finalExpression: (statementSeparator @expression)  _ '}'
 | 
			
		||||
	  { statements.push(finalExpression) 
 | 
			
		||||
    	return nodeBlock(statements) }
 | 
			
		||||
  / '{' _nl finalExpression: expression  _ '}'
 | 
			
		||||
	  { return nodeBlock([finalExpression]) }
 | 
			
		||||
  = quotedInnerBlock
 | 
			
		||||
  / finalExpression: expression
 | 
			
		||||
    { return nodeBlock([finalExpression])}
 | 
			
		||||
 | 
			
		||||
quotedInnerBlock  
 | 
			
		||||
  = '{' _nl statements:array_statements  finalExpression: (statementSeparator @expression)  _ '}'
 | 
			
		||||
  = '{' _nl statements:array_statements  finalExpression: (statementSeparator @expression)  _nl '}'
 | 
			
		||||
	  { statements.push(finalExpression) 
 | 
			
		||||
    	return nodeBlock(statements) }
 | 
			
		||||
  / '{' _nl finalExpression: expression  _ '}'
 | 
			
		||||
  / '{' _nl finalExpression: expression  _nl '}'
 | 
			
		||||
	  { return nodeBlock([finalExpression]) }
 | 
			
		||||
 | 
			
		||||
array_statements
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user