compiler/tests/PPCCodeGeneratorTest.st
changeset 471 7544e517db96
parent 464 f6d77fee9811
child 481 34ee0d3c72e7
equal deleted inserted replaced
470:f59795ddcd90 471:7544e517db96
     7 		arguments'
     7 		arguments'
     8 	classVariableNames:''
     8 	classVariableNames:''
     9 	poolDictionaries:''
     9 	poolDictionaries:''
    10 	category:'PetitCompiler-Tests-Visitors'
    10 	category:'PetitCompiler-Tests-Visitors'
    11 !
    11 !
       
    12 
    12 
    13 
    13 !PPCCodeGeneratorTest methodsFor:'as yet unclassified'!
    14 !PPCCodeGeneratorTest methodsFor:'as yet unclassified'!
    14 
    15 
    15 context	
    16 context	
    16     ^ context := PPCProfilingContext new
    17     ^ context := PPCProfilingContext new
   753     self assert: parser parse: 'abc' to: #($a $b $c) end: 3.
   754     self assert: parser parse: 'abc' to: #($a $b $c) end: 3.
   754     self assert: parser parse: 'abcd' to: #( $a $b $c ) end: 3.
   755     self assert: parser parse: 'abcd' to: #( $a $b $c ) end: 3.
   755     self assert: parser fail: 'ab'.
   756     self assert: parser fail: 'ab'.
   756 !
   757 !
   757 
   758 
       
   759 testSequenceOptInlined1
       
   760     | a b bOpt |
       
   761 
       
   762     a := $a asParser asCompilerNode.
       
   763     b := $b asParser asCompilerNode.
       
   764     bOpt := PPCOptionalNode new
       
   765                 child:  b ;
       
   766                 markForInline;
       
   767                 yourself.
       
   768     node := PPCSequenceNode new
       
   769         children: { a . bOpt };
       
   770         yourself.
       
   771     self compileTree: node.
       
   772     
       
   773     self assert: parser parse: 'ab' to: #($a $b ) end: 2.
       
   774     self assert: parser parse: 'a' to: #( $a nil ) end: 1.
       
   775 
       
   776     "Created: / 22-05-2015 / 11:47:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   777 !
       
   778 
       
   779 testSequenceOptInlined2
       
   780     | a b bOpt |
       
   781 
       
   782     a := $a asParser asCompilerNode.
       
   783     a markForInline.
       
   784     b := $b asParser asCompilerNode.
       
   785     b markForInline.
       
   786     bOpt := PPCOptionalNode new
       
   787                 child:  b ;
       
   788                 markForInline;
       
   789                 yourself.
       
   790     node := PPCSequenceNode new
       
   791         children: { a . bOpt };
       
   792         yourself.
       
   793     self compileTree: node.
       
   794     
       
   795     self assert: parser parse: 'ab' to: #($a $b ) end: 2.
       
   796     self assert: parser parse: 'a' to: #( $a nil ) end: 1.
       
   797 
       
   798     "Created: / 22-05-2015 / 11:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   799 !
       
   800 
   758 testStarAnyNode
   801 testStarAnyNode
   759     arguments cacheFirstFollow: false.
   802     arguments cacheFirstFollow: false.
   760     node := PPCStarAnyNode new 
   803     node := PPCStarAnyNode new 
   761         child: PPCNilNode new; 
   804         child: PPCNilNode new; 
   762         yourself.
   805         yourself.
   945     self assert: parser parse: 'foo' to: $f end: 1.
   988     self assert: parser parse: 'foo' to: $f end: 1.
   946     self assert: parser parse: 'bar' to: $b end: 1.
   989     self assert: parser parse: 'bar' to: $b end: 1.
   947     self assert: parser parse: '' to: nil.
   990     self assert: parser parse: '' to: nil.
   948 ! !
   991 ! !
   949 
   992 
       
   993 !PPCCodeGeneratorTest class methodsFor:'documentation'!
       
   994 
       
   995 version_HG
       
   996 
       
   997     ^ '$Changeset: <not expanded> $'
       
   998 ! !
       
   999