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)

1  
sbool hygienicParse1_debug, hygienicParse1_unquote;
2  
3  
static Lisp hygienicParse1(S s) {
4  
  if (hygienicParse1_debug)
5  
    print("Parsing: " + s);
6  
    
7  
  // Simple case first
8  
  S id = englishToConceptLanguage_simple(s);
9  
  if (id != null) ret lisp(id);
10  
  
11  
  // Now the pattern matching
12  
  L<Lisp> parses = englishToLisp_multi(s);
13  
  if (hygienicParse1_debug) {
14  
    int i = 0;
15  
    for (Lisp l : sortByArgumentHygiene(parses))
16  
      printIndent((++i) + ". " + l + " [" + lisp_roundBracketHygieneScore(l) + "]");
17  
  }
18  
  Lisp l = chooseBestArgumentHygiene(parses);
19  
  ret l == null ? lispFromJavaTok(s) : hygienicParse1_sub(l);
20  
}
21  
22  
// parse the arguments which are original strings 
23  
static Lisp hygienicParse1_sub(Lisp l) {
24  
  if (l == null || l.isLeaf()) ret l;
25  
  Lisp x = lisp(l.head);
26  
  for (Lisp a : l.args) {
27  
    if (hygienicParse1_unquote) a = lisp(unquote(a.raw()));
28  
    x.add(or(hygienicParse1(a.raw()), a));
29  
  }
30  
  ret x;
31  
}

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: 586 / 543
Version history: 9 change(s)
Referenced in: [show references]