PPStartOfWordParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 16 Jun 2015 07:49:21 +0100
changeset 491 82b272c7dc37
parent 427 a7f5e6de19d2
permissions -rw-r--r--
Codegen: added support for smart action node compiling. Avoid creation of intermediate result collection for action nodes if all references to action block's argument (i.e., the nodes collection) is in form of: * <nodes> at: <numeric constant> * <nodes> first (second, third...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
427
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser' }"
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Smalltalk }"
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
PPParser subclass:#PPStartOfWordParser
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'PetitParser-Parsers'
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
!PPStartOfWordParser methodsFor:'as yet unclassified'!
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
acceptsEpsilon
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	^ true
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
!
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
parseOn: aPPContext
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	aPPContext atEnd ifTrue: [  
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	].
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
	(aPPContext position == 0) ifTrue: [ 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
		(aPPContext peek isAlphaNumeric) ifTrue: [ 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
			^ #startOfWord
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
		] ifFalse: [ 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
			^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	 	]
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
	].
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
	aPPContext back.
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
	aPPContext peek isAlphaNumeric ifTrue: [
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	].
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
	aPPContext next.
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
	
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
	^ aPPContext peek isAlphaNumeric ifTrue: [ #startOfWord ] ifFalse: [ 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
		PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
	]
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
	
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
! !
a7f5e6de19d2 Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42