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

37
LINES

< > BotCompany Repo | #1008817 // Test brackets + && + || + rule, bottom-up

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2438L/16K/53K).

1  
!7
2  
3  
sS input = [[
4  
  RULE WasLAB (("was|warum")&&("ist|bedeutet|heißt|soll|meint|nenn(t|en|st)")&&("lab")||("bla"))
5  
]];
6  
7  
sS rules = [[
8  
9  
RULE <identifier> ( <exp> ) = rule
10  
11  
// bracketing combines top and bottom
12  
( <exp> ) = bracket
13  
<bracket> = expX
14  
15  
// primitive expressions are also at top level
16  
<quoted> = expX
17  
18  
// now come the lower levels
19  
<expX> = exp3
20  
21  
<exp2> & & <exp3> = and
22  
<exp3> = exp2
23  
<and> = exp2
24  
25  
<exp1> | | <exp2> = or
26  
<exp2> = exp1
27  
<or> = exp1
28  
29  
// lowest level
30  
<exp1> = exp
31  
]];
32  
33  
p-tt {
34  
  Explain e = explain(input, rules, "rule");
35  
  print("Parsed as: " + structForUser(e.fullMatchClasses()));
36  
  printExplainTree2_filterClasses(e, func(S s) { !startsWith(s, "exp") });
37  
}

Author comment

Began life as a copy of #1008809

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: #1008817
Snippet name: Test brackets + && + || + rule, bottom-up
Eternal ID of this version: #1008817/23
Text MD5: 8854b725d40712f2b2f7b495452ddd05
Transpilation MD5: 80f8504581e3c98448f019e8d28713fe
Author: stefan
Category: javax / parsing
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-10 01:05:25
Source code size: 718 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 528 / 743
Version history: 22 change(s)
Referenced in: [show references]