├── .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 | 4 | 5 | --project-name 6 | CNUserNotification 7 | --project-company 8 | cocoa:naut 9 | --project-version 10 | 1.0 11 | --company-id 12 | com.cocoanaut 13 | --ignore 14 | 15 | *.m 16 | CNAppDelegate.* 17 | 18 | --docset-platform-family 19 | osx 20 | --create-docset 21 | 22 | --install-docset 23 | 24 | --create-html 25 | 26 | --index-desc 27 | ../DocIndex.md 28 | --output 29 | ../Documentation/ 30 | include 31 | ../Documentation/Images 32 | --warn-empty-description 33 | 34 | --warn-missing-arg 35 | 36 | --warn-unknown-directive 37 | 38 | --logformat 39 | xcode 40 | --exit-threshold 41 | 2 42 | --repeat-first-par 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Risp/RispReader/Model/RispReaderEvalCore/RispReaderEvalCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispReaderEvalCore.h 3 | // Risp 4 | // 5 | // Created by closure on 4/24/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RispREPLAlphaWindowController; 12 | @interface RispReaderEvalCore : NSObject 13 | + (NSArray *)evalCurrentLine:(NSString *)sender; 14 | + (NSArray *)evalCurrentLine:(NSString *)sender expressions:(NSArray **)expressions; 15 | + (void)renderTextView:(NSTextView *)textView resultValue:(id)v insertNewLine:(BOOL)insertNewLine block:(void (^)(id v))defaultRender; 16 | 17 | + (void)renderTextFieldCell:(NSTextFieldCell *)cell resultValue:(id)v insertNewLine:(BOOL)insertNewLine block:(void (^)(id v))defaultRender; 18 | 19 | + (NSUInteger)lineNumberOfTextView:(NSTextView *)textView; 20 | + (NSArray *)textView:(NSTextView *)textView processLinesWithHandler:(id (^)(NSTextView *text, NSRange range))handler; 21 | + (NSRange)rangeOfCurrentLine:(NSTextView *)textView; 22 | 23 | + (void)removeAttachmentsFromTextView:(NSTextView *)textView; 24 | @end 25 | -------------------------------------------------------------------------------- /Risp/RispReader/Model/RispRender/RispRender.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRender.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 | #import 11 | 12 | @interface NSObject (Render) 13 | - (NSAttributedString *)render; 14 | @end 15 | 16 | @interface RispSequence (Render) 17 | - (NSAttributedString *)render; 18 | @end 19 | 20 | @interface RispList (Render) 21 | - (NSAttributedString *)render; 22 | @end 23 | 24 | @interface RispVector (Render) 25 | - (NSAttributedString *)render; 26 | @end 27 | 28 | @interface RispKeyword (Render) 29 | - (NSAttributedString *)render; 30 | @end 31 | 32 | @interface RispMap (Render) 33 | - (NSAttributedString *)render; 34 | @end 35 | 36 | @interface RispLazySequence (Render) 37 | - (NSAttributedString *)render; 38 | @end 39 | 40 | @interface RispSymbol (Render) 41 | - (NSAttributedString *)render; 42 | @end 43 | 44 | @interface NSDecimalNumber (Render) 45 | - (NSAttributedString *)render; 46 | @end 47 | 48 | @interface NSString (Render) 49 | - (NSAttributedString *)render; 50 | @end 51 | 52 | @interface NSImage (Render) 53 | - (NSAttributedString *)render; 54 | @end 55 | 56 | @interface NSFileWrapper (Render) 57 | - (NSAttributedString *)render; 58 | @end 59 | 60 | @interface NSArray (Render) 61 | - (NSAttributedString *)render; 62 | @end 63 | -------------------------------------------------------------------------------- /Risp/RispReader/RispAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispAppDelegate.h 3 | // RispReader 4 | // 5 | // Created by closure on 4/15/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RispAppDelegate : NSObject 12 | 13 | @property (assign) IBOutlet NSWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Risp/RispReader/RispReader-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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | ${MACOSX_DEPLOYMENT_TARGET} 25 | NSHumanReadableCopyright 26 | Copyright © 2014 closure. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Risp/RispReader/RispReader-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/RispReader/RispRender/RispRender.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRender.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 | #import 11 | 12 | @interface NSObject (Render) 13 | - (NSAttributedString *)render; 14 | @end 15 | 16 | @interface RispSequence (Render) 17 | - (NSAttributedString *)render; 18 | @end 19 | 20 | @interface RispList (Render) 21 | - (NSAttributedString *)render; 22 | @end 23 | 24 | @interface RispVector (Render) 25 | - (NSAttributedString *)render; 26 | @end 27 | 28 | @interface RispKeyword (Render) 29 | - (NSAttributedString *)render; 30 | @end 31 | 32 | @interface RispMap (Render) 33 | - (NSAttributedString *)render; 34 | @end 35 | 36 | @interface RispLazySequence (Render) 37 | - (NSAttributedString *)render; 38 | @end 39 | 40 | @interface RispSymbol (Render) 41 | - (NSAttributedString *)render; 42 | @end 43 | 44 | @interface NSDecimalNumber (Render) 45 | - (NSAttributedString *)render; 46 | @end 47 | 48 | @interface NSString (Render) 49 | - (NSAttributedString *)render; 50 | @end 51 | 52 | @interface NSImage (Render) 53 | - (NSAttributedString *)render; 54 | @end 55 | 56 | @interface NSFileWrapper (Render) 57 | - (NSAttributedString *)render; 58 | @end 59 | 60 | @interface NSArray (Render) 61 | - (NSAttributedString *)render; 62 | @end 63 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/LineNumberView/MarkerLineNumberView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MarkerTextView.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 10/4/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | #import "NoodleLineNumberView.h" 32 | 33 | @interface MarkerLineNumberView : NoodleLineNumberView 34 | { 35 | NSImage *markerImage; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/LineNumberView/NoodleLineNumberMarker.h: -------------------------------------------------------------------------------- 1 | // 2 | // NoodleLineNumberMarker.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 9/30/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | 33 | @interface NoodleLineNumberMarker : NSRulerMarker 34 | { 35 | unsigned lineNumber; 36 | } 37 | 38 | - (id)initWithRulerView:(NSRulerView *)aRulerView lineNumber:(float)line image:(NSImage *)anImage imageOrigin:(NSPoint)imageOrigin; 39 | 40 | - (void)setLineNumber:(unsigned)line; 41 | - (unsigned)lineNumber; 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/LineNumberView/NoodleLineNumberView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NoodleLineNumberView.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 9/28/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @class NoodleLineNumberMarker; 33 | 34 | @interface NoodleLineNumberView : NSRulerView 35 | { 36 | // Array of character indices for the beginning of each line 37 | NSMutableArray *lineIndices; 38 | // Maps line numbers to markers 39 | NSMutableDictionary *linesToMarkers; 40 | } 41 | @property (nonatomic, strong) NSFont *font; 42 | @property (nonatomic, strong) NSColor *color; 43 | @property (nonatomic, strong) NSColor *alternateTextColor; 44 | @property (nonatomic, strong) NSColor *textColor; 45 | @property (nonatomic, strong) NSColor *backgroundColor; 46 | - (id)initWithScrollView:(NSScrollView *)aScrollView; 47 | 48 | - (NSUInteger)lineNumberForLocation:(CGFloat)location; 49 | - (NoodleLineNumberMarker *)markerAtLine:(NSUInteger)line; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RMBlurredView/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Raffael Hannemann All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | - Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Risp/RispReader/Views/RMBlurredView/README.md: -------------------------------------------------------------------------------- 1 | # RMBlurredView 2 | 3 | This subclass of NSView can be used to get an iOS 7 like blurred background to mimic a frosted glass effect — on OS X! Check out the corresponding article on [Cocoanetics](http://www.cocoanetics.com/2013/10/blurring-views-on-mac/). 4 | 5 | **NOTE:** The parent view of the RMBlurredView must be layer-backed to see the effect. 6 | 7 | ![RMBlurredView, a NSView with blurred background](http://www.cocoanetics.com/files/Chat-Heads-Preview.jpg "Custom NSView subclass with blurred background") 8 | 9 | ([Chat Heads](http://www.raffael.me/chatheads) with blurred title and bottom bar) 10 | 11 | The view can be easily customized to your needs: 12 | 13 | * **blurRadius (float)** A float indicating the strength of the blur effect. This will be directly passed as input parameter for the Gaussian blur CIFilter. Default: 20.0. 14 | 15 | * **saturationFactor (float)** A float value indicating the strength of the increased saturation effect. The Control Center for example uses increased saturated colors to get more vibrant colors shining through the view. Default: 2.0. 16 | 17 | * **tintColor (NSColor)** A NSColor used a the background color for the view. Default: 70% White. 18 | 19 | **NOTE:** Can be used with [RMSecondaryScroller](https://github.com/raffael/RMSecondaryScroller) to get a customizable NSScroller for NSScrollViews. 20 | 21 | ## Usage 22 | 23 | Usage should be clear once you see the annotated header file. Check out the [RMBlurredViewExample](https://github.com/raffael/RMBlurredViewExample) project. 24 | 25 | ## Contact 26 | 27 | * Raffael Hannemann 28 | * [@raffael_me](http://www.twitter.com/raffael_me/) 29 | * http://www.raffael.me/ 30 | 31 | ## License 32 | 33 | Copyright (c) 2013 Raffael Hannemann 34 | Under BSD License. 35 | 36 | ## Want more? 37 | 38 | Follow [@raffael_me](http://www.twitter.com/raffael_me/) for similar releases. 39 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RMBlurredView/RMBlurredView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RMBlurredView.h 3 | // 4 | // Created by Raffael Hannemann on 08.10.13. 5 | // Copyright (c) 2013 Raffael Hannemann. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | // Make sure to import QuartzCore and add it to your Linked Libraries of your target 11 | #import 12 | 13 | @interface RMBlurredView : NSView { 14 | // Keep a reference to the filters for later modification 15 | CIFilter *_blurFilter, *_saturationFilter; 16 | CALayer *_hostedLayer; 17 | } 18 | 19 | /** The layer will be tinted using the tint color. By default it is a 70% White Color */ 20 | @property (strong,nonatomic) NSColor *tintColor; 21 | 22 | /** To get more vibrant colors, a filter to increase the saturation of the colors can be applied. The default value is 2.5. */ 23 | @property (assign,nonatomic) float saturationFactor; 24 | 25 | /** The blur radius defines the strength of the Gaussian Blur filter. The default value is 20.0. */ 26 | @property (assign,nonatomic) float blurRadius; 27 | 28 | /** Use the following property names in the User Defined Runtime Attributes in Interface Builder to set up your RMBlurredView on the fly. Note: The color can be set up, too, using 'tintColor'. */ 29 | @property (strong,nonatomic) NSNumber *saturationFactorNumber; 30 | @property (strong,nonatomic) NSNumber *blurRadiusNumber; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/MDBlackTransparentView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MDBlackTransparentView.h 3 | // Borderless Window 4 | // 5 | // Created by Mark Douma on 12/15/2010. 6 | // Copyright 2010 Mark Douma LLC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface MDBlackTransparentView : NSView { 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/MDBlackTransparentView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MDBlackTransparentView.m 3 | // Borderless Window 4 | // 5 | // Created by Mark Douma on 12/15/2010. 6 | // Copyright 2010 Mark Douma LLC. All rights reserved. 7 | // 8 | 9 | #import "MDBlackTransparentView.h" 10 | 11 | 12 | @implementation MDBlackTransparentView 13 | 14 | 15 | - (id)initWithFrame:(NSRect)frame { 16 | if (self = [super initWithFrame:frame]) { 17 | 18 | } 19 | return self; 20 | } 21 | 22 | - (void)drawRect:(NSRect)frame { 23 | NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:frame xRadius:6.0 yRadius:6.0]; 24 | [[NSColor blackColor] set]; 25 | [path fill]; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/MDBorderlessWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // MDBorderlessWindow.h 3 | // Borderless Window 4 | // 5 | // Created by Mark Douma on 6/19/2010. 6 | // Copyright 2010 Mark Douma LLC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface MDBorderlessWindow : NSWindow { 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/MDBorderlessWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // MDBorderlessWindow.m 3 | // Borderless Window 4 | // 5 | // Created by Mark Douma on 6/19/2010. 6 | // Copyright 2010 Mark Douma LLC. All rights reserved. 7 | // 8 | 9 | #import "MDBorderlessWindow.h" 10 | 11 | 12 | @implementation MDBorderlessWindow 13 | 14 | - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation { 15 | 16 | if (self = [super initWithContentRect:contentRect 17 | styleMask:NSBorderlessWindowMask 18 | backing:NSBackingStoreBuffered defer:deferCreation]) { 19 | [self setAlphaValue:0.75]; 20 | [self setOpaque:NO]; 21 | [self setExcludedFromWindowsMenu:NO]; 22 | [self setBackgroundColor:[NSColor clearColor]]; 23 | [self setLevel:NSFloatingWindowLevel]; 24 | } 25 | return self; 26 | } 27 | 28 | 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/RispHUDWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispHUDWindowController.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 | #import "MDBorderlessWindow.h" 12 | #import "RispTextFieldVCenteredCell.h" 13 | 14 | @interface RispHUDWindowController : NSWindowController 15 | @property (strong) IBOutlet MDBorderlessWindow *hudWindow; 16 | @property (weak) IBOutlet RispTextFieldVCenteredCell *contentCell; 17 | @property (weak) IBOutlet NSTextField *content; 18 | @property (unsafe_unretained) IBOutlet NSTextView *textView; 19 | 20 | - (void)setValue:(id)value; 21 | @end 22 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/RispTextFieldVCenteredCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispTextFieldVCenteredCell.h 3 | // RView 4 | // 5 | // Created by closure on 5/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RispTextFieldVCenteredCell : NSTextFieldCell 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/RispTextFieldVCenteredCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispTextFieldVCenteredCell.m 3 | // RView 4 | // 5 | // Created by closure on 5/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import "RispTextFieldVCenteredCell.h" 10 | 11 | @implementation RispTextFieldVCenteredCell 12 | -(void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 13 | NSAttributedString *attrString = self.attributedStringValue; 14 | 15 | /* if your values can be attributed strings, make them white when selected */ 16 | if (self.isHighlighted && self.backgroundStyle==NSBackgroundStyleDark) { 17 | NSMutableAttributedString *whiteString = attrString.mutableCopy; 18 | [whiteString addAttribute: NSForegroundColorAttributeName 19 | value: [NSColor whiteColor] 20 | range: NSMakeRange(0, whiteString.length) ]; 21 | attrString = whiteString; 22 | } 23 | 24 | [attrString drawWithRect: [self titleRectForBounds:cellFrame] 25 | options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin]; 26 | } 27 | 28 | - (NSRect)titleRectForBounds:(NSRect)theRect { 29 | /* get the standard text content rectangle */ 30 | NSRect titleFrame = [super titleRectForBounds:theRect]; 31 | 32 | /* find out how big the rendered text will be */ 33 | NSAttributedString *attrString = self.attributedStringValue; 34 | NSRect textRect = [attrString boundingRectWithSize: titleFrame.size 35 | options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin ]; 36 | 37 | /* If the height of the rendered text is less then the available height, 38 | * we modify the titleRect to center the text vertically */ 39 | if (textRect.size.height < titleFrame.size.height) { 40 | titleFrame.origin.y = theRect.origin.y + (theRect.size.height - textRect.size.height) / 2.0; 41 | titleFrame.size.height = textRect.size.height; 42 | } 43 | return titleFrame; 44 | } 45 | @end 46 | -------------------------------------------------------------------------------- /Risp/RispReader/Views/RispHUD/TSTTextGrowth.h: -------------------------------------------------------------------------------- 1 | // 2 | // TSTTextGrowth.h 3 | // autoGrowingExample 4 | // 5 | // Created by Scott O'Brien on 1/01/13. 6 | // Copyright (c) 2013 Scott O'Brien. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TSTTextGrowth : NSTextField 12 | 13 | - (NSSize)intrinsicContentSize; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispREPLAlphaWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispREPLAlphaWindowController.h 3 | // Risp 4 | // 5 | // Created by closure on 4/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class RispRenderFoundation; 13 | @interface RispREPLAlphaWindowController : NSWindowController 14 | 15 | @property (weak) IBOutlet NSView *editorView; 16 | @property (strong) IBOutlet RispRenderFoundation *renderCore; 17 | @property (nonatomic, strong) NSTextView *inputTextView; 18 | @property (nonatomic, strong) NSScrollView *scrollView; 19 | 20 | @property (unsafe_unretained) IBOutlet NSTextView *outputTextView; 21 | 22 | @end 23 | 24 | FOUNDATION_EXPORT NSString * RispREPLAlphaWindowWillCloseNotification; 25 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispREPLAlphaWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispREPLAlphaWindowController.m 3 | // Risp 4 | // 5 | // Created by closure on 4/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import "RispREPLAlphaWindowController.h" 10 | #import 11 | NSString * RispREPLAlphaWindowWillCloseNotification = @"RispREPLAlphaWindowWillCloseNotification"; 12 | @interface RispREPLAlphaWindowController () 13 | @end 14 | 15 | @implementation RispREPLAlphaWindowController 16 | 17 | - (id)initWithWindow:(NSWindow *)window 18 | { 19 | self = [super initWithWindow:window]; 20 | if (self) { 21 | // Initialization code here. 22 | } 23 | return self; 24 | } 25 | 26 | - (void)awakeFromNib { 27 | [super awakeFromNib]; 28 | // [_renderCore setSyntaxColoured:YES]; 29 | // [_renderCore setObject:@YES forKey:ro_MGSFOSyntaxColouring]; 30 | [_renderCore setObject:self forKey:RispRenderFoundationFODelegate]; 31 | [_renderCore embedInView:_editorView]; 32 | [_renderCore setObject:@"Risp" forKey:@"syntaxDefinition"]; 33 | _scrollView = [_renderCore objectForKey:ro_MGSFOScrollView]; 34 | _inputTextView = [_renderCore objectForKey:ro_MGSFOTextView]; 35 | [[self window] setRepresentedFilename:@"RispReader"]; 36 | [[[self window] standardWindowButton:NSWindowDocumentIconButton] setImage:[NSApp applicationIconImage]]; 37 | } 38 | 39 | - (void)windowDidLoad 40 | { 41 | [super windowDidLoad]; 42 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 43 | } 44 | 45 | - (void)windowWillClose:(NSNotification *)notification { 46 | [[NSNotificationCenter defaultCenter] postNotificationName:RispREPLAlphaWindowWillCloseNotification object:nil userInfo:nil]; 47 | } 48 | @end 49 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispRenderWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderWindowController.h 3 | // Risp 4 | // 5 | // Created by closure on 4/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface RispRenderWindowController : NSWindowController 12 | @property (weak) IBOutlet RispIDEView *editorView; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispRenderWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderWindowController.m 3 | // Risp 4 | // 5 | // Created by closure on 4/28/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import "RispRenderWindowController.h" 10 | 11 | @interface RispRenderWindowController () 12 | 13 | @end 14 | 15 | @implementation RispRenderWindowController 16 | 17 | - (id)initWithWindow:(NSWindow *)window 18 | { 19 | self = [super initWithWindow:window]; 20 | if (self) { 21 | // Initialization code here. 22 | } 23 | return self; 24 | } 25 | 26 | - (void)awakeFromNib { 27 | [super awakeFromNib]; 28 | [_editorView setShowInvisibles:NO]; 29 | [_editorView setMode:RispIDEViewModeClojure]; 30 | [_editorView setTheme:RispIDEViewThemeXcode]; 31 | [_editorView setShowPrintMargin:NO]; 32 | } 33 | 34 | - (void)windowDidLoad 35 | { 36 | [super windowDidLoad]; 37 | 38 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispWindowBlurer.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispWindowBlurer.h 3 | // Risp 4 | // 5 | // Created by closure on 4/26/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RispWindowBlurer : NSObject 12 | + (void)enableBlurForWindow:(NSWindow *)window; 13 | @end 14 | -------------------------------------------------------------------------------- /Risp/RispReader/WindowControllers/RispWindowBlurer.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispWindowBlurer.m 3 | // Risp 4 | // 5 | // Created by closure on 4/26/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import "RispWindowBlurer.h" 10 | 11 | @implementation RispWindowBlurer 12 | typedef void * CGSConnectionID; 13 | typedef void * CGSConnection; 14 | typedef void * CGSWindowID; 15 | extern OSStatus CGSNewConnection(const void **attributes, CGSConnection * id); 16 | typedef void *CGSWindowFilterRef; 17 | extern CGError CGSNewCIFilterByName(CGSConnection cid, CFStringRef filterName, CGSWindowFilterRef *outFilter); 18 | extern CGError CGSAddWindowFilter(CGSConnection cid, CGSWindowID wid, CGSWindowFilterRef filter, int flags); 19 | extern CGError CGSSetCIFilterValuesFromDictionary(CGSConnection cid, CGSWindowFilterRef filter, CFDictionaryRef filterValues); 20 | 21 | + (void)enableBlurForWindow:(NSWindow *)window 22 | { 23 | 24 | CGSConnectionID _myConnection; 25 | CGSWindowFilterRef __compositingFilter; 26 | 27 | int __compositingType = 1; // Apply filter to contents underneath the window, then draw window normally on top 28 | 29 | /* Make a new connection to CoreGraphics, alternatively you could use the main connection*/ 30 | 31 | CGSNewConnection(NULL , &_myConnection); 32 | 33 | /* The following creates a new CoreImage filter, then sets its options with a dictionary of values*/ 34 | 35 | CGSNewCIFilterByName (_myConnection, (CFStringRef)@"CIGaussianBlur", &__compositingFilter); 36 | NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:20.0] forKey:@"inputRadius"]; 37 | CGSSetCIFilterValuesFromDictionary(_myConnection, __compositingFilter, (__bridge CFDictionaryRef)optionsDict); 38 | 39 | /* Now just switch on the filter for the window */ 40 | 41 | CGSAddWindowFilter(_myConnection, (CGSWindowID)[window windowNumber], __compositingFilter, __compositingType ); 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /Risp/RispReader/Windows/RispAutoHideWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispAutoHideWindow.h 3 | // Risp 4 | // 5 | // Created by closure on 4/25/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | @interface NSTrackingArea (updateRect) 11 | - (void)_updateRect:(NSRect)range; 12 | @end 13 | 14 | @interface RispAutoHideWindow : NSWindow 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispReader/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Risp/RispReader/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Risp/RispReader/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RispReader 4 | // 5 | // Created by closure on 4/15/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) 12 | { 13 | return NSApplicationMain(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /Risp/RispReader/穹.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/RispReader/穹.jpg -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/MarkerLineNumberView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MarkerTextView.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 10/4/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | #import "NoodleLineNumberView.h" 32 | 33 | @interface MarkerLineNumberView : NoodleLineNumberView 34 | { 35 | NSImage *markerImage; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/NSScanner+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 12/08/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSScanner (Fragaria) 13 | - (void)RispRenderFoundation_setScanLocation:(NSUInteger)idx; 14 | @end 15 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/NSScanner+Fragaria.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+Fragaria.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 12/08/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import "NSScanner+Fragaria.h" 10 | 11 | 12 | @implementation NSScanner (Fragaria) 13 | 14 | /* 15 | 16 | RispRenderFoundation_setScanLocation: 17 | 18 | */ 19 | - (void)RispRenderFoundation_setScanLocation:(NSUInteger)idx 20 | { 21 | /* 22 | 23 | NSScanner raises if the index is beyond the end of the string. 24 | 25 | */ 26 | NSUInteger maxIndex = [[self string] length]; 27 | if (idx > maxIndex) { 28 | NSLog(@"Invalid scan location %lu > max of %lu", (long)idx, (long)maxIndex); 29 | idx = maxIndex; 30 | } 31 | 32 | [self setScanLocation:idx]; 33 | } 34 | @end 35 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/NoodleLineNumberMarker.h: -------------------------------------------------------------------------------- 1 | // 2 | // NoodleLineNumberMarker.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 9/30/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | 33 | @interface NoodleLineNumberMarker : NSRulerMarker 34 | { 35 | unsigned lineNumber; 36 | } 37 | 38 | - (id)initWithRulerView:(NSRulerView *)aRulerView lineNumber:(float)line image:(NSImage *)anImage imageOrigin:(NSPoint)imageOrigin; 39 | 40 | - (void)setLineNumber:(unsigned)line; 41 | - (unsigned)lineNumber; 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/NoodleLineNumberView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NoodleLineNumberView.h 3 | // Line View Test 4 | // 5 | // Created by Paul Kim on 9/28/08. 6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @class NoodleLineNumberMarker; 33 | 34 | @interface NoodleLineNumberView : NSRulerView 35 | { 36 | // Array of character indices for the beginning of each line 37 | NSMutableArray *lineIndices; 38 | // Maps line numbers to markers 39 | NSMutableDictionary *linesToMarkers; 40 | } 41 | @property (nonatomic, strong) NSFont *font; 42 | @property (nonatomic, strong) NSColor *color; 43 | @property (nonatomic, strong) NSColor *alternateTextColor; 44 | @property (nonatomic, strong) NSColor *textColor; 45 | @property (nonatomic, strong) NSColor *backgroundColor; 46 | - (id)initWithScrollView:(NSScrollView *)aScrollView; 47 | 48 | - (NSUInteger)lineNumberForLocation:(CGFloat)location; 49 | - (NoodleLineNumberMarker *)markerAtLine:(NSUInteger)line; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Preferences.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispFontTransformer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fraise version 3.7 - Based on Smultron by Peter Borg 3 | Written by Jean-François Moy - jeanfrancois.moy@gmail.com 4 | Find the latest version at http://github.com/jfmoy/Fraise 5 | 6 | Copyright 2010 Jean-François Moy 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #import 16 | 17 | 18 | @interface RispFontTransformer : NSValueTransformer { 19 | 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispFontTransformer.m: -------------------------------------------------------------------------------- 1 | /* 2 | Fraise version 3.7 - Based on Smultron by Peter Borg 3 | Written by Jean-François Moy - jeanfrancois.moy@gmail.com 4 | Find the latest version at http://github.com/jfmoy/Fraise 5 | 6 | Copyright 2010 Jean-François Moy 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #import "RispFontTransformer.h" 16 | 17 | @implementation RispFontTransformer 18 | 19 | + (Class)transformedValueClass 20 | { 21 | return [NSString class]; 22 | } 23 | 24 | 25 | + (BOOL)allowsReverseTransformation 26 | { 27 | return NO; 28 | } 29 | 30 | 31 | - (id)transformedValue:(id)value 32 | { 33 | NSFont *font = [NSUnarchiver unarchiveObjectWithData:value]; 34 | 35 | return [NSString stringWithFormat:@"%@ - %.0fpt", [font fontName], [font pointSize]]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispFoundationPrefsWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispFoundationPrefsWindowController.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 30/04/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RispRenderFoundationPreferences.h" 11 | #import "RispPrefsWindowController.h" 12 | 13 | @interface RispFoundationPrefsWindowController : RispPrefsWindowController { 14 | IBOutlet NSView *generalView; 15 | RispRenderFoundationFontsAndColoursPrefsViewController *fontsAndColoursPrefsViewController; 16 | RispRenderFoundationTextEditingPrefsViewController *textEditingPrefsViewController; 17 | NSString *toolbarIdentifier; 18 | NSString *generalIdentifier; 19 | NSString *textIdentifier; 20 | NSString *fontIdentifier; 21 | 22 | } 23 | - (IBAction)revertToStandardSettings:(id)sender; 24 | @end 25 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundation-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/RispRenderFoundation/RispRenderFoundation-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/RispRenderFoundation/RispRenderFoundationAutoCompleteDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationAutoCompleteDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 4/12/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol RispRenderFoundationAutoCompleteDelegate 12 | 13 | - (NSArray*) completions; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationBasicPerformer.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | 23 | @interface RispRenderFoundationBasicPerformer : NSObject { 24 | 25 | NSNumberFormatter *thousandFormatter; 26 | NSMutableDictionary *fetchRequests; 27 | } 28 | 29 | + (RispRenderFoundationBasicPerformer *)sharedInstance; 30 | 31 | - (void)insertFetchRequests; 32 | - (NSArray *)fetchAll:(NSString *)key; 33 | - (void)removeAllItemsFromMenu:(NSMenu *)menu; 34 | - (void)insertSortOrderNumbersForArrayController:(NSArrayController *)arrayController; 35 | - (NSString *)thousandFormatedStringFromNumber:(NSNumber *)number; 36 | - (NSString *)copyResolveAliasInPath:(NSString *)path; 37 | 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationBreakpointDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationBreakpointDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 3/5/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol RispRenderFoundationBreakpointDelegate 12 | 13 | - (void) toggleBreakpointForFile:(NSString*)file onLine:(int)line; 14 | - (NSSet*) breakpointsForFile:(NSString*)file; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationErrorPopOver.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationErrorPopOver.h 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 4/11/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface RispRenderFoundationErrorPopOver : NSObject 12 | 13 | // Pass an array of strings to this function to open up the popover window. Window will be centered in the view that is passed to this function. 14 | + (void) showErrorDescriptions:(NSArray*)errors relativeToView:(NSView*) view; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationFontsAndColoursPrefsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationFontsAndColoursPrefsViewController.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 14/09/2012. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RispRenderFoundationFontsAndColoursPrefsViewController : RispRenderFoundationPrefsViewController 13 | 14 | - (IBAction)setFontAction:(id)sender; 15 | - (void)changeFont:(id)sender; 16 | @end 17 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationFontsAndColoursPrefsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationFontsAndColoursPrefsViewController.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 14/09/2012. 6 | // 7 | // 8 | 9 | #import "RispRenderFoundation.h" 10 | #import "RispRenderFoundationFramework.h" 11 | 12 | @interface RispRenderFoundationFontsAndColoursPrefsViewController () 13 | 14 | @end 15 | 16 | @implementation RispRenderFoundationFontsAndColoursPrefsViewController 17 | 18 | /* 19 | 20 | - init 21 | 22 | */ 23 | - (id)init { 24 | self = [super initWithNibName:@"RispRenderFoundationPreferencesFontsAndColours" bundle:[NSBundle bundleForClass:[self class]]]; 25 | if (self) { 26 | 27 | } 28 | return self; 29 | } 30 | 31 | /* 32 | 33 | - setFontAction: 34 | 35 | */ 36 | - (IBAction)setFontAction:(id)sender 37 | { 38 | #pragma unused(sender) 39 | 40 | NSFontManager *fontManager = [NSFontManager sharedFontManager]; 41 | NSData *fontData = [[[NSUserDefaultsController sharedUserDefaultsController] values] valueForKey:RispRenderFoundationPrefsTextFont]; 42 | NSFont *font = [NSUnarchiver unarchiveObjectWithData:fontData]; 43 | [fontManager setSelectedFont:font isMultiple:NO]; 44 | [fontManager orderFrontFontPanel:nil]; 45 | 46 | } 47 | 48 | /* 49 | 50 | - changeFont: 51 | 52 | */ 53 | - (void)changeFont:(id)sender 54 | { 55 | 56 | /* changeFont: is sent up the responder chain by the fontManager so we have to call this 57 | method from say the preferences window controller which has been configured as the window delegate */ 58 | NSFontManager *fontManager = sender; 59 | NSFont *panelFont = [fontManager convertFont:[fontManager selectedFont]]; 60 | [RispRenderFoundationDefaults setValue:[NSArchiver archivedDataWithRootObject:panelFont] forKey:RispRenderFoundationPrefsTextFont]; 61 | } 62 | @end 63 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationFramework.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RispRenderFoundationFramework.h 3 | * Fragaria 4 | * 5 | * Created by Jonathan on 06/05/2010. 6 | * Copyright 2010 mugginsoft.com. All rights reserved. 7 | * 8 | */ 9 | #import "RispRenderFoundationStandardHeader.h" 10 | #import "RispRenderFoundationSyntaxColouring.h" 11 | #import "RispRenderFoundationTextView.h" 12 | #import "RispRenderFoundationLayoutManager.h" 13 | #import "RispRenderFoundationLineNumbers.h" 14 | #import "RispRenderFoundationGutterTextView.h" 15 | #import "RispRenderFoundationTextPerformer.h" 16 | #import "RispRenderFoundationExtraInterfaceController.h" 17 | #import "RispRenderFoundationBasicPerformer.h" 18 | #import "RispRenderFoundationTextMenuController.h" 19 | #import "ICUPattern.h" 20 | #import "ICUMatcher.h" 21 | #import "NSStringICUAdditions.h" 22 | #import "RispFoundationPrefsWindowController.h" 23 | #import "RispRenderFoundationSyntaxController.h" 24 | #import "NSScanner+Fragaria.h" 25 | #import "RispRenderFoundationPreferences.h" 26 | #import "RispRenderFoundationGlyphGenerator.h" 27 | #import "RispRenderFoundationPreferences.h" 28 | #import "RispRenderFoundationErrorPopOver.h" 29 | #import "RispRenderFoundationAutoCompleteDelegate.h" 30 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationGlyphGenerator.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationGlyphGenerator.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 23/09/2012. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface RispRenderFoundationGlyphGenerator : NSGlyphGenerator { 12 | id _destination; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationGutterTextView.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | 23 | @interface RispRenderFoundationGutterTextView : NSTextView { 24 | NSImage* imgBreakpoint0; 25 | NSImage* imgBreakpoint1; 26 | NSImage* imgBreakpoint2; 27 | NSString* fileName; 28 | NSArray* breakpointLines; 29 | } 30 | 31 | @property (nonatomic,copy) NSString* fileName; 32 | @property (nonatomic,retain) NSArray* breakpointLines; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationLayoutManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | @interface RispRenderFoundationLayoutManager : NSLayoutManager { 23 | 24 | NSDictionary *defAttributes; 25 | NSString *tabCharacter; 26 | NSString *newLineCharacter; 27 | NSString *spaceCharacter; 28 | BOOL showInvisibleCharacters; 29 | NSGlyph *invisibleGlyphs; 30 | BOOL useGlyphSubstitutionForInvisibleGlyphs; 31 | BOOL drawInvisibleGlyphsUsingCoreText; 32 | NSMutableArray *lineRefs; 33 | } 34 | 35 | - (NSAttributedString *)attributedStringWithTemporaryAttributesApplied; 36 | 37 | @property BOOL showInvisibleCharacters; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationLineNumbers.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | @class RispRenderFoundationTextView; 23 | 24 | @interface RispRenderFoundationLineNumbers : NSObject { 25 | NSPoint zeroPoint; 26 | NSClipView *updatingLineNumbersForClipView; 27 | NSDictionary *attributes; 28 | id document; 29 | } 30 | 31 | - (id)initWithDocument:(id)theDocument; 32 | - (void)viewBoundsDidChange:(NSNotification *)notification; 33 | - (void)updateLineNumbersCheckWidth:(BOOL)checkWidth recolour:(BOOL)recolour; 34 | - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)checkWidth recolour:(BOOL)recolour; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationPrefsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationPrefsViewController.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 22/10/2012. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface RispRenderFoundationPrefsViewController : NSViewController 12 | - (BOOL)commitEditingAndDiscard:(BOOL)discard; 13 | @end 14 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationPrefsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationPrefsViewController.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 22/10/2012. 6 | // 7 | // 8 | 9 | #import "RispRenderFoundationPrefsViewController.h" 10 | 11 | @interface RispRenderFoundationPrefsViewController () 12 | 13 | @end 14 | 15 | @implementation RispRenderFoundationPrefsViewController 16 | 17 | /* 18 | 19 | - commitEditingAndDiscard: 20 | 21 | */ 22 | - (BOOL)commitEditingAndDiscard:(BOOL)discard 23 | { 24 | BOOL commit = YES; 25 | 26 | // commit edits, discarding changes on error 27 | if (![[NSUserDefaultsController sharedUserDefaultsController] commitEditing]) { 28 | if (discard) [[NSUserDefaultsController sharedUserDefaultsController] discardEditing]; 29 | commit = NO; 30 | } 31 | 32 | return commit; 33 | } 34 | 35 | #pragma mark - 36 | #pragma mark NSTabViewDelegate 37 | 38 | /* 39 | 40 | - tabView:shouldSelectTabViewItem: 41 | 42 | */ 43 | - (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem 44 | { 45 | #pragma unused(tabView) 46 | #pragma unused(tabViewItem) 47 | BOOL select = YES; 48 | 49 | // if we have un committed edits then disallow tab item selection 50 | if (![self commitEditingAndDiscard:NO]) { 51 | select = NO; 52 | } 53 | 54 | return select; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationSyntaxController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationSyntaxController.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 01/05/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface RispRenderFoundationSyntaxController : NSObject { 13 | 14 | NSArray *syntaxDefinitionNames; 15 | NSMutableDictionary *syntaxDefinitions; 16 | } 17 | 18 | + (instancetype)sharedInstance; 19 | + (NSString *)standardSyntaxDefinitionName; 20 | - (NSArray *)syntaxDefinitionNames; 21 | - (void)insertSyntaxDefinitions; 22 | - (NSDictionary *)syntaxDictionaryWithName:(NSString *)name; 23 | - (NSDictionary *)syntaxDefinitionWithExtension:(NSString *)extension; 24 | - (NSString *)syntaxDefinitionNameWithExtension:(NSString *)extension; 25 | 26 | @property (retain, nonatomic,readonly) NSArray *syntaxDefinitionNames; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationSyntaxError.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationSyntaxError.h 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 4/9/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface RispRenderFoundationSyntaxError : NSObject 12 | { 13 | NSString* description; 14 | int line; 15 | int character; 16 | NSString* code; 17 | int length; 18 | } 19 | 20 | @property (nonatomic,copy) NSString* description; 21 | @property (nonatomic,assign) int line; 22 | @property (nonatomic,assign) int character; 23 | @property (nonatomic,copy) NSString* code; 24 | @property (nonatomic,assign) int length; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationSyntaxError.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationSyntaxError.m 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 4/9/13. 6 | // 7 | // 8 | 9 | #import "RispRenderFoundationSyntaxError.h" 10 | 11 | @implementation RispRenderFoundationSyntaxError 12 | 13 | @synthesize line, character, code, length, description; 14 | 15 | - (void) dealloc 16 | { 17 | self.description = NULL; 18 | self.code = NULL; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationTextEditingPrefsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationTextEditingPrefsViewController.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 14/09/2012. 6 | // 7 | // 8 | 9 | #import 10 | #import "RispRenderFoundationPrefsViewController.h" 11 | 12 | @interface RispRenderFoundationTextEditingPrefsViewController : RispRenderFoundationPrefsViewController { 13 | NSImage *toolbarImage; 14 | } 15 | 16 | - (IBAction)changeGutterWidth:(id)sender; 17 | @end 18 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationTextEditingPrefsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RispRenderFoundationTextEditingPrefsViewController.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 14/09/2012. 6 | // 7 | // 8 | 9 | #import "RispRenderFoundationTextEditingPrefsViewController.h" 10 | #import "RispRenderFoundationFramework.h" 11 | 12 | @interface RispRenderFoundationTextEditingPrefsViewController () 13 | 14 | @end 15 | 16 | @implementation RispRenderFoundationTextEditingPrefsViewController 17 | 18 | /* 19 | 20 | - init 21 | 22 | */ 23 | - (id)init { 24 | self = [super initWithNibName:@"RispRenderFoundationPreferencesTextEditing" bundle:[NSBundle bundleForClass:[self class]]]; 25 | if (self) { 26 | 27 | } 28 | return self; 29 | } 30 | 31 | /* 32 | 33 | - changeGutterWidth: 34 | 35 | */ 36 | - (IBAction)changeGutterWidth:(id)sender { 37 | #pragma unused(sender) 38 | 39 | /*NSEnumerator *documentEnumerator = [[[FRACurrentProject documentsArrayController] arrangedObjects] objectEnumerator]; 40 | for (id document in documentEnumerator) { 41 | [FRAInterface updateGutterViewForDocument:document]; 42 | [[document valueForKey:ro_MGSFOLineNumbers] updateLineNumbersCheckWidth:YES recolour:YES]; 43 | }*/ 44 | } 45 | 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationTextPerformer.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | 23 | @interface RispRenderFoundationTextPerformer : NSObject { 24 | 25 | NSString *darkSideLineEnding; 26 | NSString *macLineEnding; 27 | NSString *unixLineEnding; 28 | 29 | NSString *newLineSymbolString; 30 | } 31 | 32 | + (RispRenderFoundationTextPerformer *)sharedInstance; 33 | 34 | - (NSString *)convertLineEndings:(NSString *)stringToConvert inDocument:(id)document; 35 | 36 | - (NSStringEncoding)guessEncodingFromData:(NSData *)textData; 37 | 38 | - (NSString *)replaceAllNewLineCharactersWithSymbolInString:(NSString *)theTextString; 39 | 40 | - (NSString *)removeAllLineEndingsInString:(NSString *)string; 41 | 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/RispRenderFoundationTextView.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RispRenderFoundation 4 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 5 | Find the latest version at https://github.com/mugginsoft/Fragaria 6 | 7 | Smultron version 3.6b1, 2009-09-12 8 | Written by Peter Borg, pgw3@mac.com 9 | Find the latest version at http://smultron.sourceforge.net 10 | 11 | Copyright 2004-2009 Peter Borg 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 | */ 19 | 20 | #import 21 | 22 | @class RispRenderFoundation; 23 | 24 | @interface RispRenderFoundationTextView : NSTextView { 25 | @private 26 | NSInteger lineHeight; 27 | NSPoint startPoint; 28 | NSPoint startOrigin; 29 | CGFloat pageGuideX; 30 | NSColor *pageGuideColour; 31 | 32 | BOOL showPageGuide; 33 | 34 | NSCursor *colouredIBeamCursor; 35 | 36 | BOOL lineWrap; 37 | } 38 | 39 | @property (retain) NSCursor *colouredIBeamCursor; 40 | @property (weak) IBOutlet RispRenderFoundation *fragaria; 41 | 42 | @property (nonatomic) BOOL lineWrap; 43 | 44 | - (void)setDefaults; 45 | 46 | - (void)setTextDefaults; 47 | 48 | - (NSInteger)lineHeight; 49 | 50 | - (void)setTabWidth; 51 | 52 | - (void)setPageGuideValues; 53 | - (void)updateIBeamCursor; 54 | 55 | - (void)setString:(NSString *)text options:(NSDictionary *)options; 56 | - (void)setAttributedString:(NSAttributedString *)text; 57 | - (void)setAttributedString:(NSAttributedString *)text options:(NSDictionary *)options; 58 | - (void)updateLineWrap; 59 | - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)text options:(NSDictionary *)options; 60 | @end 61 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/latex.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | { 7 | endCommand 8 | } 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | \ 15 | endVariable 16 | {}()[],?.;/:+=><~ 17 | firstString 18 | $ 19 | secondString 20 | 21 | firstSingleLineComment 22 | % 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | \\((sub)*section|part|chapter|paragraph){[^}]*} 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | \begin{document} 44 | \end{document} 45 | 46 | autocompleteWords 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/none.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | 19 | secondString 20 | 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | allowSyntaxColouring 42 | 43 | keywords 44 | 45 | autocompleteWords 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/pdf.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | / 15 | endVariable 16 | ()><[]{}/% 17 | firstString 18 | 19 | secondString 20 | 21 | firstSingleLineComment 22 | % 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | endobj 44 | endstream 45 | f 46 | false 47 | n 48 | null 49 | obj 50 | R 51 | startxref 52 | stream 53 | trailer 54 | true 55 | xref 56 | 57 | autocompleteWords 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/plist.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | <? 11 | endInstruction 12 | ?> 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | 44 | autocompleteWords 45 | 46 | key 47 | string 48 | real 49 | integer 50 | date 51 | true 52 | false 53 | data 54 | array 55 | dict 56 | 57 | 58 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/sgml.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | 44 | autocompleteWords 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/shell.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | ` 7 | endCommand 8 | ´ 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | $ 15 | endVariable 16 | (){}=;:[] 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | # 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | ^\s*(function)?\s?\w*(\(\))?\s?\n?\s*\{ 35 | removeFromFunction 36 | function 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | if 44 | then 45 | elif 46 | else 47 | fi 48 | case 49 | in 50 | ;; 51 | esac 52 | while 53 | for 54 | do 55 | done 56 | continue 57 | local 58 | return 59 | 60 | autocompleteWords 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/standard.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | allowSyntaxColouring 42 | 43 | keywords 44 | 45 | autocompleteWords 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/supercollider.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | | 11 | endInstruction 12 | | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | // 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | /* 27 | endFirstMultiLineComment 28 | */ 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | ^\s*.*\(.*\)\n?\s*\{ 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | and 44 | ar 45 | arg 46 | case 47 | classvar 48 | collect 49 | do 50 | dup 51 | false 52 | if 53 | inf 54 | kr 55 | new 56 | nil 57 | or 58 | protect 59 | switch 60 | this 61 | true 62 | super 63 | try 64 | var 65 | while 66 | 67 | autocompleteWords 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/torquescript.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autocompleteWords 6 | 7 | beginCommand 8 | 9 | beginFirstMultiLineComment 10 | /* 11 | beginInstruction 12 | 13 | beginSecondMultiLineComment 14 | 15 | beginVariable 16 | $% 17 | endCommand 18 | 19 | endFirstMultiLineComment 20 | */ 21 | endInstruction 22 | 23 | endSecondMultiLineComment 24 | 25 | endVariable 26 | ./*+-()=; 27 | firstSingleLineComment 28 | // 29 | firstString 30 | " 31 | functionDefinition 32 | ^\s*\w*function\s+.* 33 | keywords 34 | 35 | break 36 | case 37 | continue 38 | datablock 39 | default 40 | else 41 | function 42 | if 43 | for 44 | new 45 | or 46 | package 47 | return 48 | switch 49 | switch$ 50 | while 51 | yes 52 | no 53 | on 54 | off 55 | true 56 | false 57 | 58 | keywordsCaseSensitive 59 | 60 | recolourKeywordIfAlreadyColoured 61 | 62 | removeFromFunction 63 | function 64 | secondSingleLineComment 65 | 66 | secondString 67 | ' 68 | 69 | 70 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/Syntax Definitions/xml.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | <? 11 | endInstruction 12 | ?> 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | CDATA 44 | EMPTY 45 | INCLUDE 46 | IGNORE 47 | NDATA 48 | #IMPLIED 49 | #PCDATA 50 | #REQUIRED 51 | 52 | autocompleteWords 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Risp/RispRenderFoundation/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Risp/SDK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/SDK.png -------------------------------------------------------------------------------- /Risp/entry.risp: -------------------------------------------------------------------------------- 1 | (def x (fn [x y] (. x decimalNumberByAdding: y))) 2 | 3 | (def x (. 1 decimalNumberByAdding: 2)) 4 | x 5 | 6 | (def x (. NSImage imageNamed: "QQ20140423-3")) 7 | x 8 | 9 | [[NSImage alloc] initWithContentsOfFile:[@"~/Desktop/1.gif" stringByStandardizingPath]] 10 | 11 | (. (. NSImage alloc) initWithContentsOfFile: (. "~/Pictures/psb.png" stringByStandardizingPath)) 12 | 13 | (def x (. (. NSImage alloc) initWithContentsOfFile: (. "~/Desktop/1.gif" stringByStandardizingPath))) 14 | 15 | (def x (. (. NSFileWrapper alloc) initWithPath: (. "~/Desktop/1.gif" stringByStandardizingPath))) 16 | x 17 | 18 | (def x (. (. NSFileWrapper alloc) initWithPath: (. "~/Desktop/1.gif" stringByStandardizingPath))) 19 | x 20 | 21 | (def x (. (. NSImage alloc) initWithContentsOfFile: (. "~/Pictures/psb.png" stringByStandardizingPath))) 22 | 23 | (defn 我是 [x n] 24 | (if (zero? n) 25 | '() 26 | (cons x (我是 x (dec n))))) 27 | (def 猫 (. (. NSImage alloc) initWithContentsOfFile: (. "~/Desktop/1.png" stringByStandardizingPath))) 28 | 29 | (def 三 3) 30 | 31 | (我是 猫 三) -------------------------------------------------------------------------------- /Risp/libLLVM-3.5.0svn.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetVal/Risp/80b2049ffa98afb9e9a530880587e41ae81eb013/Risp/libLLVM-3.5.0svn.dylib -------------------------------------------------------------------------------- /Risp/test.risp: -------------------------------------------------------------------------------- 1 | (defn test [f r] 2 | (if (= r (f)) 3 | true 4 | false)) 5 | 6 | (defn identity [x] x) 7 | 8 | (defn = 9 | ([x] x) 10 | ([x y] (. x isEqualTo: y)) 11 | ([x y z] (and (. x isEqualTo: y) (. x isEqualTo: z)))) 12 | -------------------------------------------------------------------------------- /RispMobile/Risp/Risp/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 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/Model/RispEvalCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // RispEvalCore.h 3 | // Risp 4 | // 5 | // Created by closure on 7/16/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface RispEvalCore : NSObject 12 | + (NSArray *)evalCurrentLine:(NSString *)sender expressions:(NSArray **)expressions; 13 | @end 14 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/RispAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RispReader 4 | // 5 | // Created by closure on 7/15/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RispAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/RispReader-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | #import 5 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/RispReader-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // RispReader-Prefix.pch 3 | // Risp 4 | // 5 | // Created by closure on 7/16/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #ifndef Risp_RispReader_Prefix_pch 10 | #define Risp_RispReader_Prefix_pch 11 | 12 | // Include any system framework and library headers here that should be included in all compilation units. 13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 14 | #import 15 | #endif 16 | -------------------------------------------------------------------------------- /RispMobile/Risp/RispReader/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RispReader 4 | // 5 | // Created by closure on 7/15/14. 6 | // Copyright (c) 2014 closure. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RispAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([RispAppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------