Uses 911K of libraries. Click here for Pure Java version (7974L/41K).
1 | !7 |
2 | |
3 | cprint { |
4 | start-thread { |
5 | S riddle = "STATIC ALA FLATTEN LIST OF PAIRS L PAIR A LL A OUT EMPTY LIST LL FOR PAIR APUN NULL L OUT ADD PA OUT ADD PB RET OUT"; |
6 | S productions = [[ |
7 | $main := $function |
8 | $function := $modifiers $typeParameters $returnType $name "(" $args ")" "{" $body "}" |
9 | $body := repeat0OrMore($statement) |
10 | $declaration := $type $name "=" $value ";" |
11 | $statement := $returnStmt | $declaration |
12 | $returnStmt := "ret" $value ";" |
13 | ]]; |
14 | |
15 | new LS prods2; |
16 | for (S grammarClass, def : parseColonEqualsProperties_tlftj(productions)) { |
17 | def = replaceDollarVarsWithAngleBracketed(def); |
18 | LS tok = javaTokWithAngleBracketsC(def); |
19 | S def2 = joinWithSpace(withoutQuoted(tok)); |
20 | S replacement = joinWithSpace("bla"); |
21 | prods2.add(dropDollarPrefix(grammarClass) + " => " + quote(def2) + " => " + replacement); |
22 | } |
23 | |
24 | new RecursiveProbabilisticParser1 parser; |
25 | parser.minTokensForAny = 0; |
26 | //parser.verbose = true; |
27 | print(recursiveProbabilisticParse(print(lines(prods2)), "function", riddle, +parser)); |
28 | } |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028213 |
Snippet name: | Probabilistic Riddle Parsing Spike 1 [seems to run forever] |
Eternal ID of this version: | #1028213/1 |
Text MD5: | 8e23c94ecc8b1fdf4b9555b45c793521 |
Transpilation MD5: | 0020c252ff1f192d51fc385a30aa61af |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-26 14:29:50 |
Source code size: | 1144 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 209 / 302 |
Referenced in: | [show references] |