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).

!7

sS input = [[
  RULE WasLAB (("was|warum")&&("ist|bedeutet|heißt|soll|meint|nenn(t|en|st)")&&("lab")||("bla"))
]];

sS rules = [[

RULE <identifier> ( <exp> ) = rule

// bracketing combines top and bottom
( <exp> ) = bracket
<bracket> = expX

// primitive expressions are also at top level
<quoted> = expX

// now come the lower levels
<expX> = exp3

<exp2> & & <exp3> = and
<exp3> = exp2
<and> = exp2

<exp1> | | <exp2> = or
<exp2> = exp1
<or> = exp1

// lowest level
<exp1> = exp
]];

p-tt {
  Explain e = explain(input, rules, "rule");
  print("Parsed as: " + structForUser(e.fullMatchClasses()));
  printExplainTree2_filterClasses(e, func(S s) { !startsWith(s, "exp") });
}

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: 527 / 740
Version history: 22 change(s)
Referenced in: [show references]