├── .gitignore
├── Risp.xcworkspace
└── contents.xcworkspacedata
├── Risp
├── Risp.xcodeproj
│ ├── .LSOverride
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── Risp
│ ├── Core
│ │ ├── init.risp
│ │ ├── io.risp
│ │ └── test.risp
│ ├── DataContainer
│ │ ├── NSObject+RispMeta.h
│ │ ├── NSObject+RispMeta.m
│ │ ├── RispCharSequence.h
│ │ ├── RispCharSequence.m
│ │ ├── RispEnvironmentVariables.h
│ │ ├── RispEnvironmentVariables.m
│ │ ├── RispKeyword.h
│ │ ├── RispKeyword.m
│ │ ├── RispLazySequence.h
│ │ ├── RispLazySequence.m
│ │ ├── RispLexicalScope.h
│ │ ├── RispLexicalScope.m
│ │ ├── RispList.h
│ │ ├── RispList.m
│ │ ├── RispMap.h
│ │ ├── RispMap.m
│ │ ├── RispMetaKeyDefinition.h
│ │ ├── RispMetaKeyDefinition.m
│ │ ├── RispSequence.h
│ │ ├── RispSequence.m
│ │ ├── RispSequenceProtocol.h
│ │ ├── RispSymbol+BIF.h
│ │ ├── RispSymbol+BIF.m
│ │ ├── RispSymbol.h
│ │ ├── RispSymbol.m
│ │ ├── RispToken.h
│ │ ├── RispToken.m
│ │ ├── RispVariable.h
│ │ ├── RispVariable.m
│ │ ├── RispVector.h
│ │ └── RispVector.m
│ ├── Documents
│ │ └── Design
│ │ │ ├── RispDesign.graffle
│ │ │ └── RispUML.graffle
│ ├── Expression
│ │ ├── RispAbstractSyntaxTree.h
│ │ ├── RispAbstractSyntaxTree.m
│ │ ├── RispBaseExpression+ASTDescription.h
│ │ ├── RispBaseExpression+ASTDescription.m
│ │ ├── RispBaseExpression.h
│ │ ├── RispBaseExpression.m
│ │ ├── RispBlockExpression.h
│ │ ├── RispBlockExpression.m
│ │ ├── RispBodyExpression.h
│ │ ├── RispBodyExpression.m
│ │ ├── RispClosureExpression.h
│ │ ├── RispClosureExpression.m
│ │ ├── RispConstantExpression.h
│ │ ├── RispConstantExpression.m
│ │ ├── RispDefExpression.h
│ │ ├── RispDefExpression.m
│ │ ├── RispDefnExpression.h
│ │ ├── RispDefnExpression.m
│ │ ├── RispDotExpression.h
│ │ ├── RispDotExpression.m
│ │ ├── RispFalseExpression.h
│ │ ├── RispFalseExpression.m
│ │ ├── RispFnExpression.h
│ │ ├── RispFnExpression.m
│ │ ├── RispFnProtocol.h
│ │ ├── RispIRCodeGenerator.h
│ │ ├── RispIfExpression.h
│ │ ├── RispIfExpression.m
│ │ ├── RispInvokeExpression.h
│ │ ├── RispInvokeExpression.m
│ │ ├── RispInvokeProtocol.h
│ │ ├── RispKeywordExpression.h
│ │ ├── RispKeywordExpression.m
│ │ ├── RispKeywordInvokeExpression.h
│ │ ├── RispKeywordInvokeExpression.m
│ │ ├── RispLetExpression.h
│ │ ├── RispLetExpression.m
│ │ ├── RispLiteralExpression.h
│ │ ├── RispLiteralExpression.m
│ │ ├── RispMapExpression.h
│ │ ├── RispMapExpression.m
│ │ ├── RispMethodExpression.h
│ │ ├── RispMethodExpression.m
│ │ ├── RispNilExpression.h
│ │ ├── RispNilExpression.m
│ │ ├── RispNumberExpression.h
│ │ ├── RispNumberExpression.m
│ │ ├── RispStringExpression.h
│ │ ├── RispStringExpression.m
│ │ ├── RispTrueExpression.h
│ │ ├── RispTrueExpression.m
│ │ ├── RispVectorExpression.h
│ │ └── RispVectorExpression.m
│ ├── FixupHook
│ │ ├── NSDecimalNumber+Math.h
│ │ ├── NSDecimalNumber+Math.m
│ │ ├── NSNull+Risp.h
│ │ ├── NSNull+Risp.m
│ │ ├── RispFixupHook.h
│ │ ├── RispFixupHook.m
│ │ ├── __RispFXHookNSCFBoolean.h
│ │ ├── __RispFXHookNSCFBoolean.m
│ │ ├── __RispFXNSString.h
│ │ └── __RispFXNSString.m
│ ├── Parser
│ │ ├── RispBaseParser.h
│ │ ├── RispBaseParser.m
│ │ ├── RispBodyParser.h
│ │ └── RispBodyParser.m
│ ├── Reader
│ │ ├── RispAnonymousFunctionReader.h
│ │ ├── RispAnonymousFunctionReader.m
│ │ ├── RispArgumentsReader.h
│ │ ├── RispArgumentsReader.m
│ │ ├── RispBaseReader.h
│ │ ├── RispBaseReader.m
│ │ ├── RispCommentReader.h
│ │ ├── RispCommentReader.m
│ │ ├── RispDispatchReader.h
│ │ ├── RispDispatchReader.m
│ │ ├── RispListReader.h
│ │ ├── RispListReader.m
│ │ ├── RispMapReader.h
│ │ ├── RispMapReader.m
│ │ ├── RispNumberReader.h
│ │ ├── RispNumberReader.m
│ │ ├── RispPushBackReader.h
│ │ ├── RispPushBackReader.m
│ │ ├── RispReader.h
│ │ ├── RispReader.m
│ │ ├── RispRegexReader.h
│ │ ├── RispRegexReader.m
│ │ ├── RispStringReader.h
│ │ ├── RispStringReader.m
│ │ ├── RispSyntaxQuoteReader.h
│ │ ├── RispSyntaxQuoteReader.m
│ │ ├── RispTokenReader.h
│ │ ├── RispTokenReader.m
│ │ ├── RispUnmatchedDelimiterReader.h
│ │ ├── RispUnmatchedDelimiterReader.m
│ │ ├── RispUnquoteReader.h
│ │ ├── RispUnquoteReader.m
│ │ ├── RispVectorReader.h
│ │ ├── RispVectorReader.m
│ │ ├── RispWrappingReader.h
│ │ └── RispWrappingReader.m
│ ├── Risp+DEBUG.h
│ ├── Risp+DEBUG.m
│ ├── Risp-Info.plist
│ ├── Risp-Prefix.pch
│ ├── Risp.h
│ ├── Risp.m
│ ├── VM
│ │ ├── RispCompiler.h
│ │ ├── RispCompiler.m
│ │ ├── RispContext.h
│ │ ├── RispContext.m
│ │ ├── RispLLVM
│ │ │ ├── RispCodeGeneratorContext.h
│ │ │ ├── RispCodeGeneratorContext.m
│ │ │ ├── RispLLVM.cpp
│ │ │ ├── RispLLVM.h
│ │ │ ├── _RispLLVMModule.h
│ │ │ ├── _RispLLVMModule.m
│ │ │ ├── __RispLLVMFoundation.h
│ │ │ └── __RispLLVMFoundation.mm
│ │ ├── RispLocalBinding.h
│ │ ├── RispLocalBinding.m
│ │ ├── RispRuntime.h
│ │ └── RispRuntime.m
│ └── en.lproj
│ │ └── InfoPlist.strings
├── RispDotOperationCodeGen
│ ├── RispDotOperationCodeGen-Prefix.pch
│ ├── RispDotOperationCodeGen.1
│ └── main.m
├── RispKeyboardBinding
│ ├── RispKBCommon.h
│ ├── RispKBCommon.m
│ ├── RispKBHotKey.h
│ ├── RispKBHotKey.m
│ ├── RispKBHotKeyCenter.h
│ ├── RispKBHotKeyCenter.m
│ ├── RispKBKeyCodeTransformer.h
│ ├── RispKBKeyCodeTransformer.m
│ ├── RispKBKeyCodeTranslator.h
│ ├── RispKBKeyCodeTranslator.m
│ ├── RispKBKeyCombo.h
│ ├── RispKBKeyCombo.m
│ ├── RispKBRecorderCell.h
│ ├── RispKBRecorderCell.m
│ ├── RispKBRecorderControl.h
│ ├── RispKBRecorderControl.m
│ ├── RispKBValidator.h
│ ├── RispKBValidator.m
│ ├── RispKeyboardBinding-Info.plist
│ ├── RispKeyboardBinding-Prefix.pch
│ ├── RispKeyboardBinding.h
│ ├── RispKeyboardBinding.m
│ └── en.lproj
│ │ └── InfoPlist.strings
├── RispMobile
│ ├── Info.plist
│ └── RispMobile.h
├── RispReader
│ ├── 1.png
│ ├── Base.lproj
│ │ └── MainMenu.xib
│ ├── Media.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ └── SDK.png
│ ├── Model
│ │ ├── ASUserNotification
│ │ │ ├── ASUserNotification.h
│ │ │ ├── ASUserNotification.m
│ │ │ ├── ASUserNotificationBannerBackgroundView.h
│ │ │ ├── ASUserNotificationBannerBackgroundView.m
│ │ │ ├── ASUserNotificationBannerButton.h
│ │ │ ├── ASUserNotificationBannerButton.m
│ │ │ ├── ASUserNotificationBannerButtonCell.h
│ │ │ ├── ASUserNotificationBannerButtonCell.m
│ │ │ ├── ASUserNotificationBannerController.h
│ │ │ ├── ASUserNotificationBannerController.m
│ │ │ ├── ASUserNotificationCenter.h
│ │ │ ├── ASUserNotificationCenter.m
│ │ │ ├── ASUserNotificationCenterDelegate.h
│ │ │ ├── ASUserNotificationDefaultSound.aif
│ │ │ ├── ASUserNotificationFeature.h
│ │ │ ├── ASUserNotificationFeature.m
│ │ │ └── AppledocSettings.plist
│ │ ├── RispReaderEvalCore
│ │ │ ├── RispReaderEvalCore.h
│ │ │ └── RispReaderEvalCore.m
│ │ └── RispRender
│ │ │ ├── RispRender.h
│ │ │ └── RispRender.m
│ ├── RispAppDelegate.h
│ ├── RispAppDelegate.m
│ ├── RispReader-Info.plist
│ ├── RispReader-Prefix.pch
│ ├── RispRender
│ │ ├── RispRender.h
│ │ └── RispRender.m
│ ├── Views
│ │ ├── LineNumberView
│ │ │ ├── MarkerLineNumberView.h
│ │ │ ├── MarkerLineNumberView.m
│ │ │ ├── NoodleLineNumberMarker.h
│ │ │ ├── NoodleLineNumberMarker.m
│ │ │ ├── NoodleLineNumberView.h
│ │ │ └── NoodleLineNumberView.m
│ │ ├── RMBlurredView
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── RMBlurredView.h
│ │ │ └── RMBlurredView.m
│ │ └── RispHUD
│ │ │ ├── MDBlackTransparentView.h
│ │ │ ├── MDBlackTransparentView.m
│ │ │ ├── MDBorderlessWindow.h
│ │ │ ├── MDBorderlessWindow.m
│ │ │ ├── RispHUDWindowController.h
│ │ │ ├── RispHUDWindowController.m
│ │ │ ├── RispHUDWindowController.xib
│ │ │ ├── RispTextFieldVCenteredCell.h
│ │ │ ├── RispTextFieldVCenteredCell.m
│ │ │ ├── TSTTextGrowth.h
│ │ │ └── TSTTextGrowth.m
│ ├── WindowControllers
│ │ ├── RispREPLAlphaWindowController.h
│ │ ├── RispREPLAlphaWindowController.m
│ │ ├── RispREPLAlphaWindowController.xib
│ │ ├── RispRenderWindowController.h
│ │ ├── RispRenderWindowController.m
│ │ ├── RispRenderWindowController.xib
│ │ ├── RispWindowBlurer.h
│ │ └── RispWindowBlurer.m
│ ├── Windows
│ │ ├── RispAutoHideWindow.h
│ │ └── RispAutoHideWindow.m
│ ├── en.lproj
│ │ ├── Credits.rtf
│ │ └── InfoPlist.strings
│ ├── main.m
│ └── 穹.jpg
├── RispRenderFoundation
│ ├── ICUMatcher.h
│ ├── ICUMatcher.m
│ ├── ICUPattern.h
│ ├── ICUPattern.m
│ ├── MarkerLineNumberView.h
│ ├── MarkerLineNumberView.m
│ ├── NSScanner+Fragaria.h
│ ├── NSScanner+Fragaria.m
│ ├── NSStringICUAdditions.h
│ ├── NSStringICUAdditions.m
│ ├── NoodleLineNumberMarker.h
│ ├── NoodleLineNumberMarker.m
│ ├── NoodleLineNumberView.h
│ ├── NoodleLineNumberView.m
│ ├── Preferences.xib
│ ├── README.md
│ ├── RispFontTransformer.h
│ ├── RispFontTransformer.m
│ ├── RispFoundationPrefsWindowController.h
│ ├── RispFoundationPrefsWindowController.m
│ ├── RispPrefsWindowController.h
│ ├── RispPrefsWindowController.m
│ ├── RispRenderFoundation-Info.plist
│ ├── RispRenderFoundation-Prefix.pch
│ ├── RispRenderFoundation.h
│ ├── RispRenderFoundation.m
│ ├── RispRenderFoundationAutoCompleteDelegate.h
│ ├── RispRenderFoundationBasicPerformer.h
│ ├── RispRenderFoundationBasicPerformer.m
│ ├── RispRenderFoundationBreakpointDelegate.h
│ ├── RispRenderFoundationCommandResult.xib
│ ├── RispRenderFoundationDetab.xib
│ ├── RispRenderFoundationEntab.xib
│ ├── RispRenderFoundationErrorPopOver.h
│ ├── RispRenderFoundationErrorPopOver.m
│ ├── RispRenderFoundationExtraInterfaceController.h
│ ├── RispRenderFoundationExtraInterfaceController.m
│ ├── RispRenderFoundationFontsAndColoursPrefsViewController.h
│ ├── RispRenderFoundationFontsAndColoursPrefsViewController.m
│ ├── RispRenderFoundationFramework.h
│ ├── RispRenderFoundationGlyphGenerator.h
│ ├── RispRenderFoundationGlyphGenerator.m
│ ├── RispRenderFoundationGoToLine.xib
│ ├── RispRenderFoundationGutterTextView.h
│ ├── RispRenderFoundationGutterTextView.m
│ ├── RispRenderFoundationLayoutManager.h
│ ├── RispRenderFoundationLayoutManager.m
│ ├── RispRenderFoundationLineNumbers.h
│ ├── RispRenderFoundationLineNumbers.m
│ ├── RispRenderFoundationOpenPanelAccessoryView.xib
│ ├── RispRenderFoundationPreferences.h
│ ├── RispRenderFoundationPreferences.m
│ ├── RispRenderFoundationPreferencesFontsAndColours.xib
│ ├── RispRenderFoundationPreferencesTextEditing.xib
│ ├── RispRenderFoundationPrefsViewController.h
│ ├── RispRenderFoundationPrefsViewController.m
│ ├── RispRenderFoundationRegularExpressionHelp.xib
│ ├── RispRenderFoundationStandardHeader.h
│ ├── RispRenderFoundationSyntaxColouring.h
│ ├── RispRenderFoundationSyntaxColouring.m
│ ├── RispRenderFoundationSyntaxColouringDelegate.h
│ ├── RispRenderFoundationSyntaxController.h
│ ├── RispRenderFoundationSyntaxController.m
│ ├── RispRenderFoundationSyntaxDefinition.h
│ ├── RispRenderFoundationSyntaxError.h
│ ├── RispRenderFoundationSyntaxError.m
│ ├── RispRenderFoundationTextEditingPrefsViewController.h
│ ├── RispRenderFoundationTextEditingPrefsViewController.m
│ ├── RispRenderFoundationTextMenuController.h
│ ├── RispRenderFoundationTextMenuController.m
│ ├── RispRenderFoundationTextPerformer.h
│ ├── RispRenderFoundationTextPerformer.m
│ ├── RispRenderFoundationTextView.h
│ ├── RispRenderFoundationTextView.m
│ ├── Syntax Definitions
│ │ ├── Risp.plist
│ │ ├── actionscript.plist
│ │ ├── actionscript3.plist
│ │ ├── active4d.plist
│ │ ├── ada.plist
│ │ ├── ampl.plist
│ │ ├── apache.plist
│ │ ├── applescript.plist
│ │ ├── asm-mips.plist
│ │ ├── asm-x86.plist
│ │ ├── asp-js.plist
│ │ ├── asp-vb.plist
│ │ ├── aspdotnet-cs.plist
│ │ ├── aspdotnet-vb.plist
│ │ ├── awk.plist
│ │ ├── batch.plist
│ │ ├── c.plist
│ │ ├── cobol.plist
│ │ ├── coffeescript.plist
│ │ ├── coldfusion.plist
│ │ ├── cpp.plist
│ │ ├── csharp.plist
│ │ ├── csound.plist
│ │ ├── css.plist
│ │ ├── d.plist
│ │ ├── dylan.plist
│ │ ├── eiffel.plist
│ │ ├── erl.plist
│ │ ├── eztpl.plist
│ │ ├── f-script.plist
│ │ ├── fortran.plist
│ │ ├── freefem.plist
│ │ ├── gedcom.plist
│ │ ├── gnuassembler.plist
│ │ ├── graphviz.plist
│ │ ├── haskell.plist
│ │ ├── header.plist
│ │ ├── html.plist
│ │ ├── idl.plist
│ │ ├── java.plist
│ │ ├── javafx.plist
│ │ ├── javascript.plist
│ │ ├── jsp.plist
│ │ ├── latex.plist
│ │ ├── lilypond.plist
│ │ ├── lisp.plist
│ │ ├── logtalk.plist
│ │ ├── lsl.plist
│ │ ├── lua.plist
│ │ ├── matlab.plist
│ │ ├── mel.plist
│ │ ├── metapost.plist
│ │ ├── metaslang.plist
│ │ ├── mysql.plist
│ │ ├── nemerle.plist
│ │ ├── none.plist
│ │ ├── nrnhoc.plist
│ │ ├── objectivec.plist
│ │ ├── objectivecaml.plist
│ │ ├── ox.plist
│ │ ├── pascal.plist
│ │ ├── pdf.plist
│ │ ├── perl.plist
│ │ ├── php.plist
│ │ ├── plist.plist
│ │ ├── postscript.plist
│ │ ├── prolog.plist
│ │ ├── python.plist
│ │ ├── r.plist
│ │ ├── rhtml.plist
│ │ ├── ruby.plist
│ │ ├── scala.plist
│ │ ├── sgml.plist
│ │ ├── shell.plist
│ │ ├── sml.plist
│ │ ├── sql.plist
│ │ ├── standard.plist
│ │ ├── stata.plist
│ │ ├── supercollider.plist
│ │ ├── tcltk.plist
│ │ ├── torquescript.plist
│ │ ├── udo.plist
│ │ ├── vb.plist
│ │ ├── verilog.plist
│ │ ├── vhdl.plist
│ │ └── xml.plist
│ ├── SyntaxDefinitions.plist
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ └── icu
│ │ ├── LICENSE.html
│ │ └── unicode
│ │ ├── parseerr.h
│ │ ├── platform.h
│ │ ├── putil.h
│ │ ├── uconfig.h
│ │ ├── udraft.h
│ │ ├── uiter.h
│ │ ├── umachine.h
│ │ ├── uregex.h
│ │ ├── urename.h
│ │ ├── ustring.h
│ │ ├── utf.h
│ │ ├── utf16.h
│ │ ├── utf8.h
│ │ ├── utf_old.h
│ │ ├── utypes.h
│ │ └── uversion.h
├── SDK.png
├── entry.risp
├── libLLVM-3.5.0svn.dylib
└── test.risp
└── RispMobile
└── Risp
├── Risp.xcodeproj
└── project.pbxproj
├── Risp
└── Info.plist
└── RispReader
├── Base.lproj
└── Main.storyboard
├── Images.xcassets
├── AppIcon.appiconset
│ └── Contents.json
└── LaunchImage.launchimage
│ └── Contents.json
├── Info.plist
├── Model
├── RispEvalCore.h
└── RispEvalCore.m
├── RispAppDelegate.h
├── RispAppDelegate.m
├── RispReader-Bridging-Header.h
├── RispReader-Prefix.pch
└── main.m
/Risp.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Risp/Risp.xcodeproj/.LSOverride:
--------------------------------------------------------------------------------
1 | /Applications/Xcode6-Beta.app
--------------------------------------------------------------------------------
/Risp/Risp.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Risp/Risp/Core/io.risp:
--------------------------------------------------------------------------------
1 | (defn absolute-path [path]
2 | (. path stringByStandardizingPath))
3 |
4 | (defn read-file [file-path]
5 | (. NSData dataWithContentsOfFile: (absolute-path file-path)))
6 |
7 | (defn open [file-path flag]
8 | (cond
9 | (= flag :read-only) (. NSFileHandle fileHandleForReadingAtPath: file-path)
10 | (= flag :write-only) (. NSFileHandle fileHandleForWritingAtPath: file-path)
11 | :else (. NSFileHandle fileHandleForUpdatingAtPath: file-path)))
12 |
13 | (defn cond [& clauses]
14 | (if (not (nil? clauses))
15 | (if (even? (count clauses))
16 | (if (first clauses)
17 | (if (next clauses)
18 | (second clauses)
19 | nil)
20 | (cond (next (next clauses)))))))
21 |
22 |
--------------------------------------------------------------------------------
/Risp/Risp/Core/test.risp:
--------------------------------------------------------------------------------
1 | ((fn [y] (((fn [y] (fn [x] (* y 2))) 3) 0)) 4)
2 | (((fn [m]
3 | ((fn [f] (f f))
4 | (fn [j]
5 | (m (fn [x] ((j j) x))))))
6 | (fn [f]
7 | (fn [coll]
8 | (if (empty? coll)
9 | 0
10 | (+ (first coll) (f (rest coll)))))))
11 | '(1 2 3 4))
12 | (map #(+ % 1) '(1 2 3 4))
13 | (apply + '(1 2 3 4))
14 | (defn 我是 [x n]
15 | (if (zero? n)
16 | '()
17 | (cons x (我是 x (dec n)))))
18 | (def 猫 (. (. NSImage alloc) initWithContentsOfFile: (. "~/Desktop/1.png" stringByStandardizingPath)))
19 | (def 三 3)
20 | (我是 猫 三)
21 |
22 | (defn render-content [path] (. (. NSFileWrapper alloc) initWithPath: (. path stringByStandardizingPath)))
23 | (render-content "~/Desktop/1.gid")
24 | (render-content "~/Desktop/1.pdf")
25 | (render-content "~/Desktop/1.mp4")
26 | (render-content "~/Desktop/1.mp3")
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/NSObject+RispMeta.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+RispMeta.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface NSObject (RispMeta)
13 | - (NSDictionary *)meta;
14 | - (BOOL)hasMeta;
15 | - (id)withMeta:(id)value forKey:(id)key;
16 |
17 | - (id)copyMetaFromObject:(id)object;
18 | @end
19 |
20 | @interface NSObject (RispDebugLocation)
21 | - (NSString *)file;
22 | - (void)setFile:(NSString *)file;
23 |
24 | - (NSInteger)columnNumber;
25 | - (void)setColumnNumber:(NSInteger)columnNumber;
26 |
27 | - (NSInteger)lineNumber;
28 | - (void)setLineNumber:(NSInteger)lineNumber;
29 |
30 | - (NSInteger)start;
31 | - (void)setStart:(NSInteger)start;
32 |
33 | - (NSInteger)end;
34 | - (void)setEnd:(NSInteger)end;
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispCharSequence.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispCharSequence.h
3 | // Risp
4 | //
5 | // Created by closure on 5/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispCharSequence : NSObject
12 | - (id)initWithString:(NSString *)str;
13 | - (NSUInteger)count;
14 | - (id)first;
15 | - (id)next;
16 | - (id)rest;
17 | - (id)last;
18 | - (id)drop:(NSNumber *)n;
19 | - (id)cons:(id)o;
20 | - (id)second;
21 | - (id)copyWithZone:(NSZone *)zone;
22 | - (NSArray *)array;
23 | - (BOOL)isEqualTo:(id)object;
24 | - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block;
25 | @end
26 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispCharSequence.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispCharSequence.m
3 | // Risp
4 | //
5 | // Created by closure on 5/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispCharSequence.h"
10 |
11 | @interface RispCharSequence ()
12 | @property (nonatomic, strong, readonly) NSString *content;
13 | @end
14 |
15 | @implementation RispCharSequence
16 | - (id)initWithString:(NSString *)str {
17 | if (self = [super init]) {
18 | _content = str;
19 | }
20 | return self;
21 | }
22 |
23 | - (NSUInteger)count {
24 | return [_content length];
25 | }
26 |
27 | - (id)first {
28 | return @([_content characterAtIndex:0]);
29 | }
30 |
31 | - (id)next {
32 | return [[RispCharSequence alloc] initWithString:[_content substringWithRange:NSMakeRange(1, [_content length] - 1)]];
33 | }
34 |
35 | - (id)rest {
36 | return [self next] ? : [RispCharSequence empty];
37 | }
38 |
39 | + (id)empty {
40 | return [[RispCharSequence alloc] init];
41 | }
42 |
43 | - (NSString *)description {
44 | return _content;
45 | }
46 | @end
47 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispEnvironmentVariables.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispEnvironmentVariables.h
3 | // Risp
4 | //
5 | // Created by closure on 3/13/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #ifndef Risp_RispEnvironmentVariables_h
10 | #define Risp_RispEnvironmentVariables_h
11 |
12 | #include
13 |
14 | FOUNDATION_EXPORT void RispEnvironmentVariablesInitialize();
15 | FOUNDATION_EXPORT NSString * const RispEnvCurrentFrameworkDirectory;
16 | FOUNDATION_EXPORT NSString * const RispEnvWorkDirectory;
17 | FOUNDATION_EXPORT NSString * const RispEnvIn;
18 | FOUNDATION_EXPORT NSString * const RispEnvOut;
19 | FOUNDATION_EXPORT NSString * const RispEnvError;
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispEnvironmentVariables.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispEnvironmentVariables.c
3 | // Risp
4 | //
5 | // Created by closure on 3/13/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | // environment variable definition
10 |
11 | NSString * const RispEnvCurrentFrameworkDirectory = @"*risp-framework-directory*";
12 | NSString * const RispEnvCurrentWorkDirectory = @"*risp-work-directory*";
13 | NSString * const RispEnvWorkDirectory = @"*risp-work-directory*";
14 | NSString * const RispEnvIn = @"*in*";
15 | NSString * const RispEnvOut = @"*out*";
16 | NSString * const RispEnvError = @"*error*";
17 |
18 | #import
19 |
20 | FOUNDATION_EXPORT void RispEnvironmentVariablesInitialize() {
21 | NSBundle *rispFramework = [NSBundle bundleWithIdentifier:@"com.retval.Risp"];
22 | RispRuntime *rt = [RispRuntime baseEnvironment];
23 | [rt registerSymbol:[RispSymbol named:RispEnvCurrentFrameworkDirectory] forObject:[rispFramework bundlePath]];
24 | NSString *workDirectory = [[NSFileManager defaultManager] currentDirectoryPath];
25 | [rt registerSymbol:[RispSymbol named:RispEnvCurrentWorkDirectory] forObject:workDirectory];
26 |
27 | NSFileHandle *handle = [[NSFileHandle alloc] initWithFileDescriptor:STDIN_FILENO closeOnDealloc:NO];
28 | [rt registerSymbol:[RispSymbol named:RispEnvIn] forObject:handle];
29 | handle = [[NSFileHandle alloc] initWithFileDescriptor:STDOUT_FILENO closeOnDealloc:NO];
30 | [rt registerSymbol:[RispSymbol named:RispEnvOut] forObject:handle];
31 | handle = [[NSFileHandle alloc] initWithFileDescriptor:STDERR_FILENO closeOnDealloc:NO];
32 | [rt registerSymbol:[RispSymbol named:RispEnvError] forObject:handle];
33 | }
34 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispKeyword.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeyword.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import
12 |
13 | @interface RispKeyword : RispSymbol
14 | + (id)named:(NSString *)name;
15 | + (BOOL)isKeyword:(NSString *)object;
16 | - (BOOL)isEqualTo:(id)object;
17 | @end
18 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispLazySequence.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispLazySequence.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispLazySequence : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispLexicalScope.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispLexicalScope.h
3 | // Syrah
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RispSymbol;
12 | @interface RispLexicalScope : NSObject
13 | @property (strong, nonatomic, readonly) RispLexicalScope *inner;
14 | @property (strong, nonatomic, readonly) NSException *exception;
15 | @property (assign, nonatomic) NSUInteger depth;
16 | @property (strong, nonatomic) NSDictionary *scope;
17 | - (id)init;
18 | - (id)initWithParent:(RispLexicalScope *)outer;
19 | - (id)initWithParent:(RispLexicalScope *)outer child:(RispLexicalScope *)inner;
20 |
21 | - (id)objectForKey:(RispSymbol *)symbol;
22 | - (void)setObject:(id)object forKey:(RispSymbol *)aKey;
23 |
24 | - (id)objectForKeyedSubscript:(id)key NS_AVAILABLE(10_8, 6_0);
25 | - (void)setObject:(id)obj forKeyedSubscript:(id )key NS_AVAILABLE(10_8, 6_0);
26 |
27 | - (RispLexicalScope *)outer;
28 |
29 | - (NSArray *)keys;
30 | - (NSArray *)values;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispList.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispList.h
3 | // Risp
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @interface RispList : RispSequence
14 | + (id)listWithObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
15 | + (id)listWithObjectsFromArray:(NSArray *)array;
16 | + (id)listWithRest:(id )rest objects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
17 |
18 | - (id)init;
19 | + (id)empty;
20 |
21 | + (id)creator;
22 | @end
23 |
24 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispMap.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMap.h
3 | // Risp
4 | //
5 | // Created by closure on 5/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispMap : NSObject
12 | + (instancetype)mapWithSequence:(id )seq;
13 | - (id)initWithArray:(NSArray *)array;
14 | - (id )seq;
15 |
16 | - (void)setObject:(id)anObject forKey:(id )aKey;
17 | - (id)objectForKey:(id)aKey;
18 | - (NSEnumerator *)keyEnumerator;
19 |
20 | - (id)objectForKeyedSubscript:(id)key NS_AVAILABLE(10_8, 6_0);
21 | - (void)setObject:(id)obj forKeyedSubscript:(id )key NS_AVAILABLE(10_8, 6_0);
22 | @end
23 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispMetaKeyDefinition.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMetaKeyDefinition.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | FOUNDATION_EXPORT NSString * const RispMetaKeyTag;
11 | FOUNDATION_EXPORT NSString * const RispMetaClassTag;
12 | FOUNDATION_EXPORT NSString * const RispMetaKeyConst;
13 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispMetaKeyDefinition.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispMetaKeyDefinition.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | NSString * const RispMetaKeyTag = @"tag";
11 | NSString * const RispMetaClassTag = @"class";
12 | NSString * const RispMetaKeyConst = @"const";
13 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispSequence.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispSequence.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispSequence : NSObject
13 | @property (nonatomic, assign, readonly) NSInteger count;
14 |
15 | - (id)initWithObject:(id)object base:(RispSequence *)base;
16 | - (id)initWithArray:(NSArray *)array;
17 |
18 | - (id)first;
19 | - (id)next;
20 | - (id)second;
21 | - (id)rest;
22 | - (id)last;
23 | - (id)reverse;
24 | - (id)drop:(NSNumber *)n;
25 | - (id)cons:(id)o;
26 | - (id)conj:(id)o;
27 | - (NSArray *)array;
28 | - (BOOL)isEqualTo:(id)object;
29 |
30 | + (id)empty;
31 | - (BOOL)isEmpty;
32 |
33 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(__unsafe_unretained id [])buffer count:(NSUInteger)len;
34 |
35 | - (NSString *)stringValue;
36 | @end
37 |
38 | @interface RispSequence (Sequence)
39 | + (id )sequence:(id)obj;
40 | @end
41 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispSequenceProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispSequenceProtocol.h
3 | // Syrah
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #ifndef Syrah_RispSequenceProtocol_h
10 | #define Syrah_RispSequenceProtocol_h
11 |
12 | @protocol RispSequence
13 | @required
14 | - (NSUInteger)count;
15 | - (id)first;
16 | - (id)next;
17 | - (id)rest;
18 | - (id)last;
19 | - (id)drop:(NSNumber *)n;
20 | - (id)cons:(id)o;
21 | - (id)second;
22 | - (id)copyWithZone:(NSZone *)zone;
23 | - (NSArray *)array;
24 | - (BOOL)isEqualTo:(id)object;
25 | - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block;
26 | @optional
27 | - (id)conj:(id)o;
28 |
29 | + (id)empty;
30 | - (id)equiv:(id)o;
31 | - (BOOL)isEmpty;
32 | - (id)eval;
33 | @end
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispSymbol+BIF.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispSymbol+BIF.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispSymbol (BIF)
12 | + (RispSymbol *)DO;
13 | + (RispSymbol *)IDENTITY;
14 | + (RispSymbol *)DOT;
15 | + (RispSymbol *)FN;
16 | + (RispSymbol *)AMP;
17 |
18 | + (RispSymbol *)QUOTE;
19 | + (RispSymbol *)APPLY;
20 | + (RispSymbol *)MAP;
21 | + (RispSymbol *)REDUCE;
22 | + (RispSymbol *)FILTER;
23 |
24 | + (RispSymbol *)UNQUOTE;
25 | + (RispSymbol *)UNQUOTESPLICING;
26 | @end
27 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispSymbol+BIF.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispSymbol+BIF.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispSymbol+BIF.h"
10 |
11 | @implementation RispSymbol (BIF)
12 | + (RispSymbol *)DO {
13 | return [RispSymbol named:@"do"];
14 | }
15 |
16 | + (RispSymbol *)IDENTITY {
17 | return [RispSymbol named:@"identity"];
18 | }
19 |
20 | + (RispSymbol *)DOT {
21 | return [RispSymbol named:@"."];
22 | }
23 |
24 | + (RispSymbol *)FN {
25 | return [RispSymbol named:@"fn"];
26 | }
27 |
28 | + (RispSymbol *)AMP {
29 | return [RispSymbol named:@"&"];
30 | }
31 |
32 | + (RispSymbol *)QUOTE {
33 | return [RispSymbol named:@"quote"];
34 | }
35 |
36 | + (RispSymbol *)APPLY {
37 | return [RispSymbol named:@"apply"];
38 | }
39 |
40 | + (RispSymbol *)MAP {
41 | return [RispSymbol named:@"map"];
42 | }
43 |
44 | + (RispSymbol *)REDUCE {
45 | return [RispSymbol named:@"reduce"];
46 | }
47 |
48 | + (RispSymbol *)FILTER {
49 | return [RispSymbol named:@"filter"];
50 | }
51 |
52 | + (RispSymbol *)UNQUOTE {
53 | return [RispSymbol named:@"unquote"];
54 | }
55 |
56 | + (RispSymbol *)UNQUOTESPLICING {
57 | return [RispSymbol named:@"unquote-splicing"];
58 | }
59 | @end
60 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispSymbol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispSymbol.h
3 | // Risp
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispSymbol : NSObject {
12 | @protected
13 | NSString *_stringValue;
14 | NSUInteger _hashCode;
15 | }
16 | @property (strong, nonatomic, readonly) NSString *stringValue;
17 | + (id)named:(NSString *)name;
18 | - (BOOL)isEqualTo:(id)object;
19 | - (NSUInteger)length;
20 | @end
21 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispToken.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispToken.h
3 | // Risp
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispSymbol.h"
10 |
11 | @interface RispToken : RispSymbol
12 | @property (strong, nonatomic, readonly) NSString *stringValue;
13 | + (id)named:(NSString *)name;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispVariable.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispVariable.h
3 | // Risp
4 | //
5 | // Created by closure on 4/19/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | @protocol RispSequence;
11 | @interface RispVariable : NSObject
12 | - (id)applyTo:(id )seq;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispVariable.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispVariable.m
3 | // Risp
4 | //
5 | // Created by closure on 4/19/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispTBox : NSObject
13 | @property (nonatomic, strong) NSThread *thread;
14 | @property (nonatomic, strong) id val;
15 | @end
16 |
17 | @interface RispUnbound : NSObject
18 | @property (nonatomic, strong) RispVariable *var;
19 | + (instancetype)unbound:(RispVariable *)var;
20 | @end
21 |
22 | @implementation RispUnbound
23 |
24 | + (instancetype)unbound:(RispVariable *)var {
25 | RispUnbound *unbound = [[RispUnbound alloc] init];
26 | [unbound setVar:var];
27 | return unbound;
28 | }
29 |
30 | - (NSString *)description {
31 | return [NSString stringWithFormat:@"Unbound: %@", _var];
32 | }
33 |
34 | @end
35 |
36 | @implementation RispVariable
37 | - (id)applyTo:(id )seq {
38 | // RT.cons(form,RT.cons(LOCAL_ENV.get(),form.next()))
39 | return nil;
40 | }
41 | @end
42 |
--------------------------------------------------------------------------------
/Risp/Risp/DataContainer/RispVector.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispVector.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import
12 |
13 | @interface RispVector : NSObject
14 | + (id)listWithObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
15 | + (id)listWithObjectsFromArray:(NSArray *)array;
16 | + (id)listWithObjectsFromArrayNoCopy:(NSArray *)array;
17 |
18 | - (id)init;
19 | - (id)initWithArray:(NSArray *)array;
20 | - (id)initWithArrayNoCopy:(NSArray *)array;
21 | - (id)objectAtIndex:(NSUInteger)index;
22 | - (id)objectAtIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0);
23 | - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block;
24 |
25 | - (NSEnumerator *)objectEnumerator;
26 | - (NSEnumerator *)reverseObjectEnumerator;
27 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len;
28 |
29 | - (NSArray *)array;
30 |
31 | - (id)nth:(NSUInteger)idx;
32 |
33 | + (id)empty;
34 | - (BOOL)isEmpty;
35 |
36 | + (id)creator;
37 |
38 | @end
39 |
40 | @interface RispVector (Mutable)
41 | - (void)addObject:(id)anObject;
42 | - (void)insertObject:(id)anObject atIndex:(NSUInteger)index;
43 | - (void)removeLastObject;
44 | - (void)removeObjectAtIndex:(NSUInteger)index;
45 | - (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
46 | - (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
47 | - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0);
48 | @end
49 |
50 |
--------------------------------------------------------------------------------
/Risp/Risp/Documents/Design/RispDesign.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/Risp/Documents/Design/RispDesign.graffle
--------------------------------------------------------------------------------
/Risp/Risp/Documents/Design/RispUML.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/Risp/Documents/Design/RispUML.graffle
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispAbstractSyntaxTree.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispAbstractSyntaxTree.h
3 | // Risp
4 | //
5 | // Created by closure on 5/24/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import
12 | @interface RispAbstractSyntaxTree : NSObject
13 | - (id)init;
14 | - (id)initWithExpression:(id)object;
15 | - (id)object;
16 | + (NSMutableString *)descriptionAppendIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc;
17 | + (NSMutableString *)descriptionAppendIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc fixupIfNeeded:(BOOL)needFixup;
18 | - (NSString *)description;
19 | - (NSString *)descriptionWithLocale:(NSLocale *)locale;
20 |
21 | + (NSString *)descriptionAppendIndentation:(NSUInteger)indentation forObject:(id)object;
22 | + (void)show:(id)object;
23 | @end
24 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBaseExpression+ASTDescription.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseExpression+ASTDescription.h
3 | // Risp
4 | //
5 | // Created by closure on 5/24/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispBaseExpression (ASTDescription)
12 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBaseExpression+ASTDescription.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseExpression+ASTDescription.m
3 | // Risp
4 | //
5 | // Created by closure on 5/24/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseExpression+ASTDescription.h"
10 | #import "RispAbstractSyntaxTree.h"
11 |
12 | @implementation RispBaseExpression (ASTDescription)
13 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
14 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
15 | }
16 | @end
17 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBaseExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @class RispContext;
13 | @protocol RispExpression
14 | @required
15 | + (id )parser:(id)object context:(RispContext *)context;
16 | - (id)eval;
17 | - (id)copyMetaFromObject:(id)object;
18 | @end
19 | @interface RispBaseExpression : NSObject
20 | - (id)eval;
21 | - (NSString *)description;
22 | @end
23 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBaseExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseExpression.h"
10 |
11 | @implementation RispBaseExpression
12 | + (id )parser:(id)object context:(RispContext *)context {
13 | return nil;
14 | }
15 |
16 | - (id)eval {
17 | return nil;
18 | }
19 |
20 | - (NSString *)description {
21 | return [[self eval] description];
22 | }
23 |
24 | - (id)copyWithZone:(NSZone *)zone {
25 | RispBaseExpression *baseExpression = [[RispBaseExpression alloc] init];
26 | return baseExpression;
27 | }
28 |
29 | - (id)copyMetaFromObject:(id)object {
30 | return [super copyMetaFromObject:object];
31 | }
32 | @end
33 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBlockExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBlockExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/8/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispBlockExpression : RispMethodExpression
13 | @property (nonatomic, strong, readonly) id (^block)(RispVector *arguments);
14 | @property (nonatomic, assign, readonly) NSUInteger numberOfArguments;
15 | + (id)parser:(id)object context:(RispContext *)context;
16 | + (id)blockWihObjcBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments;
17 | - (id)initWithBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments;
18 | - (id)applyTo:(RispVector *)arguments;
19 | - (BOOL)isVariadic;
20 | - (NSInteger)paramsCount;
21 | @end
22 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBlockExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispBlockExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 5/8/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBlockExpression.h"
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @interface RispBlockExpression () {
14 | @private
15 | BOOL _variadic;
16 | }
17 |
18 | @end
19 |
20 | @implementation RispBlockExpression
21 | + (id)parser:(id)object context:(RispContext *)context {
22 | return [super parser:object context:context];
23 | }
24 |
25 | + (id)blockWihObjcBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments {
26 | return [[RispBlockExpression alloc] initWithBlock:block variadic:isVariadic numberOfArguments:numberOfArguments];
27 | }
28 |
29 | - (id)initWithBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments {
30 | if (self = [super init]) {
31 | _block = block;
32 | _variadic = isVariadic;
33 | _numberOfArguments = numberOfArguments;
34 | }
35 | return self;
36 | }
37 |
38 | - (id)applyTo:(RispVector *)arguments {
39 | if (!_block) return nil;
40 | return _block(arguments);
41 | }
42 |
43 | - (BOOL)isVariadic {
44 | return _variadic;
45 | }
46 |
47 | - (NSString *)description {
48 | return [NSString stringWithFormat:@"%@ %@", NSStringFromClass([self class]), _block];
49 | }
50 |
51 | - (NSInteger)paramsCount {
52 | return _numberOfArguments;
53 | }
54 |
55 | - (id)copyWithZone:(NSZone *)zone {
56 | RispBlockExpression *copy = [[RispBlockExpression alloc] initWithBlock:[_block copy] variadic:_variadic numberOfArguments:_numberOfArguments];
57 | return copy;
58 | }
59 | @end
60 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispBodyExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBodyExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/22/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispBodyExpression : RispBaseExpression
12 | + (RispBodyExpression *)parser:(id )form context:(RispContext *)context;
13 |
14 | @property (nonatomic, strong, readonly) RispVector *exprs;
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispClosureExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispClosureExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/22/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @interface RispClosureExpression : RispBaseExpression
15 | @property (nonatomic, strong, readonly) RispFnExpression *fnExpression;
16 | @property (nonatomic, strong, readonly) RispLexicalScope *environment;
17 | - (id)initWithLexicalScopeEnvironment:(RispLexicalScope *)environment fnExpression:(RispFnExpression *)fnExpression;
18 | - (RispMethodExpression *)methodForCountOfArgument:(NSUInteger)cntOfArguments;
19 | @end
20 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispConstantExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispConstantExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/13/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispConstantExpression : RispLiteralExpression
12 | @property (nonatomic, strong, readonly) id constantValue;
13 | + (id)parser:(id)object context:(RispContext *)context;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispDefExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispDefExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/23/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispDefExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) RispSymbol *key;
13 | @property (nonatomic, strong, readonly) id value;
14 |
15 | + (id)parser:(id)object context:(RispContext *)context;
16 | + (RispSymbol *)speicalKey;
17 | @end
18 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispDefnExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispDefnExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/5/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispDefnExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) RispSymbol *key;
13 | @property (nonatomic, strong, readonly) id value;
14 |
15 | + (id)parser:(id)object context:(RispContext *)context;
16 | + (RispSymbol *)speicalKey;
17 | @end
18 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispDotExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispDotExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/23/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispDotExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) id target;
13 | @property (nonatomic, assign, readonly) SEL selector;
14 | @property (nonatomic, strong, readonly) id exprs;
15 |
16 | + (id)parser:(id)object context:(RispContext *)context;
17 | - (id)eval;
18 |
19 | + (RispSymbol *)speicalKey;
20 | @end
21 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispFalseExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispFalseExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispFalseExpression : RispLiteralExpression
12 | - (instancetype)init;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispFalseExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispFalseExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @implementation RispFalseExpression
14 | - (instancetype)init {
15 | if (self = [super init]) {
16 | _value = @NO;
17 | }
18 | return self;
19 | }
20 |
21 | - (id)value {
22 | return _value;
23 | }
24 |
25 | - (NSString *)description {
26 | return [[self value] description];
27 | }
28 |
29 | - (id)copyWithZone:(NSZone *)zone {
30 | RispFalseExpression *copy = [[RispFalseExpression alloc] initWithValue:_value];
31 | return copy;
32 | }
33 |
34 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
35 | [super _descriptionWithIndentation:indentation desc:desc];
36 | [desc appendFormat:@"%@ - %@ %@\n", [self class], [self description], [self rispLocationInfomation]];
37 | }
38 | @end
39 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispFnExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispFnExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/21/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 |
18 | @interface RispFnExpression : RispBaseExpression
19 | @property (nonatomic, strong) RispSymbol *name;
20 | @property (nonatomic, strong) RispMethodExpression *variadicMethod;
21 | @property (nonatomic, strong) RispList *methods;
22 | //@property (nonatomic, strong) RispSymbol *name;
23 |
24 | + (RispFnExpression *)parse:(id )form context:(RispContext *)context;
25 |
26 | - (id)applyTo:(RispVector *)arguments;
27 |
28 | - (id)copyWithZone:(NSZone *)zone;
29 | @end
30 |
31 | @interface RispFnExpression (BlockSupport)
32 | + (instancetype)blockWihObjcBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments;
33 | - (id)initWithBlock:(id (^)(RispVector *arguments))block variadic:(BOOL)isVariadic numberOfArguments:(NSUInteger)numberOfArguments;
34 | @end
35 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispFnProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispFnProtocol.h
3 | // Risp
4 | //
5 | // Created by closure on 5/22/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @class RispMethodExpression, RispVector;
13 | @protocol RispFnProtocol
14 | @required
15 | - (RispMethodExpression *)methodForCountOfArgument:(NSUInteger)cntOfArguments;
16 |
17 | @optional
18 | - (RispMethodExpression *)methodForArguments:(RispVector *)arguments;
19 | @end
20 |
21 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispIRCodeGenerator.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispIRCodeGenerator.h
3 | // Risp
4 | //
5 | // Created by closure on 5/8/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol RispIRCodeGenerator
12 | - (void *)generateCode:(id)context; // RispCodeGeneratorContext
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispIfExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispIfExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/13/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispIfExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) RispBaseExpression *testExpression;
13 | @property (nonatomic, strong, readonly) RispBaseExpression *thenExpression;
14 | @property (nonatomic, strong, readonly) RispBaseExpression *elseExpression;
15 |
16 | + (id)parser:(id)object context:(RispContext *)context;
17 | + (RispSymbol *)speicalKey;
18 | @end
19 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispInvokeExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispInvokeExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/23/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispInvokeExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) id fexpr;
13 | @property (nonatomic, strong, readonly) RispVector *arguments;
14 | + (RispInvokeExpression *)parser:(id )form context:(RispContext *)context;
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispInvokeProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispInvokeProtocol.h
3 | // Risp
4 | //
5 | // Created by closure on 5/4/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RispVector;
12 | @protocol RispInvokeProtocol
13 | @required
14 | - (id)applyTo:(RispVector *)arguments;
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispKeywordExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeywordExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispKeywordExpression : RispLiteralExpression
13 | + (id)parser:(id)object context:(RispContext *)context;
14 | - (id)initWithKeyword:(RispKeyword *)keyword;
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispKeywordExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeywordExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @implementation RispKeywordExpression
14 | + (id)parser:(id)object context:(RispContext *)context {
15 | return [[[RispKeywordExpression alloc] initWithKeyword:object] copyMetaFromObject:object];
16 | }
17 |
18 | - (id)initWithKeyword:(RispKeyword *)keyword {
19 | if (self = [super initWithValue:keyword]) {
20 | }
21 | return self;
22 | }
23 |
24 | - (id)value {
25 | return _value;
26 | }
27 |
28 | - (NSString *)description {
29 | return [_value description];
30 | }
31 |
32 | - (id)copyWithZone:(NSZone *)zone {
33 | RispKeywordExpression *copy = [[RispKeywordExpression alloc] initWithValue:_value];
34 | return copy;
35 | }
36 |
37 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
38 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
39 | [desc appendFormat:@"%@ - %@ %@\n", [self class], [self description], [self rispLocationInfomation]];
40 | }
41 | @end
42 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispKeywordInvokeExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeywordInvokeExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/28/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispKeywordInvokeExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) RispBaseExpression *targetExpression;
13 | @property (nonatomic, strong, readonly) RispKeywordExpression *keywordExpression;
14 | - (id)initWithTargetExpression:(RispBaseExpression *)target keyword:(RispKeywordExpression *)keyword;
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispKeywordInvokeExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeywordInvokeExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 5/28/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RispKeywordInvokeExpression.h"
11 | #import "RispAbstractSyntaxTree.h"
12 | #import "RispBaseExpression+ASTDescription.h"
13 |
14 | @implementation RispKeywordInvokeExpression
15 |
16 | - (id)initWithTargetExpression:(RispBaseExpression *)target keyword:(RispKeywordExpression *)keyword {
17 | if (self = [super init]) {
18 | _targetExpression = target;
19 | _keywordExpression = keyword;
20 | }
21 | return self;
22 | }
23 |
24 | - (id)eval {
25 | RispMap *target = [_targetExpression eval];
26 | if (![target isKindOfClass:[RispMap class]]) {
27 | [NSException raise:RispIllegalArgumentException format:@"%@ is not a map", _targetExpression];
28 | }
29 | RispKeyword *keyword = [_keywordExpression eval];
30 | if (![keyword isKindOfClass:[RispKeyword class]]) {
31 | [NSException raise:RispIllegalArgumentException format:@"%@ is not a keyword", _keywordExpression];
32 | }
33 | return [target objectForKey:keyword];
34 | }
35 |
36 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
37 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
38 | [desc appendFormat:@"%@\n", [self className]];
39 | [_keywordExpression _descriptionWithIndentation:indentation + 1 desc:desc];
40 | [_targetExpression _descriptionWithIndentation:indentation + 1 desc:desc];
41 | }
42 | @end
43 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispLetExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispLetExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/25/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispLetExpression : RispBaseExpression
12 | @property (nonatomic, strong, readonly) RispVectorExpression *bindingExpression;
13 | @property (nonatomic, strong, readonly) RispBaseExpression *expression;
14 | + (id)parser:(id)object context:(RispContext *)context;
15 | + (RispSymbol *)speicalKey;
16 | @end
17 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispLiteralExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispLiteralExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispLiteralExpression : RispBaseExpression {
12 | @package
13 | id _value;
14 | }
15 |
16 | - (id)initWithValue:(id)value;
17 | - (id)value;
18 | - (id)literalValue;
19 | - (id)eval;
20 | @end
21 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispLiteralExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispLiteralExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "RispAbstractSyntaxTree.h"
12 | #import "RispBaseExpression+ASTDescription.h"
13 |
14 | @implementation RispLiteralExpression
15 | - (id)initWithValue:(id)value {
16 | if (self = [super init]) {
17 | _value = value;
18 | }
19 | return self;
20 | }
21 |
22 | - (id)value {
23 | RispLexicalScope *scope = [[RispContext currentContext] currentScope];
24 | return scope[_value];
25 | }
26 |
27 | - (id)literalValue {
28 | return _value;
29 | }
30 |
31 | - (id)eval {
32 | return [self value];
33 | }
34 |
35 | - (NSString *)description {
36 | return [_value description];
37 | }
38 |
39 | - (id)copyWithZone:(NSZone *)zone {
40 | RispLiteralExpression *copy = [[RispLiteralExpression alloc] initWithValue:_value];
41 | return copy;
42 | }
43 |
44 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
45 | [super _descriptionWithIndentation:indentation desc:desc];
46 | [desc appendFormat:@"%@ : %@ %@\n", [self class], [self description], [_value rispLocationInfomation]];
47 | }
48 | @end
49 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispMapExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMapExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 5/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispMapExpression : RispBaseExpression
12 | + (id)parser:(id)object context:(RispContext *)context;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispMethodExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMethodExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/21/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @class RispFnExpression, RispBodyExpression;
15 | @interface RispMethodExpression : RispBaseExpression
16 |
17 | @property (nonatomic, strong, readonly) RispBodyExpression *bodyExpression;
18 | @property (nonatomic, strong) NSMutableArray *argstypes;
19 | @property (nonatomic, strong) NSString *prim;
20 | @property (nonatomic, strong) RispVector *requiredParms;
21 | @property (nonatomic, strong) RispSymbol *restParm;
22 |
23 | @property (nonatomic, assign, readonly, getter = isStatics) BOOL statics;
24 |
25 | @property (nonatomic, strong) RispLexicalScope *localBinding;
26 | + (RispMethodExpression *)parser:(id )form context:(RispContext *)context fn:(RispFnExpression *)fn static:(BOOL)isStatic;
27 |
28 | + (void)bindArguments:(RispVector *)arguments forMethod:(RispMethodExpression *)method toScope:(RispLexicalScope *)scope;
29 |
30 | - (NSInteger)paramsCount;
31 | - (BOOL)isVariadic;
32 |
33 | - (id)applyTo:(RispVector *)arguments;
34 | @end
35 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispNilExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispNilExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispNilExpression : RispLiteralExpression;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispNilExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispNilExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @implementation RispNilExpression
14 | - (instancetype)init {
15 | if (self = [super init]) {
16 | _value = [NSNull null];
17 | }
18 | return self;
19 | }
20 |
21 | - (id)value {
22 | return _value;
23 | }
24 |
25 | - (NSString *)description {
26 | return @"nil";
27 | }
28 |
29 | - (id)copyWithZone:(NSZone *)zone {
30 | RispNilExpression *copy = [[RispNilExpression alloc] initWithValue:_value];
31 | return copy;
32 | }
33 |
34 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
35 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
36 | [desc appendFormat:@"%@ - %@ %@\n", [self class], [self description], [self rispLocationInfomation]];
37 | }
38 | @end
39 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispNumberExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispNumberExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RispNumberExpression : RispLiteralExpression
13 | + (id)parser:(id)object context:(RispContext *)context;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispNumberExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispNumberExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispNumberExpression.h"
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @implementation RispNumberExpression
14 | + (id)parser:(id)object context:(RispContext *)context {
15 | return [[[RispNumberExpression alloc] initWithValue:object] copyMetaFromObject:object];
16 | }
17 |
18 | - (id)value {
19 | return _value;
20 | }
21 |
22 | - (NSString *)description {
23 | return [_value description];
24 | }
25 |
26 | - (id)copyWithZone:(NSZone *)zone {
27 | RispNumberExpression *copy = [[RispNumberExpression alloc] initWithValue:_value];
28 | return copy;
29 | }
30 |
31 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
32 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
33 | [desc appendFormat:@"%@ : %@ %@\n", [self class], [self description], [_value rispLocationInfomation]];
34 | }
35 | @end
36 |
37 | @interface NSDecimalNumber (Compare)
38 | - (NSNumber *)compareTo:(NSDecimalNumber *)n;
39 | @end
40 |
41 | @implementation NSDecimalNumber (Compare)
42 |
43 | - (NSDecimalNumber *)compareTo:(NSNumber *)decimalNumber {
44 | NSComparisonResult result = [self compare:decimalNumber];
45 | return [[NSDecimalNumber alloc] initWithLong:result];
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispStringExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispStringExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispStringExpression : RispLiteralExpression
12 | + (id)parser:(id)object context:(RispContext *)context;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispStringExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispStringExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/20/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispStringExpression.h"
10 | #import "RispAbstractSyntaxTree.h"
11 | #import "RispBaseExpression+ASTDescription.h"
12 |
13 | @implementation RispStringExpression
14 | + (id)parser:(id)object context:(RispContext *)context {
15 | return [[[RispStringExpression alloc] initWithValue:object] copyMetaFromObject:object];
16 | }
17 |
18 | - (id)value {
19 | return _value;
20 | }
21 |
22 | - (NSString *)description {
23 | return _value;
24 | }
25 |
26 | - (id)copyWithZone:(NSZone *)zone {
27 | RispStringExpression *copy = [[RispStringExpression alloc] initWithValue:_value];
28 | return copy;
29 | }
30 |
31 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
32 | [RispAbstractSyntaxTree descriptionAppendIndentation:indentation desc:desc];
33 | [desc appendFormat:@"%@ - %@ %@\n", [self class], [self description], [self rispLocationInfomation]];
34 | }
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispTrueExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispTrueExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispTrueExpression : RispLiteralExpression
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispTrueExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispTrueExpression.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "RispAbstractSyntaxTree.h"
12 | #import "RispBaseExpression+ASTDescription.h"
13 |
14 | @implementation RispTrueExpression
15 | - (instancetype)init {
16 | if (self = [super init]) {
17 | _value = @YES;
18 | }
19 | return self;
20 | }
21 |
22 | - (id)value {
23 | return _value;
24 | }
25 |
26 | - (NSString *)description {
27 | return [[self value] description];
28 | }
29 |
30 | - (id)copyWithZone:(NSZone *)zone {
31 | RispTrueExpression *copy = [[RispTrueExpression alloc] initWithValue:_value];
32 | return copy;
33 | }
34 |
35 | - (void)_descriptionWithIndentation:(NSUInteger)indentation desc:(NSMutableString *)desc {
36 | [super _descriptionWithIndentation:indentation desc:desc];
37 | [desc appendFormat:@"%@ - %@ %@\n", [self class], [self description], [self rispLocationInfomation]];
38 | }
39 | @end
40 |
--------------------------------------------------------------------------------
/Risp/Risp/Expression/RispVectorExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispVectorExpression.h
3 | // Risp
4 | //
5 | // Created by closure on 4/21/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @interface RispVectorExpression : RispBaseExpression
14 | @property (nonatomic, strong, readonly) RispVector *vector;
15 | + (RispVectorExpression *)parse:(RispVector *)vector context:(RispContext *)context;
16 | - (id)initWithVector:(RispVector *)vector;
17 | @end
18 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/NSDecimalNumber+Math.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDecimalNumber+Math.h
3 | // Risp
4 | //
5 | // Created by closure on 5/30/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDecimalNumber (Math)
12 | - (id)mod:(NSDecimalNumber *)n;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/NSDecimalNumber+Math.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDecimalNumber+Math.m
3 | // Risp
4 | //
5 | // Created by closure on 5/30/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "NSDecimalNumber+Math.h"
10 |
11 | @implementation NSDecimalNumber (Math)
12 | - (id)mod:(NSDecimalNumber *)divisor {
13 | NSDecimalNumber *quotient = [self decimalNumberByDividingBy:divisor withBehavior:[NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundDown scale:0 raiseOnExactness:NO raiseOnOverflow:NO raiseOnUnderflow:NO raiseOnDivideByZero:NO]];
14 | NSDecimalNumber *subtractAmount = [quotient decimalNumberByMultiplyingBy:divisor];
15 | NSDecimalNumber *remainder = [self decimalNumberBySubtracting:subtractAmount];
16 | return remainder;
17 | }
18 | @end
19 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/NSNull+Risp.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSNull+Risp.h
3 | // Risp
4 | //
5 | // Created by closure on 5/31/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSNull (Risp)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/NSNull+Risp.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSNull+Risp.m
3 | // Risp
4 | //
5 | // Created by closure on 5/31/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "NSNull+Risp.h"
10 |
11 | @implementation NSNull (Risp)
12 | - (NSString *)description {
13 | return @"nil";
14 | }
15 | @end
16 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/RispFixupHook.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispFixupHook.h
3 | // Risp
4 | //
5 | // Created by closure on 5/12/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispFixupHook : NSObject
12 | + (void)hookFromClass:(id)targetClass selector:(SEL)targetSelector withClass:(id)class withSelector:(SEL)selector;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/RispFixupHook.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispFixupHook.m
3 | // Risp
4 | //
5 | // Created by closure on 5/12/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispFixupHook.h"
10 | #include
11 |
12 | @implementation RispFixupHook
13 | + (void)hookFromClass:(id)targetClass selector:(SEL)targetSelector withClass:(id)class withSelector:(SEL)selector {
14 | Method methodOfCFBoolean = class_getInstanceMethod(targetClass, targetSelector);
15 | Method methodOfImp = class_getInstanceMethod(class, selector);
16 | method_exchangeImplementations(methodOfCFBoolean, methodOfImp);
17 | }
18 | @end
19 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/__RispFXHookNSCFBoolean.h:
--------------------------------------------------------------------------------
1 | //
2 | // __RispFXHookNSCFBoolean.h
3 | // Risp
4 | //
5 | // Created by closure on 5/12/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RispFixupHook.h"
11 | @interface __RispFXHookNSCFBoolean : NSNumber
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/__RispFXNSString.h:
--------------------------------------------------------------------------------
1 | //
2 | // __RispFXNSString.h
3 | // Risp
4 | //
5 | // Created by closure on 5/29/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString (appendString)
12 | - (id)copyWithAppendString:(NSString *)string;
13 | @end
14 |
15 | @interface NSMutableString (appendString)
16 | - (id)copyWithAppendString:(NSString *)string;
17 | @end
18 |
19 | @interface NSString (URL)
20 | + (id)stringWithContentsOfURL:(NSURL *)url;
21 | @end
22 |
23 | @interface NSString (File)
24 | + (id)stringWithContentsOfFile:(NSString *)path;
25 | @end
26 |
27 | @interface NSData (Str)
28 | - (NSString *)stringValue;
29 | @end
30 |
31 | @interface __RispFXNSString : NSObject
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Risp/Risp/FixupHook/__RispFXNSString.m:
--------------------------------------------------------------------------------
1 | //
2 | // __RispFXNSString.m
3 | // Risp
4 | //
5 | // Created by closure on 5/29/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "__RispFXNSString.h"
10 |
11 | @implementation NSString (appendString)
12 |
13 | - (id)copyWithAppendString:(NSString *)string {
14 | if (!string)
15 | return self;
16 | return [NSString stringWithFormat:@"%@%@", self, string];
17 | }
18 |
19 | @end
20 |
21 | @implementation NSMutableString (appendString)
22 |
23 | - (id)copyWithAppendString:(NSString *)string {
24 | if (!string)
25 | return self;
26 | [self appendString:string];
27 | return self;
28 | }
29 |
30 | @end
31 |
32 | @implementation NSString (URL)
33 |
34 | + (id)stringWithContentsOfURL:(NSURL *)url {
35 | return [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
36 | }
37 |
38 | @end
39 |
40 | @implementation NSString (File)
41 |
42 | + (id)stringWithContentsOfFile:(NSString *)path {
43 | return [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
44 | }
45 |
46 | @end
47 |
48 | @implementation NSData (Str)
49 | - (NSString *)stringValue {
50 | return [[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding];
51 | }
52 | @end
53 |
54 | @implementation __RispFXNSString
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/Risp/Risp/Parser/RispBaseParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseParser.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @class RispContext, RispSymbol, RispLexicalScope;
13 | @interface RispBaseParser : NSObject
14 | + (id)parser:(id)object context:(RispContext *)context;
15 | + (id )analyze:(RispContext *)context form:(id)form;
16 | @end
17 |
18 | @interface RispBaseParser (tag)
19 | + (RispSymbol *)tagOfObject:(id)o;
20 | + (id)resolveSymbol:(RispSymbol *)symbol allowPrivate:(BOOL)allowPrivate inScope:(RispLexicalScope *)scope;
21 | @end
22 |
--------------------------------------------------------------------------------
/Risp/Risp/Parser/RispBodyParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBodyParser.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseParser.h"
10 |
11 | @class RispVector;
12 | @interface RispBodyParser : RispBaseParser
13 | @property (nonatomic, strong) RispVector *exprs;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Parser/RispBodyParser.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispBodyParser.m
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 |
16 | id EVAL = @"";
17 | id STATEMENT = @"";
18 |
19 | @implementation RispBodyParser
20 | + (id)parseWithContext:(RispContext *)context object:(id)object {
21 | RispSequence *seq = (RispSequence *)object;
22 | if ([[RispSymbol DO] isEqualTo:[seq first]]) {
23 | seq = [seq next];
24 | }
25 | RispVector *exprs = [RispVector empty];
26 | for (; seq; seq = [seq next]) {
27 | id e = (context != EVAL && (context == STATEMENT || [seq next] != nil)) ? [self analyze:STATEMENT form:[seq first]] : [self analyze:context form:[seq first]];
28 | exprs = [exprs cons:e];
29 | }
30 | return nil;
31 | }
32 | @end
33 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispAnonymousFunctionReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispAnonymousFunctionReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispAnonymousFunctionReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispAnonymousFunctionReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispAnonymousFunctionReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation RispAnonymousFunctionReader
15 | - (id)invoke:(RispReader *)reader object:(id)object {
16 | id seq = nil;
17 | @try {
18 | RispContext *context = [RispContext currentContext];
19 | [context pushScope];
20 | [[reader reader] unread:'('];
21 | id form = [reader readEofIsError:YES eofValue:nil isRecursive:YES];
22 | NSArray *args = [[[context currentScope] keys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
23 | return [[obj1 stringValue] compare:[obj2 stringValue] options:NSNumericSearch];
24 | }];
25 | seq = [RispList listWithObjectsFromArray:@[[RispSymbol FN], [RispVector listWithObjectsFromArrayNoCopy:args], form]];
26 | }
27 | @catch (NSException *exception) {
28 | @throw exception;
29 | }
30 | @finally {
31 | [[RispContext currentContext] popScope];
32 | }
33 | return seq;
34 | }
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispArgumentsReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispArgumentsReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispArgumentsReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispBaseReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispBaseReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | @class RispPushBackReader, RispReader, RispList;
11 |
12 | FOUNDATION_EXPORT NSMutableArray *RispMacros;
13 | FOUNDATION_EXPORT NSMutableArray *RispDispatchMacros;
14 |
15 | @interface RispBaseReader : NSObject
16 | @property (nonatomic, strong, readonly) NSString *content;
17 | @property (nonatomic, strong, readonly) NSString *file;
18 | + (BOOL)isWhiteSpace:(NSInteger)ch;
19 | + (BOOL)isDigit:(NSInteger)ch;
20 | + (BOOL)isDigit:(NSInteger)ch decimal:(NSInteger)decimal;
21 | + (BOOL)isTerminatingMacro:(NSInteger)ch;
22 | + (BOOL)isMacros:(NSInteger)ch;
23 | + (id)macro:(NSInteger)ch;
24 | + (NSInteger)readUnicodeChar:(RispPushBackReader *)reader ch:(NSInteger)ch decimal:(NSInteger)base length:(NSUInteger)length exact:(BOOL)exact;
25 |
26 | - (id)initWithContent:(NSString *)content fileNamed:(NSString *)file;
27 | - (id)initWithContentsOfFile:(NSString *)path;
28 | - (id)initWithData:(NSData *)data fileNamed:(NSString *)file;
29 | - (id)invoke:(RispReader *)reader object:(id)object;
30 | - (RispList *)reader:(RispReader *)reader delimited:(unichar)delimit recursive:(BOOL)isRecursive;
31 | @end
32 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispCommentReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispCommentReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispCommentReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispCommentReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispCommentReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @implementation RispCommentReader
14 | - (id)invoke:(RispReader *)reader object:(id)object {
15 | NSInteger ch = 0;
16 | do {
17 | ch = [[reader reader] read1];
18 | } while (ch != 0 && ch != '\n' && ch != '\r');
19 | return reader;
20 | }
21 | @end
22 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispDispatchReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispDispatchReader.h
3 | // Risp
4 | //
5 | // Created by closure on 5/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispDispatchReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispDispatchReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispDispatchReader.m
3 | // Risp
4 | //
5 | // Created by closure on 5/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @implementation RispDispatchReader
13 | - (id)invoke:(RispReader *)reader object:(id)object {
14 | UniChar ch = [[reader reader] read1];
15 | if(ch == 0)
16 | [NSException raise:RispRuntimeException format:@"EOF while reading character"];
17 | RispBaseReader *dispatchReader = RispDispatchMacros[ch];
18 |
19 | // Try the ctor reader first
20 | if(dispatchReader == nil) {
21 | [[reader reader] unread:ch];
22 | id result = [dispatchReader invoke:reader object:object];
23 |
24 | if(result != nil) {
25 | return result;
26 | } else {
27 | [NSException raise:RispRuntimeException format:@"No dispatch macro for: %c", (char) ch];
28 | }
29 | }
30 | return [dispatchReader invoke:reader object:object];
31 | }
32 | @end
33 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispListReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispListReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @class RispReader;
12 | @interface RispListReader : RispBaseReader
13 | - (id)invoke:(RispReader *)reader object:(id)object;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispListReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispListReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 |
15 | @implementation RispListReader
16 | - (id)invoke:(RispReader *)reader object:(id)object {
17 | RispList *list = [self reader:reader delimited:')' recursive:YES];
18 | if ([list isEmpty]) {
19 | return [RispList empty];
20 | }
21 | return list;
22 | }
23 | @end
24 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispMapReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMapReader.h
3 | // Risp
4 | //
5 | // Created by closure on 5/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispMapReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispMapReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispMapReader.m
3 | // Risp
4 | //
5 | // Created by closure on 5/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispMapReader.h"
10 | #import
11 | #import
12 |
13 | @implementation RispMapReader
14 | - (id)invoke:(RispReader *)reader object:(id)object {
15 | return [RispMap mapWithSequence:[self reader:reader delimited:'}' recursive:YES]];
16 | }
17 | @end
18 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispNumberReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispNumberReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispNumberReader : RispBaseReader
12 | + (NSNumber *)matchNumber:(NSString *)s;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispNumberReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispNumberReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation RispNumberReader
15 |
16 | + (id)matchNumber:(NSString *)s {
17 | NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
18 | [f setNumberStyle:NSNumberFormatterDecimalStyle];
19 | NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:s];
20 | return num;
21 | }
22 |
23 | - (id)invoke:(RispReader *)reader object:(id)object {
24 | unichar initch = [[reader reader] read1];
25 | NSMutableString *sb = [[NSMutableString alloc] init];
26 | [sb appendFormat:@"%C", initch];
27 | for (; ;) {
28 | NSInteger ch = [[reader reader] read1];
29 | if (ch == 0 || [RispBaseReader isWhiteSpace:ch] || [RispBaseReader isMacros:ch]) {
30 | [[reader reader] unread:ch];
31 | break;
32 | }
33 | [sb appendFormat:@"%C", (unichar)ch];
34 | }
35 | id n = [RispNumberReader matchNumber:sb];
36 | if (n == nil) {
37 | [NSException raise:RispInvalidNumberFormatException format:@"invalid number format: %@", sb];
38 | }
39 | return n;
40 | }
41 | @end
42 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispPushBackReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispPushBackReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispPushBackReader : RispBaseReader {
12 | @private
13 | UniChar *_buf;
14 | NSInteger _length;
15 | }
16 | @property (assign, nonatomic, readonly) NSInteger pos;
17 | @property (assign, nonatomic, readonly) NSInteger length;
18 |
19 | @property (assign, nonatomic, readonly) NSInteger columnNumber;
20 | @property (assign, nonatomic, readonly) NSInteger lineNumber;
21 |
22 | - (id)initWithContent:(NSString *)content fileNamed:(NSString *)file;
23 | - (id)initWithContentsOfFile:(NSString *)file;
24 | - (UniChar)read;
25 | - (UniChar)read1;
26 |
27 | - (UniChar)read:(NSMutableString *)buffer offset:(NSInteger)offset count:(NSInteger)count;
28 | - (BOOL)ready;
29 | - (void)unreadFromBuffer:(NSMutableString *)buffer;
30 | - (void)unread:(NSMutableString *)buffer offset:(NSInteger)offset length:(NSInteger)length;
31 | - (void)unread:(NSInteger)oneChar;
32 | - (NSInteger)skip;
33 | @end
34 |
35 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 | #import "RispPushBackReader.h"
11 | @class RispSymbol;
12 | @interface RispReader : RispBaseReader
13 | @property (nonatomic, strong, readonly) RispPushBackReader *reader;
14 | - (id)invoke:(RispReader *)reader object:(id)object;
15 | - (id)readEofIsError:(BOOL)eofIsError eofValue:(id)eofValue isRecursive:(BOOL)recursive;
16 | - (id)interpretToken:(NSString *)token;
17 | - (BOOL)isEnd;
18 | - (id)setupDebugInformationForObject:(id)object start:(NSInteger)start columnNumber:(NSInteger)columnNumber lineNumber:(NSInteger)lineNumber;
19 | @end
20 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispRegexReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispRegexReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispRegexReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispRegexReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispRegexReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @implementation RispRegexReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispStringReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispStringReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispStringReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispSyntaxQuoteReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispSyntaxQuoteReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispSyntaxQuoteReader : RispBaseReader
12 | - (id)invoke:(RispReader *)reader object:(id)object;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispTokenReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispTokenReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispBaseReader.h"
10 |
11 | @interface RispTokenReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispTokenReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispTokenReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation RispTokenReader
15 | - (id)invoke:(RispReader *)reader object:(id)object {
16 | UniChar initch = [[reader reader] read1];
17 | NSMutableString *sb = [[NSMutableString alloc] init];
18 | [sb appendFormat:@"%C", initch];
19 | for (; ;) {
20 | UniChar ch = [[reader reader] read1];
21 | if (ch == 0 || [RispBaseReader isWhiteSpace:ch] || [RispBaseReader isTerminatingMacro:ch]) {
22 | [[reader reader] unread:ch];
23 | return sb;
24 | }
25 | [sb appendFormat:@"%C", ch];
26 | }
27 | return nil;
28 | }
29 | @end
30 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispUnmatchedDelimiterReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispUnmatchedDelimiterReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispUnmatchedDelimiterReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispUnmatchedDelimiterReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispUnmatchedDelimiterReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispUnmatchedDelimiterReader.h"
10 | #import
11 |
12 | static RispUnmatchedDelimiterReader *__RispUnmatchedDelimiterReader = nil;
13 | @implementation RispUnmatchedDelimiterReader
14 | - (id)init {
15 | static dispatch_once_t onceToken;
16 | if (__RispUnmatchedDelimiterReader)
17 | return __RispUnmatchedDelimiterReader;
18 |
19 | if (self = [super init]) {
20 | dispatch_once(&onceToken, ^{
21 | __RispUnmatchedDelimiterReader = self;
22 | });
23 | }
24 | return __RispUnmatchedDelimiterReader;
25 | }
26 |
27 | - (id)invoke:(RispReader *)reader object:(id)object {
28 | [NSException raise:RispRuntimeException format:@"Unmatched delimiter: %C", (UniChar)[object unsignedIntegerValue]];
29 | return nil;
30 | }
31 | @end
32 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispUnquoteReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispUnquoteReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispUnquoteReader : RispBaseReader
12 | - (id)invoke:(RispReader *)reader object:(id)object;
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispUnquoteReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispUnquoteReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispUnquoteReader.h"
10 |
11 | @implementation RispUnquoteReader
12 | - (id)invoke:(RispReader *)reader object:(id)object {
13 | RispPushBackReader *pushBackReader = [reader reader];
14 | UniChar ch = [pushBackReader read1];
15 | if (ch == 0) {
16 | [NSException raise:RispRuntimeException format:@"EOF while reading character"];
17 | }
18 | if (ch == '@') {
19 | id o = [reader readEofIsError:YES eofValue:nil isRecursive:YES];
20 | return [[RispList alloc] initWithObject:[RispSymbol UNQUOTESPLICING] base:[RispSequence sequence:o]];
21 | }
22 | [pushBackReader unread:ch];
23 | id o = [reader readEofIsError:YES eofValue:nil isRecursive:YES];
24 | return [[RispList alloc] initWithObject:[RispSymbol UNQUOTE] base:[RispSequence sequence:o]];
25 | }
26 | @end
27 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispVectorReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispVectorReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispVectorReader : RispBaseReader
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispVectorReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispVectorReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispVectorReader.h"
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation RispVectorReader
15 | - (id)invoke:(RispReader *)reader object:(id)object {
16 | return [[RispVector alloc] initWithArrayNoCopy:[[self reader:reader delimited:']' recursive:YES] array]];
17 | }
18 | @end
19 |
20 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispWrappingReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispWrappingReader.h
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispWrappingReader : RispBaseReader
12 | @property (strong, nonatomic, readonly) RispSymbol *symbol;
13 | - (id)initWithSymbol:(RispSymbol *)symbol;
14 | @end
15 |
--------------------------------------------------------------------------------
/Risp/Risp/Reader/RispWrappingReader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispWrappingReader.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispWrappingReader.h"
10 |
11 | @implementation RispWrappingReader
12 | - (id)initWithSymbol:(RispSymbol *)symbol {
13 | if (self = [super init]) {
14 | _symbol = symbol;
15 | }
16 | return self;
17 | }
18 |
19 | - (id)invoke:(RispReader *)reader object:(id)object {
20 | id o = [reader readEofIsError:YES eofValue:nil isRecursive:YES];
21 | return [[RispList alloc] initWithArray:[NSArray arrayWithObjects:_symbol, o, nil]];
22 | }
23 | @end
24 |
--------------------------------------------------------------------------------
/Risp/Risp/Risp+DEBUG.h:
--------------------------------------------------------------------------------
1 | //
2 | // Risp+DEBUG.h
3 | // Risp
4 | //
5 | // Created by closure on 5/26/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSObject (Debug)
12 | - (NSString *)rispLocationInfomation;
13 | @end
14 |
15 | @interface Risp : NSObject
16 |
17 | @end
18 |
19 | @interface Risp (Debug)
20 | + (NSString *)decriptionForExpression:(id )expression;
21 | + (void)show:(id)object;
22 | @end
23 |
24 | #if TARGET_OS_IPHONE
25 | @interface NSObject (className)
26 | - (NSString *)className;
27 | - (BOOL)isEqualTo:(id)object;
28 | @end
29 | #endif
--------------------------------------------------------------------------------
/Risp/Risp/Risp+DEBUG.m:
--------------------------------------------------------------------------------
1 | //
2 | // Risp+DEBUG.m
3 | // Risp
4 | //
5 | // Created by closure on 5/26/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "Risp+DEBUG.h"
10 |
11 | @implementation NSObject (Debug)
12 |
13 | - (NSString *)rispLocationInfomation {
14 | if ([self hasMeta]) {
15 | NSString *string = [[NSString alloc] initWithFormat:@"",
16 | [self file],
17 | [self start],
18 | [self end],
19 | [self lineNumber],
20 | [self columnNumber]];
21 | return string;
22 | }
23 | return @"";
24 | }
25 |
26 | @end
27 |
28 | @implementation Risp (Debug)
29 | + (NSString *)decriptionForExpression:(id )expression {
30 | return [expression description];
31 | }
32 |
33 | + (void)show:(id)object {
34 | NSLog(@"%@", object);
35 | return;
36 | }
37 | @end
38 |
39 | #if TARGET_OS_IPHONE
40 | @implementation NSObject (className)
41 |
42 | - (NSString *)className {
43 | return NSStringFromClass([self class]);
44 | }
45 |
46 | - (BOOL)isEqualTo:(id)object {
47 | if ([self isKindOfClass:[NSString class]] && [object isKindOfClass:[NSString class]]) {
48 | return [(NSString *)self compare:object options:0] == 0;
49 | } else if ([self isKindOfClass:[NSNumber class]] && [object isKindOfClass:[NSNumber class]]) {
50 | return [(NSNumber *)self compare:object];
51 | } else if ([self isKindOfClass:[NSDate class]] && [object isKindOfClass:[NSDate class]]) {
52 | return [(NSDate *)self compare:object];
53 | }
54 | return self == object;
55 | }
56 |
57 | @end
58 | #endif
--------------------------------------------------------------------------------
/Risp/Risp/Risp-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.retval.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSHumanReadableCopyright
26 | Copyright © 2014 closure. All rights reserved.
27 | NSPrincipalClass
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Risp/Risp/Risp-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #ifdef __OBJC__
8 | #if TARGET_OS_IPHONE
9 | #import
10 | #else
11 | #import
12 | #endif
13 | #import "RispSequenceProtocol.h"
14 | #import "Risp+DEBUG.h"
15 | #endif
16 |
--------------------------------------------------------------------------------
/Risp/Risp/Risp.m:
--------------------------------------------------------------------------------
1 | //
2 | // Risp.m
3 | // Risp
4 | //
5 | // Created by closure on 4/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Risp+DEBUG.h"
11 | #import "NSDecimalNumber+Math.h"
12 |
13 | @interface NSObject (String)
14 | - (NSString *)stringValue;
15 | @end
16 |
17 | @implementation NSObject (String)
18 |
19 | - (NSString *)stringValue {
20 | return [self description];
21 | }
22 |
23 | @end
24 |
25 | @implementation Risp
26 |
27 | + (void)load {
28 | RispReader *reader = [[RispReader alloc] initWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.retval.Risp"] pathForResource:@"init" ofType:@"risp"]];
29 | RispContext *context = [RispContext currentContext];
30 | id value = nil;
31 | NSMutableArray *values = [[NSMutableArray alloc] init];
32 | while (![reader isEnd]) {
33 | @autoreleasepool {
34 | @try {
35 | value = [reader readEofIsError:YES eofValue:nil isRecursive:YES];
36 | [[reader reader] skip];
37 | if (value == reader) {
38 | continue;
39 | }
40 | id expr = [RispCompiler compile:context form:value];
41 | id v = [expr eval];
42 | // id v = nil;
43 | NSLog(@"%@ -\n%@\n-> %@", value, [[[RispAbstractSyntaxTree alloc] initWithExpression:expr] description], v);
44 | [values addObject:v ? : [NSNull null]];
45 | }
46 | @catch (NSException *exception) {
47 | NSLog(@"exception: %@ - %@", value, exception);
48 | }
49 | }
50 | }
51 | }
52 |
53 | + (id)eval:(id)object {
54 | id expr = nil;
55 | if (![object conformsToProtocol:@protocol(RispExpression)]) {
56 | expr = [RispCompiler compile:[RispContext currentContext] form:object];
57 | }
58 | return [expr eval];
59 | }
60 |
61 | @end
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispCompiler.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispCompiler.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | typedef NS_ENUM(NSUInteger, RispCompilerStatus) {
14 | RispCompilerStatusREQ = 0,
15 | RispCompilerStatusREST = 1,
16 | RispCompilerStatusDONE = 2,
17 | };
18 |
19 | @interface RispCompiler : NSObject
20 | + (Class)targetIsClass:(id)target;
21 | - (id)initWithObject:(id)object;
22 |
23 | + (id)compile:(RispContext *)context form:(id)form;
24 | + (id)macroexpand:(id)form;
25 |
26 | + (id)eval:(id)rispForm;
27 | @end
28 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispContext.h
3 | // Risp
4 | //
5 | // Created by closure on 4/18/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 |
19 | typedef NS_ENUM(NSUInteger, RispContextStatus) {
20 | RispContextStatement = 0, // do not require value
21 | RispContextExpression = 1, // require value
22 | RispContextClosure = 2, // local binding
23 | RispContextEval = 3, // eval the expression
24 | };
25 |
26 | @interface RispContext : NSObject
27 | + (instancetype)mainContext;
28 | + (instancetype)defaultContext;
29 | + (instancetype)currentContext;
30 | + (void)setCurrentContext:(RispContext *)context;
31 |
32 | + (NSDictionary *)mergeScope:(RispLexicalScope *)scope withScope:(RispLexicalScope *)other;
33 |
34 | @property (nonatomic, assign) RispContextStatus status;
35 | - (RispLexicalScope *)currentScope;
36 | - (void)registerValue:(id)value forKey:(id)key;
37 |
38 | // special form api group
39 | - (BOOL)isSpecial:(id)key;
40 | - (id)specialForKey:(id)key;
41 | - (void)registerSpecialValue:(id)value forKey:(id)key;
42 |
43 | // keyword set
44 | - (RispKeywordExpression *)registerKeyword:(RispKeyword *)value;
45 | - (BOOL)keywordIsRegisted:(RispKeyword *)keyword;
46 | - (RispKeywordExpression *)keywordExpressionForKeyword:(RispKeyword *)value;
47 |
48 | - (id)isMacro:(id)key;
49 |
50 | - (RispLexicalScope *)mergeScope:(RispLexicalScope *)scope;
51 |
52 | - (id)pushScope;
53 | - (id)pushScope:(RispLexicalScope *)scope;
54 | - (id)pushScopeWithConfiguration:(NSDictionary *)info;
55 | - (id)pushScopeWithMergeScope:(RispLexicalScope *)scope;
56 | - (void)popScope;
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLLVM/RispCodeGeneratorContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispCodeGeneratorContext.h
3 | // Risp
4 | //
5 | // Created by closure on 6/1/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #if TARGET_OS_MAC
11 | #include "llvm-c/Core.h"
12 | @class RispContext;
13 | @interface RispCodeGeneratorContext : NSObject
14 | @property (nonatomic, strong, readonly) RispContext *rispContext;
15 | @property (nonatomic, assign, readonly) LLVMContextRef llvmContext;
16 | @property (nonatomic, assign, readonly) LLVMModuleRef mainModule;
17 |
18 | - (id)initWithRispContext:(RispContext *)rispContext llvmContext:(LLVMContextRef)llvmContext;
19 |
20 | - (LLVMModuleRef)currentModule;
21 | - (void)pushModule:(LLVMModuleRef)moduleToPush;
22 | - (void)popMoudle;
23 | @end
24 | #endif
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLLVM/RispCodeGeneratorContext.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispCodeGeneratorContext.m
3 | // Risp
4 | //
5 | // Created by closure on 6/1/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispCodeGeneratorContext.h"
10 |
11 | #import "_RispLLVMModule.h"
12 |
13 | @interface RispCodeGeneratorContext ()
14 | @property (nonatomic, strong, readonly) NSMutableArray *moduleStack; // RispLLVMModule include
15 | @end
16 |
17 | @implementation RispCodeGeneratorContext
18 |
19 | - (id)initWithRispContext:(RispContext *)rispContext llvmContext:(LLVMContextRef)llvmContext {
20 | if (self = [super init]) {
21 | _rispContext = rispContext;
22 | _llvmContext = llvmContext;
23 | _mainModule = LLVMModuleCreateWithNameInContext("main", _llvmContext);
24 | _moduleStack = [[NSMutableArray alloc] init];
25 | [self pushModule:_mainModule];
26 | }
27 | return self;
28 | }
29 |
30 | - (void)dealloc {
31 | _rispContext = nil;
32 | LLVMContextDispose(_llvmContext);
33 | }
34 |
35 | - (void)pushModule:(LLVMModuleRef)moduleToPush {
36 | [_moduleStack addObject:[_RispLLVMModule module:moduleToPush]];
37 | }
38 |
39 | - (void)popMoudle {
40 | [_moduleStack removeLastObject];
41 | }
42 |
43 | - (LLVMModuleRef)currentModule {
44 | return [[_moduleStack lastObject] module];
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLLVM/_RispLLVMModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // _RispLLVMModule.h
3 | // Risp
4 | //
5 | // Created by closure on 6/1/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #if TARGET_OS_MAC
11 | #include "llvm-c/Core.h"
12 | @interface _RispLLVMModule : NSObject
13 | @property (nonatomic, assign, readonly) LLVMModuleRef module;
14 | + (instancetype)module:(LLVMModuleRef)llvmModule;
15 | - (instancetype)initWithLLVMMoudle:(LLVMModuleRef)llvmModule;
16 | @end
17 | #endif
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLLVM/_RispLLVMModule.m:
--------------------------------------------------------------------------------
1 | //
2 | // _RispLLVMModule.m
3 | // Risp
4 | //
5 | // Created by closure on 6/1/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "_RispLLVMModule.h"
10 |
11 | @implementation _RispLLVMModule
12 | + (instancetype)module:(LLVMModuleRef)llvmModule {
13 | return [[_RispLLVMModule alloc] initWithLLVMMoudle:llvmModule];
14 | }
15 |
16 | - (instancetype)initWithLLVMMoudle:(LLVMModuleRef)llvmModule {
17 | if (self = [super init]) {
18 | _module = llvmModule;
19 | }
20 | return self;
21 | }
22 |
23 | - (void)dealloc {
24 | LLVMDisposeModule(_module);
25 | _module = nil;
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLLVM/__RispLLVMFoundation.h:
--------------------------------------------------------------------------------
1 | //
2 | // __RispLLVMFoundation.h
3 | // Risp
4 | //
5 | // Created by closure on 6/10/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface __RispLLVMFoundation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLocalBinding.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispLocalBinding.h
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | @class RispSymbol, NSTreeNode, RispBaseExpression;
11 | @interface RispLocalBinding : NSObject
12 | @property (nonatomic, strong, readonly) RispSymbol *sym;
13 | @property (nonatomic, strong, readonly) RispSymbol *tag;
14 | @property (nonatomic, strong) RispBaseExpression *expr;
15 | @property (nonatomic, strong, readonly) NSString *name;
16 | @property (nonatomic, assign, readonly) NSInteger idx;
17 | @property (nonatomic, assign, readonly) BOOL isArg;
18 | @property (nonatomic, strong) NSTreeNode *clearPathRoot;
19 | @property (nonatomic, assign) BOOL canBeCleared;
20 | @property (nonatomic, assign) BOOL recurMistmatch;
21 |
22 | - (id)initWithIndex:(NSInteger)index symbol:(RispSymbol *)sym tag:(RispSymbol *)tag init:(RispBaseExpression *)expr isArg:(BOOL)isArg pathNode:(NSTreeNode *)clearPathRoot;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispLocalBinding.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispLocalBinding.m
3 | // Risp
4 | //
5 | // Created by closure on 4/17/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @implementation RispLocalBinding
13 | - (id)initWithIndex:(NSInteger)index symbol:(RispSymbol *)sym tag:(RispSymbol *)tag init:(RispBaseExpression *)expr isArg:(BOOL)isArg pathNode:(NSTreeNode *)clearPathRoot {
14 | if (self = [super init]) {
15 | _idx = index;
16 | _sym = sym;
17 | _tag = tag;
18 | _expr = expr;
19 | _isArg = isArg;
20 | _clearPathRoot = clearPathRoot;
21 | _name = [_sym stringValue];
22 | }
23 | return self;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Risp/Risp/VM/RispRuntime.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispRuntime.h
3 | // Syrah
4 | //
5 | // Created by closure on 4/14/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | @interface RispRuntime : NSObject
15 | @property (strong, nonatomic, readonly) RispLexicalScope *rootScope;
16 | @property (assign, nonatomic, readonly, getter = isDeref) id defref;
17 |
18 | + (id)map:(id)object fn:(id (^)(id object))fn;
19 | + (void)apply:(id)object fn:(id (^)(id object))fn;
20 | + (id)reduce:(id)object fn:(id (^)(id coll, id object))fn;
21 | + (id)filter:(id)object pred:(id (^)(id object))pred;
22 | + (id)remove:(id)object pred:(id (^)(id object))pred;
23 |
24 | + (instancetype)baseEnvironment;
25 | + (NSRange)rangeForDefaultArugmentsNumber;
26 | + (NSRange)rangeForDefaultArugmentsNumberWithUnlimit;
27 | - (BOOL)registerSymbol:(RispSymbol *)symbol forObject:(id)object;
28 | @end
29 |
30 | FOUNDATION_EXPORT NSString * const RispRuntimeException;
31 | FOUNDATION_EXPORT NSString * const RispInvalidNumberFormatException;
32 | FOUNDATION_EXPORT NSString * const RispIllegalArgumentException;
33 |
--------------------------------------------------------------------------------
/Risp/Risp/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Risp/RispDotOperationCodeGen/RispDotOperationCodeGen-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #ifdef __OBJC__
8 | #import
9 | #endif
10 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBHotKey.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBHotKey.h
3 | // Protein
4 | //
5 | // Created by Quentin Carnicelli on Sat Aug 02 2003.
6 | // Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
7 | //
8 | // Contributors:
9 | // Andy Kim
10 |
11 | #import
12 | #import
13 | #import
14 |
15 | @interface RispKBHotKey : NSObject
16 | {
17 | NSString* mIdentifier;
18 | NSString* mName;
19 | RispKBKeyCombo* mKeyCombo;
20 | id mTarget;
21 | SEL mAction;
22 |
23 | NSUInteger mCarbonHotKeyID;
24 | EventHotKeyRef mCarbonEventHotKeyRef;
25 | }
26 |
27 | - (id)initWithIdentifier: (id)identifier keyCombo: (RispKBKeyCombo*)combo;
28 | - (id)init;
29 |
30 | - (void)setIdentifier: (id)ident;
31 | - (id)identifier;
32 |
33 | - (void)setName: (NSString*)name;
34 | - (NSString*)name;
35 |
36 | - (void)setKeyCombo: (RispKBKeyCombo*)combo;
37 | - (RispKBKeyCombo*)keyCombo;
38 |
39 | - (void)setTarget: (id)target;
40 | - (id)target;
41 | - (void)setAction: (SEL)action;
42 | - (SEL)action;
43 |
44 | - (NSUInteger)carbonHotKeyID;
45 | - (void)setCarbonHotKeyID: (NSUInteger)hotKeyID;
46 |
47 | - (EventHotKeyRef)carbonEventHotKeyRef;
48 | - (void)setCarbonEventHotKeyRef:(EventHotKeyRef)hotKeyRef;
49 |
50 | - (void)invoke;
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBHotKeyCenter.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBHotKeyCenter.h
3 | // Protein
4 | //
5 | // Created by Quentin Carnicelli on Sat Aug 02 2003.
6 | // Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
7 | //
8 | // Contributors:
9 | // Quentin D. Carnicelli
10 | // Finlay Dobbie
11 | // Vincent Pottier
12 | // Andy Kim
13 |
14 | #import
15 |
16 | @class RispKBHotKey;
17 |
18 | @interface RispKBHotKeyCenter : NSObject
19 | {
20 | NSMutableDictionary* mHotKeys; //Keys are carbon hot key IDs
21 | BOOL mEventHandlerInstalled;
22 | UInt32 mHotKeyCount; // Used to assign new hot key ID
23 | }
24 |
25 | + (RispKBHotKeyCenter *)sharedCenter;
26 |
27 | - (BOOL)registerHotKey: (RispKBHotKey*)hotKey;
28 | - (void)unregisterHotKey: (RispKBHotKey*)hotKey;
29 |
30 | - (NSArray*)allHotKeys;
31 | - (RispKBHotKey*)hotKeyWithIdentifier: (id)ident;
32 |
33 | - (void)sendEvent: (NSEvent*)event;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBKeyCodeTransformer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBKeyCodeTransformer.h
3 | // ShortcutRecorder
4 | //
5 | // Copyright 2006-2007 Contributors. All rights reserved.
6 | //
7 | // License: BSD
8 | //
9 | // Contributors:
10 | // David Dauer
11 | // Jesper
12 | // Jamie Kirkpatrick
13 |
14 | #import
15 |
16 | @interface RispKBKeyCodeTransformer : NSValueTransformer {} @end
17 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBKeyCodeTranslator.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBKeyCodeTranslator.h
3 | // Chercher
4 | //
5 | // Created by Finlay Dobbie on Sat Oct 11 2003.
6 | // Copyright (c) 2003 Cliché Software. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispKBKeyCodeTranslator : NSObject
12 | {
13 | TISInputSourceRef keyboardLayout;
14 | const UCKeyboardLayout *uchrData;
15 | UInt32 keyTranslateState;
16 | UInt32 deadKeyState;
17 | }
18 |
19 | + (id)currentTranslator;
20 |
21 | - (id)initWithKeyboardLayout:(TISInputSourceRef)aLayout;
22 | - (NSString *)translateKeyCode:(short)keyCode;
23 |
24 | - (TISInputSourceRef)keyboardLayout;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBKeyCombo.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBKeyCombo.h
3 | // Protein
4 | //
5 | // Created by Quentin Carnicelli on Sat Aug 02 2003.
6 | // Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RispKBKeyCombo : NSObject
12 | {
13 | NSInteger mKeyCode;
14 | NSUInteger mModifiers;
15 | }
16 |
17 | + (id)clearKeyCombo;
18 | + (id)keyComboWithKeyCode: (NSInteger)keyCode modifiers: (NSUInteger)modifiers;
19 | - (id)initWithKeyCode: (NSInteger)keyCode modifiers: (NSUInteger)modifiers;
20 |
21 | - (id)initWithPlistRepresentation: (id)plist;
22 | - (id)plistRepresentation;
23 |
24 | - (BOOL)isEqual: (RispKBKeyCombo*)combo;
25 |
26 | - (NSInteger)keyCode;
27 | - (NSUInteger)modifiers;
28 |
29 | - (BOOL)isClearCombo;
30 | - (BOOL)isValidHotKeyCombo;
31 |
32 | @end
33 |
34 |
35 | @interface RispKBKeyCombo (UserDisplayAdditions)
36 | - (NSString*)keyCodeString;
37 | - (NSUInteger)modifierMask;
38 | @end
39 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKBValidator.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKBValidator.h
3 | // ShortcutRecorder
4 | //
5 | // Copyright 2006-2007 Contributors. All rights reserved.
6 | //
7 | // License: BSD
8 | //
9 | // Contributors:
10 | // David Dauer
11 | // Jesper
12 | // Jamie Kirkpatrick
13 |
14 | #import
15 |
16 | @interface RispKBValidator : NSObject {
17 | id delegate;
18 | }
19 |
20 | - (id) initWithDelegate:(id)theDelegate;
21 |
22 | - (BOOL) isKeyCode:(NSInteger)keyCode andFlagsTaken:(NSUInteger)flags error:(NSError **)error;
23 | - (BOOL) isKeyCode:(NSInteger)keyCode andFlags:(NSUInteger)flags takenInMenu:(NSMenu *)menu error:(NSError **)error;
24 |
25 | - (id) delegate;
26 | - (void) setDelegate: (id) theDelegate;
27 |
28 | @end
29 |
30 | #pragma mark -
31 |
32 | @interface NSObject( RispKBValidation )
33 | - (BOOL) shortcutValidator:(RispKBValidator *)validator isKeyCode:(NSInteger)keyCode andFlagsTaken:(NSUInteger)flags reason:(NSString **)aReason;
34 | @end
35 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKeyboardBinding-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.retval.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSHumanReadableCopyright
26 | Copyright © 2014 closure. All rights reserved.
27 | NSPrincipalClass
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKeyboardBinding-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #ifdef __OBJC__
8 | #import
9 | #endif
10 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKeyboardBinding.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeyboardBinding.h
3 | // RispKeyboardBinding
4 | //
5 | // Created by closure on 4/16/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import
19 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/RispKeyboardBinding.m:
--------------------------------------------------------------------------------
1 | //
2 | // RispKeyboardBinding.m
3 | // RispKeyboardBinding
4 | //
5 | // Created by closure on 4/16/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import "RispKeyboardBinding.h"
10 |
--------------------------------------------------------------------------------
/Risp/RispKeyboardBinding/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Risp/RispMobile/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.retval.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Risp/RispMobile/RispMobile.h:
--------------------------------------------------------------------------------
1 | //
2 | // RispMobile.h
3 | // RispMobile
4 | //
5 | // Created by closure on 7/15/14.
6 | // Copyright (c) 2014 closure. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for RispMobile.
12 | FOUNDATION_EXPORT double RispMobileVersionNumber;
13 |
14 | //! Project version string for RispMobile.
15 | FOUNDATION_EXPORT const unsigned char RispMobileVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Risp/RispReader/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/RispReader/1.png
--------------------------------------------------------------------------------
/Risp/RispReader/Media.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "size" : "512x512",
45 | "idiom" : "mac",
46 | "filename" : "SDK.png",
47 | "scale" : "1x"
48 | },
49 | {
50 | "idiom" : "mac",
51 | "size" : "512x512",
52 | "scale" : "2x"
53 | }
54 | ],
55 | "info" : {
56 | "version" : 1,
57 | "author" : "xcode"
58 | }
59 | }
--------------------------------------------------------------------------------
/Risp/RispReader/Media.xcassets/AppIcon.appiconset/SDK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/RispReader/Media.xcassets/AppIcon.appiconset/SDK.png
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationBannerBackgroundView.h:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationBannerBackgroundView.h
3 | //
4 | // Created by Frank Gregor on 17.05.13.
5 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
6 | //
7 |
8 | /*
9 | The MIT License (MIT)
10 | Copyright © 2013 Frank Gregor,
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the “Software”), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 |
19 | The above copyright notice and this permission notice shall be included in
20 | all copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 | THE SOFTWARE.
29 | */
30 |
31 | #import
32 |
33 | @interface ASUserNotificationBannerBackgroundView : NSView
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationBannerButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationBannerButton.h
3 | //
4 | // Created by Frank Gregor on 20.05.13.
5 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
6 | //
7 |
8 | /*
9 | The MIT License (MIT)
10 | Copyright © 2013 Frank Gregor,
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the “Software”), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 |
19 | The above copyright notice and this permission notice shall be included in
20 | all copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 | THE SOFTWARE.
29 | */
30 |
31 | #import
32 |
33 | @interface ASUserNotificationBannerButton : NSButton
34 |
35 | - (instancetype)initWithTitle:(NSString *)theTitle actionHandler:(void (^)(void))actionHandler;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationBannerButtonCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationBannerButtonCell.h
3 | //
4 | // Created by Frank Gregor on 20.05.13.
5 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
6 | //
7 |
8 | /*
9 | The MIT License (MIT)
10 | Copyright © 2013 Frank Gregor,
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the “Software”), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 |
19 | The above copyright notice and this permission notice shall be included in
20 | all copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 | THE SOFTWARE.
29 | */
30 |
31 | #import
32 |
33 | @interface ASUserNotificationBannerButtonCell : NSButtonCell
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationBannerController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationBannerController.h
3 | //
4 | // Created by Frank Gregor on 16.05.13.
5 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
6 | //
7 |
8 | /*
9 | The MIT License (MIT)
10 | Copyright © 2013 Frank Gregor,
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the “Software”), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 |
19 | The above copyright notice and this permission notice shall be included in
20 | all copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 | THE SOFTWARE.
29 | */
30 |
31 | #import
32 | #import "ASUserNotification.h"
33 |
34 | typedef void (^ASUserNotificationBannerActivationHandler)(ASUserNotificationActivationType);
35 |
36 | @interface ASUserNotificationBannerController : NSWindowController
37 | @property (strong) id delegate;
38 |
39 | - (instancetype)initWithNotification:(ASUserNotification *)theNotification
40 | delegate:(id)theDelegate
41 | usingActivationHandler:(ASUserNotificationBannerActivationHandler)activationHandler;
42 | - (void)presentBanner;
43 | - (void)presentBannerDismissAfter:(NSTimeInterval)dismissTimerInterval;
44 | - (void)dismissBanner;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationCenterDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationCenterDelegate.h
3 | // ASUserNotification Example
4 | //
5 | // Created by Frank Gregor on 17.05.13.
6 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class ASUserNotificationCenter, ASUserNotification;
12 |
13 | @protocol ASUserNotificationCenterDelegate
14 | @optional
15 |
16 | /**
17 | Sent to the delegate when the user notification center has decided not to present your notification.
18 |
19 | @param center The user notification center.
20 | @param notification The user notification object.
21 |
22 | @return notification should be displayed regardless; NO otherwise.
23 | */
24 | - (BOOL)userNotificationCenter:(ASUserNotificationCenter *)center shouldPresentNotification:(ASUserNotification *)notification;
25 |
26 | /**
27 | Sent to the delegate when a user clicks on a user notification presented by the user notification center.
28 |
29 | @param center The user notification center.
30 | @param notification The user notification object.
31 | */
32 | - (void)userNotificationCenter:(ASUserNotificationCenter *)center didActivateNotification:(ASUserNotification *)notification;
33 |
34 | /**
35 | Sent to the delegate when a notification delivery date has arrived.
36 |
37 | @param center The user notification center.
38 | @param notification The user notification object.
39 |
40 | This method is always called, regardless of your application state and even if you deliver the user notification yourself using deliverNotification:.
41 |
42 | This delegate method is invoked before the userNotificationCenter:shouldPresentNotification: delegate method.
43 | */
44 | - (void)userNotificationCenter:(ASUserNotificationCenter *)center didDeliverNotification:(ASUserNotification *)notification;
45 | @end
46 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationDefaultSound.aif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/RispReader/Model/ASUserNotification/ASUserNotificationDefaultSound.aif
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/ASUserNotificationFeature.m:
--------------------------------------------------------------------------------
1 | //
2 | // ASUserNotificationFeature.m
3 | // ASUserNotification Example
4 | //
5 | // Created by Frank Gregor on 26.05.13.
6 | // Copyright (c) 2013 cocoa:naut. All rights reserved.
7 | //
8 |
9 | #import "ASUserNotificationFeature.h"
10 |
11 | @implementation ASUserNotificationFeature
12 |
13 | - (id)init
14 | {
15 | self = [super init];
16 | if (self) {
17 | _dismissDelayTime = 5;
18 | _lineBreakMode = NSLineBreakByTruncatingTail;
19 | _bannerImage = [NSApp applicationIconImage];
20 | }
21 | return self;
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/Risp/RispReader/Model/ASUserNotification/AppledocSettings.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |