Libraryless. Click here for Pure Java version (3196L/21K/69K).
!759 static boolean printNulls = true, full = true; static L<S> inputs = toLinesFullTrim([[ hello "hello!" hello you hello < you [hello] [hello] [you] [hello < you] [ ? < Is < it < safe < to < allow [PowerTOP] to [make < all < the < changes < located on < the < Tunables < tab] ] [ I < was < going to < create < a < startup script < for < it ] ]]); static S snlRules = [[ // highest (strongest binding) level <identifier> = idword <quoted> = subword ? = idword ! = idword <subword> = word <idword> = word // juxtaposition on highest level <word> <word> = word // bracketing takes us to highest level [ <lowest> ] = subword ( <lowest> ) = subword // < is intermediate <word> = arrows <word> < <arrows> = arrows = lowest // allow empty here <arrows> = lowest ]]; p { for (S input : inputs) { Explain exp = full ? explainFull(input, snlRules, "lowest") : explain(input, snlRules, "lowest"); print(); print("PARSING: " + input); print(); if (exp == null) print("No parse"); else { //printStructure(exp.e); printTree(0, exp); } print(); } } static void printTree(int indent, Explain e) { if (e == null) { // this would print "null" for every <identifier> etc if (printNulls) print(indent(indent) + "null"); } else { print(indent(indent) + e.className() + " | " + e.string()); for (Explain sub : e.subs) printTree(indent+2, sub); } }
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: | #1002683 |
Snippet name: | Parsing Simplified NL (dev.) |
Eternal ID of this version: | #1002683/1 |
Text MD5: | fce1f37cafbc47462d56645f858ed8aa |
Transpilation MD5: | b1c76008175b872c594dd4809c4a70f6 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-13 20:12:08 |
Source code size: | 1573 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 742 / 781 |
Referenced in: | [show references] |