recognizers why and how
play

Recognizers Why and How M. Anton Ertl TU Wien How to deal with - PowerPoint PPT Presentation

Recognizers Why and How M. Anton Ertl TU Wien How to deal with literals Recognizers Parsing Words 123 s" abc" $ff H# ff a [char] a 1.2e3 No way to define new recognizers No good way to define parsing words


  1. Recognizers Why and How M. Anton Ertl TU Wien

  2. How to deal with literals Recognizers Parsing Words 123 s" abc" $ff H# ff ’a’ [char] a 1.2e3 • No way to define new recognizers • No good way to define parsing words non-default non-immediate compilation semantics State -smartness and the like Not just an implementation problem • ⇒ user-defined recognizers

  3. Ideal • Recognized literal acts like a normal word • : 123 123 ; • Interpret Compile Postpone ? vs. ]] a 123 b [[ ]] a [[ 123 ]] literal b [[ ’ ? find find-name name>string ?

  4. How to specify and implement recognizers • Specify interpret, compile, and postpone actions Advantage: Optimization possible Disadvantage: Bugs can hide, especially for postpone • Specify parse-time, run-time, and data-shifting actions interpret: parse-time run-time compile: parse-time shift ]] run-time [[ postpone: parse-time shift ]] shift ]] run-time [[ [[ • Define a temporary word Advantages: Allows ticking etc. Conceptual simplicity Disadvantage: Optimization?

  5. Temporary words • Separate dictionary pointer (like ELF section) • Should be inlined if compiled. But how? • Becomes permanent if postpone d or ticked • Other permanent uses need explicit permanence • Recognized string as name? Decompiler name>string

  6. Coding example : usingle ( c-addr u -- f ) 0. 2over >number 0= if drop 2drop 2drop false exit then drop drop rot rot [’] constant execute-parsing true ;

  7. Inline when compiled • Require using an intelligent compile, Quite elegant But set-opt is unlikely to be standardized • Or specify parse-time and compile-time action For compilation, perform these actions In other cases, build the word

  8. Performance with many recognizers • Linear search through recognizer stack? • Or fast pre-selection • Pre-selection may accept invalid strings but must not reject valid strings • prefix pre-selectors ⇒ trie • regexp pre-selectors ⇒ NFA/DFA

  9. Conclusion • User-defined words are great! Let´s also allow user-defined recognizers • New implementation approach: Define temporary words How to inline? • Pre-Selectors for performance

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend