1 / 23

R4Intellij

R4Intellij. Integration of R with Intellij IDEA. Roadmap (coming soon). Live Templates Quickfixes for common problems Incorrect subset Folding ArcFoldingBuilder More complete unit test collection See GrammarKit examples. Roadmap (later). quick navigation to variable definitions

zander
Download Presentation

R4Intellij

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. R4Intellij Integration of R with Intellij IDEA

  2. Roadmap (coming soon) • Live Templates • Quickfixes for common problems • Incorrect subset • Folding • ArcFoldingBuilder • More complete unit test collection • See GrammarKit examples

  3. Roadmap (later) • quick navigation to variable definitions • (excellent) Example: ArcChooser • Push to R also for windows • Example? Arc:ReplToolWindow • ColorSettingsPage (see Bash implementation) • Show parameter info

  4. Roadmap (far future) • R Console for Idea • Learn from bash:AddReplAction • Use Rdaemon to access R session • Provide intentions for ggplot • Add path completion relative to getwd() (see bash plugin

  5. Lexer • Just as the lexer is a source code spelling checker, the parser is a grammar checker • A utility such as JFlex builds a lexer from a specification file the programmer writes to define the 'words' (lexical tokens) in the desired language

  6. Parser • The parser works by setting pairs of markers (PsiBuilder.Marker instances) within the stream of tokens received from the lexer. Each pair of markers defines the range of lexer tokens for a single node in the AST tree. If a pair of markers is nested in another pair (starts after its start and ends before its end), it becomes the child node of the outer pair. • The element type for the marker pair (and for the AST node created from it) is specified when the end marker is set (by a call to PsiBuilder.Marker.done()) • BashElementTypesvsBashTokenTypes

  7. Parser Basics: LL-Parser • Ein LL-Parser heißt LL(k)-Parser, wennerwährend des Parsens k Tokens vorausschauenkann und imGegensatzzum LF-Parser den Kellerinhaltbenutzt. k wirddabeialsLookaheadbezeichnet • Obwohl die LL(k)-Grammatikenrelativeingeschränktsind, werden LL(k)-Parser oft benutzt. Die Entscheidung, nachwelcher Regel expandiertwird, kannalleindurchAnalyse des Lookaheadgetroffenwerden. EineeinfacheMöglichkeitzurImplementierungdieserParsertechnikbietet die Methode des rekursivenAbstiegs • Einekontextfreie Grammatik heißtLL(k)-Grammatik füreinenatürlicheZahl k, wennjederAbleitungsschritteindeutigdurch die nächsten k Symbole der Eingabe (Lookahead) bestimmtist

  8. Parser package for R • Uses almost identical version of R grammar • According to parser docu: created using bison • Source file creates c-parser

  9. Psi parser • Try the grammar kit • The Clojure parser is probably the simplest and smallest of all the custom language plugins that are maintained by us • No, IDEA currently does not have a ready solution for using generated parsers. The typical approach when writing parsers in IDEA is to create a method parseSmth(). for each rule in the grammar, and implement the rule in terms of PsiBuilder markers. • write lexer and parser manually (lexer is jflex-generated and parser is completely by hand) since you have to continue your parsing whatever user types in. • Language construction never been easy, it doesn't matter if you do it by  hand or by Antlr

  10. PsiParser

  11. Recursive descent parser • kind of top-down parser built from a set of mutually-recursive procedures

  12. GrammarKit Notes • All used special characters must be named in the token-section of the grammar header • Other tokens will be picked up on the fly from the grammar rules (e.g. string, number, id in the bnf-example) • They will be translated into RTokenTypes (Rtypes) • They must be produced by the Lexer! (And just those, as other tokens will be ignored by the generated parser)

  13. ANTLR notes • ANTLR imposes the convention that lexer rules start with an uppercase letter and parser rules with a lowercase letter

  14. PEG • Indirect left-recursion is when a rule R calls a rule R′ which then calls R (where R and R′ are distinct rules). Indirect left-recursion adds a number of challenges • Direct Left-Recursive Parsing Expression Grammars  PEGs can be (indirect) left-recursive • Warth idea for packrat parsers: In essence, the parser turns from (recursive) top-down in normal operation to (iterative) bottom-up when left-recursion is detected

  15. Custom Language: R

  16. Language Injection

  17. Bash plugin for Intellij • Well done: http://www.ansorg-it.com/en/products_bashsupport.html

  18. Options for code snippet evaluation • R Session has almost complete implementation for console, objects, etc • TextMatebundle • Start R in special mode that reads all input from file and writes all output to another one which then somehow imported into textmate • I think FindWindow and SendMessage are the functions you want to use, in general. • Use the clipboard • Tinn-R: It also pops up additional menu and toolbar when it detects Rgui running on the same computer. These addons interact with the R console and allow to submit code in part or in whole and to control R directly. • It seems to have some limitations • Maybe DOM is a solution: rdom, RDCOMClient • Or white • Or most promising, we could try to use the windows API via VBScript or C#

  19. R Console for Idea • Use RSessionsolution • Learn from TinnR

  20. Tinn-R • Allows for Rgui interaction to evaluate line or selection • including list variables or objects, clearing console, even stopping the current process. • Code formatter • Bracket matching & checking • Commenting uncommenting

  21. RStudio

More Related