Commits

Anonymous committed 1ed515e

interactive loop

  • Participants
  • Parent commits c6a34f2

Comments (0)

Files changed (1)

File shakespeare.pir

 
 .loadlib 'shakespeare_group'
 
+.sub 'interactive' :method
+    # ignored
+    .param pmc adverbs         :slurpy :named
+    .local pmc rgx, stdin, match
+    .local pmc code # code has to be a pmc or a string conversion from null will die()
+    .local string output, prompt
+    prompt = '>'
+    stdin = getstdin
+    say "Thou hast entered the interactive sentence verifier"
+    say "Enter a Sentence to see How It Parses"
+    rgx= get_hll_global ['shakespeare';'Grammar'], 'sentence'
+  loop: 
+    unless stdin goto endloop
+    
+    code = stdin.'readline_interactive'(prompt)
+    if null code goto endloop
+    unless code goto loop
+    match = rgx(code)
+    if match goto dump
+    say "no match"
+    goto loop
+  dump:
+    output = match.'dump_str'()
+    say output
+    goto loop
+  endloop:
+.end
+
 .sub 'onload' :anon :load :init
     .local pmc p6meta
     load_bytecode 'PCT.pbc'