cycr 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,584 @@
1
+ (csetq *domains* '(
2
+ ("Accts" . (
3
+ #$AccountingMt
4
+ ))
5
+ ("Admin" . (
6
+ #$InternationalOrganizationDataMt
7
+ #$RegionalOrganizationsInTheMiddleEastFactsheetMt
8
+ #$USGovernmentDomesticOrganizationDataMt
9
+ #$USGovernmentOrganizationDataMt
10
+ ))
11
+ ("Advertg" . (
12
+ #$Advertising
13
+ ))
14
+ ("Aerosp" . (
15
+ #$AeronauticalEngineer
16
+ #$Aeronautics
17
+ ))
18
+ ("Agric" . (
19
+ ))
20
+ ("Anat" . (
21
+ #$AnimalPhysiologyMt
22
+ #$AnimalPhysiologyVocabularyMt
23
+ #$FemaleHumanBodyStructureMt
24
+ #$HumanBodyStructureMt
25
+ #$MaleHumanBodyStructureMt
26
+ ))
27
+ ("Anthrop" . (
28
+ #$EthnicGroupsMt
29
+ #$EthnicGroupsVocabularyMt
30
+ #$PeopleLingoTemplateMt
31
+ #$PeopleVocabularyMt
32
+ ))
33
+ ("Antiq" . (
34
+ #$PeloponnesianWarMt
35
+ ))
36
+ ("Archeol" . (
37
+ ))
38
+ ("Archit" . (
39
+ #$NooescapeArchitectureMt
40
+ ))
41
+ ("Art" . (
42
+ #$ArtWorksDataMt
43
+ #$ArtWorksDataVocabularyMt
44
+ #$PopCultureMythologyMt
45
+ ))
46
+ ("Astrol" . (
47
+ ))
48
+ ("Astron" . (
49
+ #$EarthObservationalAstronomyMt
50
+ #$EarthObservationalAstronomyVocabularyMt
51
+ #$ObservationalAstronomyMt
52
+ #$PlanetaryBaseKBVocabularyMt
53
+ #$SimpleAstronomyDataVocabularyMt
54
+ #$SimpleAstronomyMt
55
+ #$UniverseDataMt
56
+ #$UniverseDataVocabularyMt
57
+ #$UniverseVocabularyMt
58
+ ))
59
+ ("Audio" . (
60
+ #$HistoryOfMusicDataMt
61
+ ))
62
+ ("Aut" . (
63
+ #$DriverPerspectiveMt
64
+ #$FiremenAndFireTruckIMt
65
+ ))
66
+ ("Aviat" . (
67
+ ))
68
+ ("Bible" . (
69
+ ))
70
+ ("Biol" . (
71
+ #$BiochemicalReasoningWithRCCMt
72
+ #$BiochemistryMt
73
+ #$BiochemistryVocabularyMt
74
+ #$BiologicalChemistryMt
75
+ #$BiologicalChemistryVocabularyMt
76
+ #$BiologicalProcedureMt
77
+ #$BiologicalProcedureVocabularyMt
78
+ #$BiologicalSocialMt
79
+ #$BiologicalSocialVocabularyMt
80
+ #$BiologicalWarfareDemoEnvironmentMt
81
+ #$BiologyGenericsMt
82
+ #$BiologyMt
83
+ #$BiologyVocabularyMt
84
+ #$MicrobiologicalChemistryMt
85
+ #$MicrobiologicalProcedureVocabularyMt
86
+ #$MicrobiologyMt
87
+ #$MicrobiologyVocabularyMt
88
+ #$MolecularBiologyMt
89
+ #$MolecularBiologyVocabularyMt
90
+ #$NaiveBiologicalDescentVocabularyMt
91
+ ))
92
+ ("Bot" . (
93
+ #$BotanyMt
94
+ #$BotanyVocabularyMt
95
+ #$FloralMarketingMt
96
+ #$VegetationMapCodeMt
97
+ ))
98
+ ("Chem" . (
99
+ #$AcidsAndBases-ChemistryDomainMt
100
+ #$BiochemicalReasoningWithRCCMt
101
+ #$BiochemistryMt
102
+ #$BiochemistryVocabularyMt
103
+ #$BiologicalChemistryMt
104
+ #$BiologicalChemistryVocabularyMt
105
+ #$ChemicalComposition-ChemistryDomainMt
106
+ #$ChemicalConstantData-ChemistryDomainMt
107
+ #$ChemicalDissociation-ChemistryDomainMt
108
+ #$ChemicalEquations-ChemistryDomainMt
109
+ #$ChemicalReactions-ChemistryDomainMt
110
+ #$ChemicalSolutions-ChemistryDomainMt
111
+ #$ChemistryAssumptionsMt
112
+ #$ChemistryLaboratory-ChemistryDomainMt
113
+ #$ChemistryMt
114
+ #$ChemistryTemplateMt
115
+ #$ChemistryVocabularyMt
116
+ #$OrganicChemistryMt
117
+ #$OrganicChemistryVocabularyMt
118
+ ))
119
+ ("Cin" . (
120
+ ))
121
+ ("CivEng" . (
122
+ #$EngineeringField
123
+ ))
124
+ ("Comm" . (
125
+ #$BrandNameProductGMt
126
+ #$BrandNameProductGVocabularyMt
127
+ #$BrandNameProductPhysicalCharacteristicsMt
128
+ #$BrandNameProductPhysicalCharacteristicsVocabularyMt
129
+ #$BrandNameRoadVehicleWorkingsMt
130
+ #$BuyingMt
131
+ #$CommercialBuyingMt
132
+ #$RetailSalesMt
133
+ #$ShoppingGMt
134
+ #$WesternBusinessPracticesMt
135
+ #$WorldProductsMt
136
+ ))
137
+ ("Comput" . (
138
+ #$ComputerDataTypesDataMt
139
+ #$ComputereseLexicalMt
140
+ #$ComputerGMt
141
+ #$ComputerGVocabularyMt
142
+ #$ComputerHardwareDataMt
143
+ #$ComputerHardwareDataVocabularyMt
144
+ #$ComputerHardwareMt
145
+ #$ComputerHardwareVocabularyMt
146
+ #$ComputerNetworkMt
147
+ #$ComputerOrganizationDataMt
148
+ #$ComputerRunningDataMt
149
+ #$ComputerRunningMt
150
+ #$ComputerSecurityDataMt
151
+ #$ComputerSecurityMt
152
+ #$ComputerSoftwareBuyingMt
153
+ #$ComputerSoftwareDataMt
154
+ #$ComputerSoftwareMt
155
+ #$ComputerSoftwareVocabularyMt
156
+ #$ComputerUseDomainMt
157
+ #$ComputerVulnerabilityMt
158
+ #$NetworkModelMt
159
+ #$ProgramModelMt
160
+ #$InformationBuyingMt
161
+ #$InformationGVocabularyMt
162
+ #$InformationSecurityMt
163
+ #$InformationTerminologyVocabularyMt
164
+ ))
165
+ ("Constr" . (
166
+ #$BuildingContentsMt
167
+ #$BuildingContentsVocabularyMt
168
+ #$BuildingMt
169
+ #$BuildingVocabularyMt
170
+ #$OrganizationBuildingVocabularyMt
171
+ ))
172
+ ("Cosmet" . (
173
+ ))
174
+ ("Culin" . (
175
+ #$CoffeeMt
176
+ #$CookingLingoTemplateMt
177
+ #$CookingWorldTestCaseEntitiesMt
178
+ #$FoodBuyingGMt
179
+ #$FoodSocialMt
180
+ #$HumanFoodGVocabularyMt
181
+ ))
182
+ ("Dance" . (
183
+ ))
184
+ ("Dent" . (
185
+ ))
186
+ ("Ecol" . (
187
+ #$EcologyMt
188
+ #$EcologyVocabularyMt
189
+ ))
190
+ ("Econ" . (
191
+ #$EconomyMt
192
+ #$EconomyVocabularyMt
193
+ ))
194
+ ("Educ" . (
195
+ ))
196
+ ("Elec" . (
197
+ #$ElectricalSystemsMt
198
+ #$ElectricalSystemsVocabularyMt
199
+ ))
200
+ ("Electron" . (
201
+ ))
202
+ ("Equest" . (
203
+ ))
204
+ ("Fashn" . (
205
+ #$ClothingGMt
206
+ #$ClothingGVocabularyMt
207
+ #$ClothingLingoTemplateMt
208
+ #$ModernWesternClothingConventionMt
209
+ ))
210
+ ("Fin" . (
211
+ #$BusinessGMt
212
+ #$BusinessMoneyMt
213
+ #$BusinessStillUnsortedForStubsMt
214
+ #$BusinessStubMt
215
+ #$FinancialTransactionMt
216
+ #$WesternBusinessPracticesMt
217
+ ))
218
+ ("Fishg" . (
219
+ ))
220
+ ("Games" . (
221
+ ))
222
+ ("Geog" . (
223
+ #$DesertShieldMt
224
+ #$DualistGeopoliticalMt
225
+ #$DualistGeopoliticalVocabularyMt
226
+ #$FranceGeographyDualistMt
227
+ #$FranceGeographyMt
228
+ #$FranceNaturalGeographyMt
229
+ #$GeographicalRegionGVocabularyMt
230
+ #$GeographyLingoTemplateMt
231
+ #$GeographyVocabularyMt
232
+ #$GeopoliticalBordersMt
233
+ #$GeopoliticalEntityVocabularyMt
234
+ #$NaturalGeographyVocabularyMt
235
+ #$NorthernHemisphereMt
236
+ #$PhysicalGeographyMt
237
+ #$PoliticalGeographyVocabularyMt
238
+ #$UnitedStatesCulturalGeographyMt
239
+ #$UnitedStatesGeographyMt
240
+ #$UnitedStatesGeographyPeopleMt
241
+ #$UnitedStatesNaturalGeographyMt
242
+ #$UnitedStatesNaturalGeographyVocabularyMt
243
+ #$WorldCompleteDualistGeographyMt
244
+ #$WorldCulturalGeographyDataMt
245
+ #$WorldGeographyDualistMt
246
+ #$WorldGeographyMt
247
+ #$WorldGeographyPhysicalMt
248
+ #$WorldNaturalGeographyMt
249
+ #$WorldNaturalGeographyVocabularyMt
250
+ #$WorldPoliticalGeographyDataMt
251
+ #$WorldPoliticalGeographyDataVocabularyMt
252
+ ))
253
+ ("Geol" . (
254
+ #$GeologicalAge
255
+ ))
256
+ ("Herald" . (
257
+ ))
258
+ ("Hist" . (
259
+ #$PeopleDataMt
260
+ #$ChronologyMt
261
+ #$ChronologyVocabularyMt
262
+ #$HistoryOfMusicDataMt
263
+ #$HistoryOfScienceDataMt
264
+ #$WorldHistoryMt
265
+ ))
266
+ ("Hort" . (
267
+ ))
268
+ ("Hunt" . (
269
+ ))
270
+ ("Ind" . (
271
+ ))
272
+ ("Insur" . (
273
+ ))
274
+ ("Journ" . (
275
+ #$AssociatedPressMt
276
+ ))
277
+ ("Jur" . (
278
+ #$BasicWesternLegalConceptsMt
279
+ ))
280
+ ("Ling" . (
281
+ #$CorpusLexicalMt
282
+ #$CrossLinguisticLexicalMt
283
+ #$LanguageAndWritingSystemVocabularyMt
284
+ #$RelativeClausesTemplateMt
285
+ #$WritingSystemCharactersVocabularyMt
286
+ ))
287
+ ("Literat" . (
288
+ #$FactsInFictionalWorksMt
289
+ #$LiteraryPeopleDataMt
290
+ #$NonfictionalWorksMt
291
+ ))
292
+ ("Math" . (
293
+ #$BayesianNetworkMt
294
+ #$DeonticReasoning-InferenceMt
295
+ #$DeonticReasoning-LogicMt
296
+ #$EqualityReasoningVocabularyMt
297
+ #$EuclideanGeometryMt
298
+ #$GeometryGMt
299
+ #$GeometryGVocabularyMt
300
+ #$LogicalTruthImplementationMt
301
+ #$LogicalTruthMt
302
+ #$MathMt
303
+ #$MathVocabularyMt
304
+ #$NaiveSpatialMt
305
+ #$NaiveSpatialVocabularyMt
306
+ #$PathSystemsVocabularyMt
307
+ #$PointBasedGeometryMt
308
+ #$PointBasedGeometryVocabularyMt
309
+ ))
310
+ ("Mech" . (
311
+ ))
312
+ ("Med" . (
313
+ #$AilmentMt
314
+ #$AilmentVocabularyMt
315
+ #$BloodTransfusionMt
316
+ #$DiseaseLexicalMt
317
+ #$HumanAilmentMt
318
+ #$HumanAilmentVocabularyMt
319
+ #$MedicalVulnerabilityMt
320
+ #$USHealthcareMt
321
+ ))
322
+ ("Meas" . (
323
+ #$CalendarsMt
324
+ #$CalendarsVocabularyMt
325
+ #$GregorianCalendarMt
326
+ #$GregorianCalendarVocabularyMt
327
+ #$IslamicCalendarMt
328
+ #$JewishCalendarMt
329
+ ))
330
+ ("Meteorol" . (
331
+ #$AmbientConditionsDataMt
332
+ #$AmbientConditionsMt
333
+ #$AmbientConditionsVocabularyMt
334
+ #$EarthWeatherMt
335
+ #$EarthWeatherVocabularyMt
336
+ #$WeatherMt
337
+ #$WeatherVocabularyMt
338
+ ))
339
+ ("Mgmt" . (
340
+ #$InternationalOrganizationDataMt
341
+ #$JobMt
342
+ #$OrganizationGMt
343
+ #$OrganizationGVocabularyMt
344
+ #$OrganizationInternalsMt
345
+ ))
346
+ ("Mil" . (
347
+ #$ArmyFM8-10-7Mt
348
+ #$ChemicalWeaponsDestructionInRussiaMt
349
+ #$China-TaiwanMilitaryTechnologyMt
350
+ #$DesertStormMilitaryPresenceMt
351
+ #$EmergingCruiseMissileCapabilitiesMt
352
+ #$EnemyMovementMt
353
+ #$MilitaryForceStructureMt
354
+ #$MilitaryGlossaryHoldingMt
355
+ #$MilitaryGMt
356
+ #$MilitaryGVocabularyMt
357
+ #$MilitaryOrganization
358
+ #$MilitaryStandard-2408Mt
359
+ #$MilitaryTermsVocabularyMt
360
+ #$ModernMilitaryMt
361
+ #$ModernMilitaryTacticsMt
362
+ #$ModernMilitaryVehiclesMt
363
+ #$ModernMilitaryWeaponsMt
364
+ #$PeloponnesianWarMt
365
+ #$RightWingTerrorismAndWeaponsOfMassDestructionMt
366
+ #$SAICTerrorismEventsDataMt
367
+ #$TerrorismInTheMiddleEastFactsheetMt
368
+ #$TerroristGroup
369
+ #$UnitedStatesModernMilitaryVehiclesDataMt
370
+ #$USArmsControlAndDisarmamentAgencyMt
371
+ #$USMarineCorpsPracticesMt
372
+ #$USMilitaryPracticesMt
373
+ #$USMilitaryStaffOrganizationMt
374
+ #$WeaponsOfMassDestructionTacticsMt
375
+ #$Year2000MilitaryTechnologyMt
376
+ ))
377
+ ("Mil" Naut . (
378
+ ))
379
+ ("Miner" . (
380
+ #$MineralogyMt
381
+ ))
382
+ ("Mining" . (
383
+ ))
384
+ ("Mus" . (
385
+ ))
386
+ ("Mythol" . (
387
+ #$ChristmasMythologyMt
388
+ #$FactsInFictionalWorksMt
389
+ #$GreekMythologyMt
390
+ #$PopCultureMythologyMt
391
+ #$RomanMythologyMt
392
+ #$WorldMythologyMt
393
+ ))
394
+ ("Naut" . (
395
+ ))
396
+ ("Nucl" nuclear . (
397
+ ))
398
+ ("Pharm" . (
399
+ #$BrandNamePharmaceuticalUseMt
400
+ #$PharmaceuticalDetailsMt
401
+ #$PharmaceuticalGMt
402
+ #$PharmaceuticalGVocabularyMt
403
+ #$PharmaceuticalUseMt
404
+ #$PharmaceuticalUseVocabularyMt
405
+ ))
406
+ ("Philos" . (
407
+ ))
408
+ ("Phon" . (
409
+ ))
410
+ ("Phot" . (
411
+ ))
412
+ ("Phys" . (
413
+ #$Aerodynamics
414
+ #$DefinitionOfKineticEnergyMt
415
+ #$DefinitionOfNetWorkMt
416
+ #$DefinitionOfWeightMt
417
+ #$DefinitionOfWork-ForceAndDisplacementSameDirectionMt
418
+ #$DefinitionOfWorkMt
419
+ #$NaivePhysicsVocabularyMt
420
+ #$NewtonianPhysicsMt
421
+ #$NewtonsSecondLawMt
422
+ #$NewtonsThirdLawMt
423
+ #$NormalPhysicalConditionsMt
424
+ #$ObjectPhysicalCharacteristicsVocabularyMt
425
+ ))
426
+ ("Physiol" . (
427
+ #$HumanPerceptionMt
428
+ #$HumanPerceptionVocabularyMt
429
+ #$HumanPhysiologyVocabularyMt
430
+ #$LinnaeanTaxonomyPhysiologyMt
431
+ #$LinnaeanTaxonomyPhysiologyVocabularyMt
432
+ #$PerceptionMt
433
+ #$PerceptionVocabularyMt
434
+ #$VertebratePhysiologyMt
435
+ #$VertebratePhysiologyVocabularyMt
436
+ ))
437
+ ("Pol" . (
438
+ #$GovernmentAgency
439
+ ))
440
+ ("Post" postal . (
441
+ ))
442
+ ("Print" . (
443
+ ))
444
+ ("Psych" . (
445
+ #$AffectMt
446
+ #$AffectVocabularyMt
447
+ ))
448
+ ("Publg" . (
449
+ #$PublicationDataMt
450
+ ))
451
+ ("Radio" . (
452
+ ))
453
+ ("Rail" . (
454
+ ))
455
+ ("Relig" . (
456
+ #$BuddhismMt
457
+ #$CatholicismMt
458
+ #$ChristianityMt
459
+ #$ChristianityNaiveMt
460
+ #$ChristianTrinityMt
461
+ #$IslamShiaMt
462
+ #$JudaismMt
463
+ #$Judeo-ChristianMt
464
+ #$NaturalismMt
465
+ #$ReligiousAgnostic
466
+ #$ReligiousCeremony
467
+ #$ReligiousPeopleDataMt
468
+ ))
469
+ ("Sch" . (
470
+ ))
471
+ ("Sci" . (
472
+ #$GeneralScientificLexicalMt
473
+ #$HistoryOfScienceDataMt
474
+ #$OrganizedResearchMt
475
+ #$TheoryOfScienceVocabularyMt
476
+ ))
477
+ ("Sewing" . (
478
+ ))
479
+ ("Sociol" . (
480
+ #$AustralasianSocialLifeMt
481
+ #$BiologicalSocialVocabularyMt
482
+ #$HumanSocialLifeMt
483
+ #$HumanSocialLifeWithTenseMt
484
+ #$IranianSocialLifeMt
485
+ #$PeopleVocabularyMt
486
+ #$UnitedStatesSocialLifeMt
487
+ #$CultureGMt
488
+ #$CultureGVocabularyMt
489
+ ))
490
+ ("Sport" . (
491
+ #$AmericanCollegeSportsOrganizationsDataMt
492
+ #$AmericanCollegeSportsPeopleDataMt
493
+ #$AmericanProfessionalSportsMt
494
+ #$NonUSProfessionalSportsMt
495
+ #$OlympicsMt
496
+ #$ProfessionalSportsGMt
497
+ #$SportsLingoTemplateMt
498
+ #$SportsProductsMt
499
+ ))
500
+ ("Stat" . (
501
+ ))
502
+ ("Tax" . (
503
+ #$AmericanFiscalPracticeMt
504
+ #$JapaneseFiscalPracticeMt
505
+ ))
506
+ ("Tech" . (
507
+ #$DevicePerspectiveMt
508
+ #$SimpleDeviceFunctioningMt
509
+ #$TechnicalEnglishLexicalMt
510
+ #$ProductGMt
511
+ #$ProductGVocabularyMt
512
+ #$ProductPhysicalCharacteristicsMt
513
+ #$ProductUsageMt
514
+ #$ProductUsageVocabularyMt
515
+ ))
516
+ ("Telcom" . (
517
+ #$CommunicationsSupportMt
518
+ #$CommunicationsSupportRulesMt
519
+ #$CommunicationsSupportVocabMt
520
+ ))
521
+ ("Tex" . (
522
+ #$MaterialsManipulationMt
523
+ ))
524
+ ("Theat" . (
525
+ ))
526
+ ("Tourism" . (
527
+ #$GenericTouristMt
528
+ ))
529
+ ("Transp" . (
530
+ #$InternationalTrafficMt
531
+ #$MovementMt
532
+ #$MovementVocabularyMt
533
+ #$SuezCanalTrafficMt
534
+ #$TransportationMt
535
+ #$TransportationPlanningMt
536
+ #$TransportationVocabularyMt
537
+ ))
538
+ ("Turf" . (
539
+ ))
540
+ ("TV" . (
541
+ #$DCSuperheroesMt
542
+ #$LargeCorpBlackBoxMt
543
+ #$MassMediaDataMt
544
+ #$MassMediaMt
545
+ #$TeletubbiesMt
546
+ #$ThePeanutsCartoonMt
547
+ #$TheSimpsonsMt
548
+ #$TheXFilesTVSeriesMt
549
+ ))
550
+ ("Univ" . (
551
+ #$AcademicLifeMt
552
+ #$AcademicOrganizationMt
553
+ #$AcademicOrganizationVocabularyMt
554
+ #$UniversityDataMt
555
+ ))
556
+ ("Vet" veterinary . (
557
+ ))
558
+ ("Wine" . (
559
+ ))
560
+ ("Zool" . (
561
+ #$AmericanKennelClubMt
562
+ #$AnimalActivitiesMt
563
+ #$AnimalActivitiesVocabularyMt
564
+ #$AnimalMovementMt
565
+ #$DogClassificationSpindleCollectorMt
566
+ #$DogClassificationSpindleHeadMt
567
+ #$DomesticBreedsMt
568
+ #$DomesticBreedsVocabularyMt
569
+ #$NaiveAnimalsVocabularyMt
570
+ ))
571
+ ))
572
+
573
+ (define domains-of (term)
574
+ (clet (
575
+ (result ())
576
+ (base-assertions (with-just-mt #$BaseKB (gather-index term)))
577
+ )
578
+ (cdolist (pair *domains*)
579
+ (pif(< 0 (with-mt-list (cdr pair)
580
+ (length (set-difference (gather-index term)
581
+ base-assertions) )))
582
+ (csetq result (adjoin (car pair) result))
583
+ ()))
584
+ (ret result)))
@@ -0,0 +1,26 @@
1
+ class String
2
+ def to_cyc(quote = false)
3
+ #self =~ /_missing_method_(.*)/ ? "#{$1.gsub("_","-")}" : "\"#{self}\""
4
+ "\"#{self}\""
5
+ end
6
+ end
7
+
8
+ class Symbol
9
+ def to_cyc(quote = false)
10
+ (quote ? "'" : "") + "#\$#{self}"
11
+ end
12
+ end
13
+
14
+ class Array
15
+ def to_cyc(quote = false)
16
+ (quote ? "'" : "") +
17
+ "("+map{|e| e.to_cyc(quote)}.join(" ")+")"
18
+ end
19
+ end
20
+
21
+ class Fixnum
22
+ def to_cyc(quote = false)
23
+ to_s
24
+ end
25
+ end
26
+
data/lib/cycr/nart.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Cyc
2
+ class Nart
3
+ attr_accessor :id, :value
4
+ def initialize(id, cyc)
5
+ @id = id.to_i
6
+ @value = cyc.find_nart_by_id @id
7
+ end
8
+
9
+ def to_cyc(quote=false)
10
+ "(find-nart-by-id #{@id})"
11
+ end
12
+
13
+ def to_s
14
+ "NART[#{@id}]: #{@value.inspect} "
15
+ end
16
+
17
+ def self.find_by_name(name,cyc)
18
+ self.new(name.match(/^NART\[([^\]]+)\]/)[1],cyc)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,63 @@
1
+ module Cyc
2
+ class Parser
3
+ # Exception raised when there is a continuation sign,
4
+ # at the end of the parsed message.
5
+ class ContinueParsing < RuntimeError
6
+ attr_reader :stack
7
+
8
+ def initialize(stack)
9
+ @stack = stack
10
+ end
11
+ end
12
+
13
+ def initialize
14
+ @lexer = SExpressionLexer.new
15
+ end
16
+
17
+ # Parses message received from server. +Message+ to parse.
18
+ def parse(message,stack=nil)
19
+ @lexer.scan_str(message)
20
+ stack ||= [[]]
21
+ while !(token = @lexer.next_token).nil?
22
+ #p token
23
+ case token[0]
24
+ when :open_par
25
+ stack.push []
26
+ when :close_par
27
+ top = stack.pop
28
+ stack[-1].push top
29
+ when :atom
30
+ # FIXME find way to differentiate strings and atoms
31
+ stack[-1] << token[1]
32
+ when :cyc_symbol
33
+ stack[-1] << token[1][2..-1].to_sym
34
+ when :symbol
35
+ stack[-1] << token[1][3..-1].to_sym
36
+ when :string
37
+ stack[-1] << token[1]
38
+ when :open_as
39
+ stack.push [:as]
40
+ when :close_quote
41
+ top = stack.pop
42
+ if top[0] == :as
43
+ as = Assertion.new(top[1],top[2])
44
+ stack[-1].push as
45
+ else
46
+ stack.push top
47
+ end
48
+ when :continuation
49
+ top = stack.pop
50
+ stack[-1].push top
51
+ raise ContinueParsing.new(stack[0][0])
52
+ end
53
+ end
54
+ stack[0][0]
55
+ rescue ContinueParsing => ex
56
+ raise
57
+ rescue Exception => ex
58
+ puts "Error occured while parsing message:\n#{message}"
59
+ puts ex
60
+ nil
61
+ end
62
+ end
63
+ end