📄 t-genmisc.st
字号:
!Object methodsFor: 'copyrights'!
tgenCopyright
"Bring up a read-only text window with the T-gen copyright notice."
"Object tgenCopyright"
| copyright aComposedTextView topView |
copyright := 'The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy.
This software is copyright (c) 1992 by Justin O. Graver.
All rights reserved, except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions:
(1) If any part of the source code for this software is distributed, then this notice must be included, unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation.
(2) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind.
Permission is NOT granted for the use of any author''s name in advertising or publicity relating to this software or products derived from it.
We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor.
Developed under the direction of Justin Graver.
Authors include: Justin Graver, Virat Hanvivatpong, and David Wilson.
Send any comments, suggestions, or defects to: graver@comm.mot.com.'.
aComposedTextView := ComposedTextView model: (ValueHolder with: copyright).
topView := ScheduledWindow new.
topView controller model: aComposedTextView model.
topView component: (LookPreferences edgeDecorator on: aComposedTextView).
topView label: TranslatorGenerator versionName , ' Copyright Notice'.
topView minimumSize: 470 @ 550.
aComposedTextView controller: NoController new.
topView open! !
!Character methodsFor: 'copying'!
copyUpToLast: char
^self! !
!Character methodsFor: 'converting'!
asString
"Answer the receiver converted into a String."
^String with: self! !
!Character class methodsFor: 'accessing untypeable characters'!
endOfInput
"Answer the Character representing ctrl-d ."
^self value: 4!
leftParenthesis
"Answer the Character representing a left parenthesis."
^self value: 40!
period
"Answer the Character representing a carriage period."
^self value: 46!
poundSign
"Answer the Character representing a pound sign."
^self value: 35!
rightParenthesis
"Answer the Character representing a right parenthesis."
^self value: 41! !
!Stream methodsFor: 'character writing'!
leftParenthesis
"Append a left parenthesis character to the receiver."
self nextPut: Character leftParenthesis!
period
"Append a period character to the receiver."
self nextPut: Character period!
poundSign
"Append a # character to the receiver."
self nextPut: Character poundSign!
rightParenthesis
"Append a right parenthesis character to the receiver."
self nextPut: Character rightParenthesis! !
WriteStream subclass: #RetractableWriteStream
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Streams'!
RetractableWriteStream comment:
'=================================================
Copyright (c) 1992 by Justin O. Graver.
All rights reserved (with exceptions).
For complete information evaluate "Object tgenCopyright."
=================================================
This class adds a ''backspace'' method and overrides several methods to correctly support this behavior.'!
!RetractableWriteStream methodsFor: 'positioning'!
backspace
"Backup one position, if possible. It may be best to signal an error when attempting to backup
past the beginning of the stream, but for now just do nothing."
self atBeginning ifFalse: [self skip: -1]! !
!RetractableWriteStream methodsFor: 'accessing'!
size
"Answer how many elements the receiver contains."
^position! !
!RetractableWriteStream methodsFor: 'testing'!
atBeginning
^position = 0! !
ReadStream subclass: #RetractableReadStream
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Streams'!
RetractableReadStream comment:
'=================================================
Copyright (c) 1992 by Justin O. Graver.
All rights reserved (with exceptions).
For complete information evaluate "Object tgenCopyright."
=================================================
This class adds a ''backspace'' method and overrides several methods to correctly support this behavior.'!
!RetractableReadStream methodsFor: 'positioning'!
backspace
"Backup one position, if possible. It may be best to signal an error when attempting to backup
past the beginning of the stream, but for now just do nothing."
self atBeginning ifFalse: [self skip: -1]! !
!RetractableReadStream methodsFor: 'testing'!
atBeginning
^position = 0! !
!RetractableReadStream methodsFor: 'accessing'!
current
"Answer the element at the current position or nil if at the beginning. This is useful for
rereading the stream after backspacing."
^self atBeginning
ifTrue: [nil]
ifFalse: [collection at: position]! !
!RetractableReadStream methodsFor: 'private'!
pastEnd
"The receiver has attempted to read past the end, answer an EOF indicator."
"NOTE: currently, this class is used only by T-gen so it is acceptable to use the end-of-input character
rather than nil to denote the end of the stream. However, in a more general context, it may
be desirable to change this back to nil. If this is done then either the transitionFor:ifNone:
method in class FSAState must be changed to check for nil as a transition symbol
(Dictionaries do not allow nil keys), or scanners must be changed to translate a nil character
to the end-of-input character. These changes affect what happens when a scanner runs out of
input in the middle of a token."
^Signal noHandlerSignal handle: [:ex | ex parameter proceedWith: (Character endOfInput)]
do: [self class endOfStreamSignal raiseRequestFrom: self]! !
!Object methodsFor: 'reconstructing'!
reconstructOn: aStream
self printOn: aStream!
reconstructOn: aStream using: dummy
self printOn: aStream! !
!Object methodsFor: 'testing'!
isAlternationNode
^false!
isConcatenationNode
^false!
isEpsilonNode
^false!
isTerminalNode
^false!
isFSAFinalState
^false!
isGrammarProduction
^false!
isItemSet
^false!
isLR0Item
^false!
isLR1Item
^false!
isNonterminal
^false!
isPartitionTransitionMap
^false!
isTerminal
^false!
isTokenClassification
^false! !
!Collection methodsFor: 'reconstructing'!
reconstructOn: aStream
"Emit #( elements ) on aStream "
aStream poundSign; leftParenthesis.
self do:
[:ea |
ea reconstructOn: aStream.
aStream space].
aStream rightParenthesis! !
!Array methodsFor: 'reconstructing'!
reconstructOn: aStream
"Emit #( elements) on aStream ."
aStream
poundSign;
leftParenthesis;
space.
1 to: self size do:
[:index |
(self at: index)
reconstructOn: aStream.
aStream space].
aStream rightParenthesis!
reconstructOn: aStream using: tokenTable
aStream
poundSign;
leftParenthesis;
space.
1 to: self size do:
[:index |
(self at: index)
reconstructOn: aStream using: tokenTable.
aStream space].
aStream rightParenthesis! !
!CharacterArray methodsFor: 'copying'!
copyUpToLast: aCharacter
"Answer a copy of the receiver from index 1 to the last occurrence of
aCharacter, non-inclusive."
| index |
(index := self
prevIndexOf: aCharacter
from: self size
to: 1) isNil ifTrue: [^self].
^self copyFrom: 1 to: index - 1! !
!String methodsFor: 'converting'!
asNonterminal
^self asSymbol! !
!String methodsFor: 'testing'!
isTerminal
^true!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -