compiler/tests/PPCompiledExpressionGrammarTest.st
changeset 438 20598d7ce9fa
child 452 9f4558b3be66
equal deleted inserted replaced
437:54b3bc9e3987 438:20598d7ce9fa
       
     1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPCompositeParserTest subclass:#PPCompiledExpressionGrammarTest
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-Tests-ExpressionGrammar'
       
    10 !
       
    11 
       
    12 !PPCompiledExpressionGrammarTest class methodsFor:'as yet unclassified'!
       
    13 
       
    14 resources
       
    15 	^ (OrderedCollection with: PPCompiledExpressionGrammarResource)
       
    16 		addAll: super resources;
       
    17 		yourself
       
    18 ! !
       
    19 
       
    20 !PPCompiledExpressionGrammarTest methodsFor:'as yet unclassified'!
       
    21 
       
    22 compilerArguments
       
    23 	^ PPCArguments default
       
    24 		profile: true;
       
    25 		ll: true;
       
    26 		yourself
       
    27 !
       
    28 
       
    29 context
       
    30 	^ PPCContext new
       
    31 !
       
    32 
       
    33 parserClass
       
    34 	^ Smalltalk at: #PPCompiledExpressionGrammar
       
    35 !
       
    36 
       
    37 parserInstanceFor: aSymbol
       
    38 	^ (Smalltalk at: #PPCompiledExpressionGrammar) new startSymbol: aSymbol
       
    39 !
       
    40 
       
    41 testNumber
       
    42 	result := self parse: '1' rule: #number.
       
    43 	self assert: result = 1.
       
    44 !
       
    45 
       
    46 testTerm
       
    47 	result := self parse: '1 + 2' rule: #term.
       
    48 	self assert: result size = 3.
       
    49 	self assert: result first = 1.
       
    50 	self assert: result second inputValue = '+'.
       
    51 	self assert: result third = 2.
       
    52 	
       
    53 ! !
       
    54