Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #1007984 // hygienicParse1 - parser that prefers round-bracket-hygienic arguments

JavaX fragment (include)

sbool hygienicParse1_debug, hygienicParse1_unquote;

static Lisp hygienicParse1(S s) {
  if (hygienicParse1_debug)
    print("Parsing: " + s);
    
  // Simple case first
  S id = englishToConceptLanguage_simple(s);
  if (id != null) ret lisp(id);
  
  // Now the pattern matching
  L<Lisp> parses = englishToLisp_multi(s);
  if (hygienicParse1_debug) {
    int i = 0;
    for (Lisp l : sortByArgumentHygiene(parses))
      printIndent((++i) + ". " + l + " [" + lisp_roundBracketHygieneScore(l) + "]");
  }
  Lisp l = chooseBestArgumentHygiene(parses);
  ret l == null ? lispFromJavaTok(s) : hygienicParse1_sub(l);
}

// parse the arguments which are original strings 
static Lisp hygienicParse1_sub(Lisp l) {
  if (l == null || l.isLeaf()) ret l;
  Lisp x = lisp(l.head);
  for (Lisp a : l.args) {
    if (hygienicParse1_unquote) a = lisp(unquote(a.raw()));
    x.add(or(hygienicParse1(a.raw()), a));
  }
  ret x;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007984
Snippet name: hygienicParse1 - parser that prefers round-bracket-hygienic arguments
Eternal ID of this version: #1007984/10
Text MD5: e1c2cd0bf9f10415ef89b1b51fd82f69
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-25 01:41:48
Source code size: 948 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 587 / 543
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)