PageRenderTime 74ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/YieldProlog/Modules/Parser.cs

https://bitbucket.org/VirtualReality/optional-modules
C# | 4572 lines | 4458 code | 73 blank | 41 comment | 123 complexity | ce5d678426367e726ae3f51595df23f5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright (c) Contributors, http://aurora-sim.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the Aurora-Sim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. // disable warning on l1, don't see how we can
  30. // code this differently
  31. #pragma warning disable 0168, 0219, 0162
  32. namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
  33. {
  34. public class Parser
  35. {
  36. public static IEnumerable<bool> read_term2(object Term, object Options)
  37. {
  38. Variable Answer = new Variable();
  39. Variable Variables = new Variable();
  40. foreach (bool l1 in read_termOptions(Options, Variables))
  41. {
  42. foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
  43. {
  44. foreach (bool l3 in remove_pos(Answer, Term))
  45. yield return false;
  46. }
  47. }
  48. }
  49. public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
  50. {
  51. Variable SaveInput = new Variable();
  52. Variable Answer = new Variable();
  53. Variable Variables = new Variable();
  54. foreach (bool l1 in read_termOptions(Options, Variables))
  55. {
  56. foreach (bool l2 in YP.current_input(SaveInput))
  57. {
  58. try
  59. {
  60. YP.see(Input);
  61. foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
  62. {
  63. foreach (bool l4 in remove_pos(Answer, Term))
  64. yield return false;
  65. }
  66. }
  67. finally
  68. {
  69. YP.see(SaveInput);
  70. }
  71. }
  72. }
  73. }
  74. /// <summary>
  75. /// For read_term, check if Options has variable_names(Variables).
  76. /// Otherwise, ignore Options.
  77. /// </summary>
  78. /// <param name="Options"></param>
  79. /// <param name="Variables"></param>
  80. /// <returns></returns>
  81. private static IEnumerable<bool> read_termOptions(object Options, object Variables)
  82. {
  83. Options = YP.getValue(Options);
  84. if (Options is Variable)
  85. throw new PrologException(Atom.a("instantiation_error"), "Options is an unbound variable");
  86. // First try to match Options = [variable_names(Variables)]
  87. foreach (bool l1 in YP.unify(Options, ListPair.make(new Functor1("variable_names", Variables))))
  88. {
  89. yield return false;
  90. yield break;
  91. }
  92. // Default: Ignore Options.
  93. yield return false;
  94. }
  95. public static IEnumerable<bool> read1(object Term)
  96. {
  97. return read_term2(Term, Atom.NIL);
  98. }
  99. public static IEnumerable<bool> read2(object Input, object Term)
  100. {
  101. return read_term3(Input, Term, Atom.NIL);
  102. }
  103. public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
  104. {
  105. // Debug: Simple implementation for now.
  106. YP.write(Format);
  107. YP.write(Arguments);
  108. YP.nl();
  109. yield return false;
  110. }
  111. // Debug: Hand-modify this central predicate to do tail recursion.
  112. public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
  113. {
  114. bool repeat = true;
  115. while (repeat)
  116. {
  117. repeat = false;
  118. {
  119. object C1 = arg1;
  120. object Dict = arg2;
  121. object Tokens = arg3;
  122. Variable C2 = new Variable();
  123. if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
  124. {
  125. if (YP.greaterThanOrEqual(C1, 0))
  126. {
  127. foreach (bool l4 in YP.get_code(C2))
  128. {
  129. #if false
  130. foreach (bool l5 in read_tokens(C2, Dict, Tokens))
  131. {
  132. yield return false;
  133. }
  134. #endif
  135. arg1 = YP.getValue(C2);
  136. arg2 = YP.getValue(Dict);
  137. arg3 = YP.getValue(Tokens);
  138. repeat = true;
  139. }
  140. }
  141. goto cutIf1;
  142. }
  143. if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
  144. {
  145. if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
  146. {
  147. foreach (bool l4 in read_identifier(C1, Dict, Tokens))
  148. {
  149. yield return false;
  150. }
  151. goto cutIf2;
  152. }
  153. }
  154. if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
  155. {
  156. if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
  157. {
  158. foreach (bool l4 in read_variable(C1, Dict, Tokens))
  159. {
  160. yield return false;
  161. }
  162. goto cutIf3;
  163. }
  164. }
  165. if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
  166. {
  167. if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
  168. {
  169. foreach (bool l4 in read_number(C1, Dict, Tokens))
  170. {
  171. yield return false;
  172. }
  173. goto cutIf4;
  174. }
  175. }
  176. if (YP.lessThan(C1, 127))
  177. {
  178. foreach (bool l3 in read_special(C1, Dict, Tokens))
  179. {
  180. yield return false;
  181. }
  182. goto cutIf5;
  183. }
  184. if (YP.lessThanOrEqual(C1, 160))
  185. {
  186. foreach (bool l3 in YP.get_code(C2))
  187. {
  188. #if false
  189. foreach (bool l4 in read_tokens(C2, Dict, Tokens))
  190. {
  191. yield return false;
  192. }
  193. #endif
  194. arg1 = YP.getValue(C2);
  195. arg2 = YP.getValue(Dict);
  196. arg3 = YP.getValue(Tokens);
  197. repeat = true;
  198. }
  199. goto cutIf6;
  200. }
  201. if (YP.greaterThanOrEqual(C1, 223))
  202. {
  203. if (YP.notEqual(C1, 247))
  204. {
  205. foreach (bool l4 in read_identifier(C1, Dict, Tokens))
  206. {
  207. yield return false;
  208. }
  209. goto cutIf7;
  210. }
  211. }
  212. if (YP.greaterThanOrEqual(C1, 192))
  213. {
  214. if (YP.notEqual(C1, 215))
  215. {
  216. foreach (bool l4 in read_variable(C1, Dict, Tokens))
  217. {
  218. yield return false;
  219. }
  220. goto cutIf8;
  221. }
  222. }
  223. if (YP.notEqual(C1, 170))
  224. {
  225. if (YP.notEqual(C1, 186))
  226. {
  227. foreach (bool l4 in read_symbol(C1, Dict, Tokens))
  228. {
  229. yield return false;
  230. }
  231. goto cutIf9;
  232. }
  233. }
  234. foreach (bool l2 in read_identifier(C1, Dict, Tokens))
  235. {
  236. yield return false;
  237. }
  238. cutIf9:
  239. cutIf8:
  240. cutIf7:
  241. cutIf6:
  242. cutIf5:
  243. cutIf4:
  244. cutIf3:
  245. cutIf2:
  246. cutIf1:
  247. { }
  248. }
  249. }
  250. }
  251. // Compiler output follows.
  252. class YPInnerClass { }
  253. // static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
  254. public static IEnumerable<bool> parseInput(object TermList)
  255. {
  256. {
  257. Variable TermAndVariables = new Variable();
  258. FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
  259. foreach (bool l2 in parseInputHelper(TermAndVariables))
  260. {
  261. findallAnswers1.add();
  262. }
  263. foreach (bool l2 in findallAnswers1.result(TermList))
  264. {
  265. yield return false;
  266. }
  267. }
  268. }
  269. public static IEnumerable<bool> parseInputHelper(object arg1)
  270. {
  271. {
  272. Variable Term = new Variable();
  273. Variable Variables = new Variable();
  274. Variable Answer = new Variable();
  275. Variable x4 = new Variable();
  276. foreach (bool l2 in YP.unify(arg1, new Functor2("f", Term, Variables)))
  277. {
  278. foreach (bool l3 in YP.repeat())
  279. {
  280. foreach (bool l4 in portable_read3(Answer, Variables, x4))
  281. {
  282. foreach (bool l5 in remove_pos(Answer, Term))
  283. {
  284. if (YP.termEqual(Term, Atom.a("end_of_file")))
  285. {
  286. yield break;
  287. goto cutIf1;
  288. }
  289. yield return false;
  290. cutIf1:
  291. { }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. public static IEnumerable<bool> clear_errors()
  299. {
  300. {
  301. yield return false;
  302. }
  303. }
  304. public static IEnumerable<bool> remove_pos(object arg1, object arg2)
  305. {
  306. {
  307. Variable X = new Variable();
  308. foreach (bool l2 in YP.unify(arg1, X))
  309. {
  310. foreach (bool l3 in YP.unify(arg2, X))
  311. {
  312. if (YP.var(X))
  313. {
  314. yield return true;
  315. yield break;
  316. }
  317. }
  318. }
  319. }
  320. {
  321. object X = arg2;
  322. Variable _Pos = new Variable();
  323. Variable _Name = new Variable();
  324. foreach (bool l2 in YP.unify(arg1, new Functor3("$VAR", _Pos, _Name, X)))
  325. {
  326. if (YP.var(X))
  327. {
  328. yield return true;
  329. yield break;
  330. }
  331. }
  332. }
  333. {
  334. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  335. {
  336. foreach (bool l3 in YP.unify(arg2, Atom.NIL))
  337. {
  338. yield return true;
  339. yield break;
  340. }
  341. }
  342. }
  343. {
  344. Variable H = new Variable();
  345. Variable T = new Variable();
  346. Variable NH = new Variable();
  347. Variable NT = new Variable();
  348. foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
  349. {
  350. foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT)))
  351. {
  352. foreach (bool l4 in remove_pos(H, NH))
  353. {
  354. foreach (bool l5 in remove_pos(T, NT))
  355. {
  356. yield return false;
  357. }
  358. }
  359. yield break;
  360. }
  361. }
  362. }
  363. {
  364. Variable A = new Variable();
  365. Variable B = new Variable();
  366. Variable NA = new Variable();
  367. Variable NB = new Variable();
  368. foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
  369. {
  370. foreach (bool l3 in YP.unify(arg2, new Functor2(",", NA, NB)))
  371. {
  372. foreach (bool l4 in remove_pos(A, NA))
  373. {
  374. foreach (bool l5 in remove_pos(B, NB))
  375. {
  376. yield return false;
  377. }
  378. }
  379. yield break;
  380. }
  381. }
  382. }
  383. {
  384. Variable Atom_1 = new Variable();
  385. Variable _F = new Variable();
  386. foreach (bool l2 in YP.unify(arg1, Atom_1))
  387. {
  388. foreach (bool l3 in YP.unify(arg2, Atom_1))
  389. {
  390. foreach (bool l4 in YP.functor(Atom_1, _F, 0))
  391. {
  392. yield return false;
  393. }
  394. }
  395. }
  396. }
  397. {
  398. object Term = arg1;
  399. object NewTerm = arg2;
  400. Variable Func = new Variable();
  401. Variable _Pos = new Variable();
  402. Variable Args = new Variable();
  403. Variable NArgs = new Variable();
  404. if (YP.nonvar(Term))
  405. {
  406. foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args))))
  407. {
  408. foreach (bool l4 in remove_pos(Args, NArgs))
  409. {
  410. foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs)))
  411. {
  412. yield return false;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax)
  420. {
  421. {
  422. foreach (bool l2 in portable_read(PosTerm, Syntax))
  423. {
  424. foreach (bool l3 in remove_pos(PosTerm, Term))
  425. {
  426. yield return false;
  427. }
  428. }
  429. }
  430. }
  431. public static IEnumerable<bool> portable_read(object Answer, object Syntax)
  432. {
  433. {
  434. Variable Tokens = new Variable();
  435. Variable ParseTokens = new Variable();
  436. foreach (bool l2 in read_tokens1(Tokens))
  437. {
  438. foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
  439. {
  440. foreach (bool l4 in parse2(ParseTokens, Answer))
  441. {
  442. yield return false;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax)
  449. {
  450. {
  451. Variable Tokens = new Variable();
  452. Variable ParseTokens = new Variable();
  453. foreach (bool l2 in read_tokens2(Tokens, Variables))
  454. {
  455. foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
  456. {
  457. foreach (bool l4 in parse2(ParseTokens, Answer))
  458. {
  459. yield return false;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3)
  466. {
  467. {
  468. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  469. {
  470. foreach (bool l3 in YP.unify(arg2, Atom.NIL))
  471. {
  472. foreach (bool l4 in YP.unify(arg3, Atom.NIL))
  473. {
  474. yield return false;
  475. }
  476. }
  477. }
  478. }
  479. {
  480. object Ys = arg2;
  481. Variable S = new Variable();
  482. Variable E = new Variable();
  483. Variable Xs = new Variable();
  484. Variable Zs = new Variable();
  485. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("comment", S, E), Xs)))
  486. {
  487. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", S, E), Zs)))
  488. {
  489. foreach (bool l4 in remove_comments(Xs, Ys, Zs))
  490. {
  491. yield return false;
  492. }
  493. yield break;
  494. }
  495. }
  496. }
  497. {
  498. Variable Pos = new Variable();
  499. Variable Xs = new Variable();
  500. Variable Ys = new Variable();
  501. Variable Pos2 = new Variable();
  502. Variable Zs = new Variable();
  503. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("["), Pos), Xs)))
  504. {
  505. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("["), Ys)))
  506. {
  507. foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
  508. {
  509. foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
  510. {
  511. foreach (bool l6 in remove_comments(Xs, Ys, Zs))
  512. {
  513. yield return false;
  514. }
  515. }
  516. yield break;
  517. }
  518. }
  519. }
  520. }
  521. {
  522. Variable Pos = new Variable();
  523. Variable Xs = new Variable();
  524. Variable Ys = new Variable();
  525. Variable Pos2 = new Variable();
  526. Variable Zs = new Variable();
  527. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("]"), Pos), Xs)))
  528. {
  529. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), Ys)))
  530. {
  531. foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
  532. {
  533. foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
  534. {
  535. foreach (bool l6 in remove_comments(Xs, Ys, Zs))
  536. {
  537. yield return false;
  538. }
  539. }
  540. yield break;
  541. }
  542. }
  543. }
  544. }
  545. {
  546. object Zs = arg3;
  547. Variable Token = new Variable();
  548. Variable Xs = new Variable();
  549. Variable Ys = new Variable();
  550. foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs)))
  551. {
  552. foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys)))
  553. {
  554. foreach (bool l4 in remove_comments(Xs, Ys, Zs))
  555. {
  556. yield return false;
  557. }
  558. }
  559. }
  560. }
  561. }
  562. public static IEnumerable<bool> expect(object Token, object arg2, object arg3)
  563. {
  564. {
  565. object Rest = arg3;
  566. foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest)))
  567. {
  568. yield return true;
  569. yield break;
  570. }
  571. }
  572. {
  573. object S0 = arg2;
  574. object x3 = arg3;
  575. foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("or"), Atom.a("operator"), Atom.a("expected") }), S0))
  576. {
  577. yield return false;
  578. }
  579. }
  580. }
  581. public static IEnumerable<bool> parse2(object Tokens, object Answer)
  582. {
  583. {
  584. Variable Term = new Variable();
  585. Variable LeftOver = new Variable();
  586. foreach (bool l2 in clear_errors())
  587. {
  588. foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver))
  589. {
  590. foreach (bool l4 in all_read(LeftOver))
  591. {
  592. foreach (bool l5 in YP.unify(Answer, Term))
  593. {
  594. yield return false;
  595. }
  596. yield break;
  597. }
  598. }
  599. foreach (bool l3 in syntax_error(Tokens))
  600. {
  601. yield return false;
  602. }
  603. }
  604. }
  605. }
  606. public static IEnumerable<bool> all_read(object arg1)
  607. {
  608. {
  609. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  610. {
  611. yield return false;
  612. }
  613. }
  614. {
  615. Variable Token = new Variable();
  616. Variable S = new Variable();
  617. foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
  618. {
  619. foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a("operator"), Atom.a("expected"), Atom.a("after"), Atom.a("expression") }), new ListPair(Token, S)))
  620. {
  621. yield return false;
  622. }
  623. }
  624. }
  625. }
  626. public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4)
  627. {
  628. {
  629. object x1 = arg2;
  630. object x2 = arg3;
  631. object x3 = arg4;
  632. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  633. {
  634. foreach (bool l3 in syntax_error(new ListPair(Atom.a("expression"), new ListPair(Atom.a("expected"), Atom.NIL)), Atom.NIL))
  635. {
  636. yield return false;
  637. }
  638. }
  639. }
  640. {
  641. object Precedence = arg2;
  642. object Term = arg3;
  643. object LeftOver = arg4;
  644. Variable Token = new Variable();
  645. Variable RestTokens = new Variable();
  646. foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens)))
  647. {
  648. foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver))
  649. {
  650. yield return false;
  651. }
  652. }
  653. }
  654. }
  655. public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5)
  656. {
  657. {
  658. object S0 = arg2;
  659. object x2 = arg3;
  660. object x3 = arg4;
  661. object x4 = arg5;
  662. foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
  663. {
  664. foreach (bool l3 in cannot_start(Atom.a("}"), S0))
  665. {
  666. yield return false;
  667. }
  668. }
  669. }
  670. {
  671. object S0 = arg2;
  672. object x2 = arg3;
  673. object x3 = arg4;
  674. object x4 = arg5;
  675. foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
  676. {
  677. foreach (bool l3 in cannot_start(Atom.a("]"), S0))
  678. {
  679. yield return false;
  680. }
  681. }
  682. }
  683. {
  684. object S0 = arg2;
  685. object x2 = arg3;
  686. object x3 = arg4;
  687. object x4 = arg5;
  688. foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
  689. {
  690. foreach (bool l3 in cannot_start(Atom.a(")"), S0))
  691. {
  692. yield return false;
  693. }
  694. }
  695. }
  696. {
  697. object S0 = arg2;
  698. object x2 = arg3;
  699. object x3 = arg4;
  700. object x4 = arg5;
  701. foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
  702. {
  703. foreach (bool l3 in cannot_start(Atom.a(","), S0))
  704. {
  705. yield return false;
  706. }
  707. }
  708. }
  709. {
  710. object S0 = arg2;
  711. object x2 = arg3;
  712. object x3 = arg4;
  713. object x4 = arg5;
  714. foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
  715. {
  716. foreach (bool l3 in cannot_start(Atom.a("|"), S0))
  717. {
  718. yield return false;
  719. }
  720. }
  721. }
  722. {
  723. object S0 = arg2;
  724. object Precedence = arg3;
  725. object Answer = arg4;
  726. object S = arg5;
  727. Variable Codes = new Variable();
  728. Variable Term = new Variable();
  729. Variable A = new Variable();
  730. foreach (bool l2 in YP.unify(arg1, new Functor1("string", Codes)))
  731. {
  732. foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("atom")))
  733. {
  734. foreach (bool l4 in YP.atom_codes(Term, Codes))
  735. {
  736. foreach (bool l5 in exprtl0(S0, Term, Precedence, Answer, S))
  737. {
  738. yield return false;
  739. }
  740. }
  741. goto cutIf1;
  742. }
  743. foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("chars")))
  744. {
  745. foreach (bool l4 in YP.atom_codes(A, Codes))
  746. {
  747. foreach (bool l5 in YP.atom_chars(A, Term))
  748. {
  749. foreach (bool l6 in exprtl0(S0, Term, Precedence, Answer, S))
  750. {
  751. yield return false;
  752. }
  753. }
  754. }
  755. goto cutIf2;
  756. }
  757. foreach (bool l3 in YP.unify(Term, Codes))
  758. {
  759. foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
  760. {
  761. yield return false;
  762. }
  763. }
  764. cutIf2:
  765. cutIf1:
  766. { }
  767. }
  768. }
  769. {
  770. object S0 = arg2;
  771. object Precedence = arg3;
  772. object Answer = arg4;
  773. object S = arg5;
  774. Variable Number = new Variable();
  775. foreach (bool l2 in YP.unify(arg1, new Functor1("number", Number)))
  776. {
  777. foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
  778. {
  779. yield return false;
  780. }
  781. }
  782. }
  783. {
  784. object Precedence = arg3;
  785. object Answer = arg4;
  786. object S = arg5;
  787. Variable S1 = new Variable();
  788. foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
  789. {
  790. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), S1)))
  791. {
  792. foreach (bool l4 in read_atom(new Functor2("/", Atom.NIL, 0), S1, Precedence, Answer, S))
  793. {
  794. yield return false;
  795. }
  796. yield break;
  797. }
  798. }
  799. }
  800. {
  801. object S1 = arg2;
  802. object Precedence = arg3;
  803. object Answer = arg4;
  804. object S = arg5;
  805. Variable Arg1 = new Variable();
  806. Variable S2 = new Variable();
  807. Variable RestArgs = new Variable();
  808. Variable S3 = new Variable();
  809. foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
  810. {
  811. foreach (bool l3 in parse(S1, 999, Arg1, S2))
  812. {
  813. foreach (bool l4 in read_list(S2, RestArgs, S3))
  814. {
  815. foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S))
  816. {
  817. yield return false;
  818. }
  819. yield break;
  820. }
  821. }
  822. }
  823. }
  824. {
  825. object S1 = arg2;
  826. object Precedence = arg3;
  827. object Answer = arg4;
  828. object S = arg5;
  829. Variable Term = new Variable();
  830. Variable S2 = new Variable();
  831. Variable S3 = new Variable();
  832. foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
  833. {
  834. foreach (bool l3 in parse(S1, 1200, Term, S2))
  835. {
  836. foreach (bool l4 in expect(Atom.a(")"), S2, S3))
  837. {
  838. foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
  839. {
  840. yield return false;
  841. }
  842. yield break;
  843. }
  844. }
  845. }
  846. }
  847. {
  848. object S1 = arg2;
  849. object Precedence = arg3;
  850. object Answer = arg4;
  851. object S = arg5;
  852. Variable Term = new Variable();
  853. Variable S2 = new Variable();
  854. Variable S3 = new Variable();
  855. foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
  856. {
  857. foreach (bool l3 in parse(S1, 1200, Term, S2))
  858. {
  859. foreach (bool l4 in expect(Atom.a(")"), S2, S3))
  860. {
  861. foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
  862. {
  863. yield return false;
  864. }
  865. yield break;
  866. }
  867. }
  868. }
  869. }
  870. {
  871. object Precedence = arg3;
  872. object Answer = arg4;
  873. object S = arg5;
  874. Variable _Pos = new Variable();
  875. Variable S1 = new Variable();
  876. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), _Pos)))
  877. {
  878. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("}"), S1)))
  879. {
  880. foreach (bool l4 in read_atom(Atom.a("{}"), S1, Precedence, Answer, S))
  881. {
  882. yield return false;
  883. }
  884. yield break;
  885. }
  886. }
  887. }
  888. {
  889. object S1 = arg2;
  890. object Precedence = arg3;
  891. object Answer = arg4;
  892. object S = arg5;
  893. Variable Pos = new Variable();
  894. Variable Term = new Variable();
  895. Variable S2 = new Variable();
  896. Variable S3 = new Variable();
  897. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), Pos)))
  898. {
  899. foreach (bool l3 in parse(S1, 1200, Term, S2))
  900. {
  901. foreach (bool l4 in expect(Atom.a("}"), S2, S3))
  902. {
  903. foreach (bool l5 in exprtl0(S3, new Functor2("{}", Pos, Term), Precedence, Answer, S))
  904. {
  905. yield return false;
  906. }
  907. yield break;
  908. }
  909. }
  910. }
  911. }
  912. {
  913. object Precedence = arg3;
  914. object Answer = arg4;
  915. object S = arg5;
  916. Variable Variable_1 = new Variable();
  917. Variable Name = new Variable();
  918. Variable Pos = new Variable();
  919. Variable S1 = new Variable();
  920. Variable Arg1 = new Variable();
  921. Variable S2 = new Variable();
  922. Variable RestArgs = new Variable();
  923. Variable S3 = new Variable();
  924. Variable Term = new Variable();
  925. foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
  926. {
  927. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
  928. {
  929. foreach (bool l4 in parse(S1, 999, Arg1, S2))
  930. {
  931. foreach (bool l5 in read_args(S2, RestArgs, S3))
  932. {
  933. foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a("call"), new ListPair(new Functor3("$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs)))))
  934. {
  935. foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
  936. {
  937. yield return false;
  938. }
  939. }
  940. yield break;
  941. }
  942. }
  943. yield break;
  944. }
  945. }
  946. }
  947. {
  948. object S0 = arg2;
  949. object Precedence = arg3;
  950. object Answer = arg4;
  951. object S = arg5;
  952. Variable Variable_1 = new Variable();
  953. Variable Name = new Variable();
  954. Variable Pos = new Variable();
  955. foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
  956. {
  957. foreach (bool l3 in exprtl0(S0, new Functor3("$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
  958. {
  959. yield return false;
  960. }
  961. }
  962. }
  963. {
  964. object S0 = arg2;
  965. object Precedence = arg3;
  966. object Answer = arg4;
  967. object S = arg5;
  968. Variable Atom_1 = new Variable();
  969. Variable P = new Variable();
  970. foreach (bool l2 in YP.unify(arg1, new Functor2("atom", Atom_1, P)))
  971. {
  972. foreach (bool l3 in read_atom(new Functor2("/", Atom_1, P), S0, Precedence, Answer, S))
  973. {
  974. yield return false;
  975. }
  976. }
  977. }
  978. }
  979. public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S)
  980. {
  981. {
  982. Variable _Pos = new Variable();
  983. Variable Number = new Variable();
  984. Variable S1 = new Variable();
  985. Variable Negative = new Variable();
  986. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("-"), _Pos)))
  987. {
  988. foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1("number", Number), S1)))
  989. {
  990. foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
  991. {
  992. foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S))
  993. {
  994. yield return false;
  995. }
  996. }
  997. yield break;
  998. }
  999. }
  1000. }
  1001. {
  1002. Variable Functor_1 = new Variable();
  1003. Variable Pos = new Variable();
  1004. Variable S1 = new Variable();
  1005. Variable Arg1 = new Variable();
  1006. Variable S2 = new Variable();
  1007. Variable RestArgs = new Variable();
  1008. Variable S3 = new Variable();
  1009. Variable Term = new Variable();
  1010. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Functor_1, Pos)))
  1011. {
  1012. foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
  1013. {
  1014. foreach (bool l4 in parse(S1, 999, Arg1, S2))
  1015. {
  1016. foreach (bool l5 in read_args(S2, RestArgs, S3))
  1017. {
  1018. foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs)))))
  1019. {
  1020. foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
  1021. {
  1022. yield return false;
  1023. }
  1024. }
  1025. yield break;
  1026. }
  1027. }
  1028. yield break;
  1029. }
  1030. }
  1031. }
  1032. {
  1033. object S0 = arg2;
  1034. Variable Op = new Variable();
  1035. Variable Pos = new Variable();
  1036. Variable Oprec = new Variable();
  1037. Variable Aprec = new Variable();
  1038. Variable Flag = new Variable();
  1039. Variable Term = new Variable();
  1040. Variable Arg = new Variable();
  1041. Variable S1 = new Variable();
  1042. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Op, Pos)))
  1043. {
  1044. foreach (bool l3 in prefixop(Op, Oprec, Aprec))
  1045. {
  1046. foreach (bool l4 in possible_right_operand(S0, Flag))
  1047. {
  1048. if (YP.lessThan(Flag, 0))
  1049. {
  1050. foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL))))
  1051. {
  1052. foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S))
  1053. {
  1054. yield return false;
  1055. }
  1056. }
  1057. goto cutIf1;
  1058. }
  1059. if (YP.greaterThan(Oprec, Precedence))
  1060. {
  1061. foreach (bool l6 in syntax_error(ListPair.make(new object[] { Atom.a("prefix"), Atom.a("operator"), Op, Atom.a("in"), Atom.a("context"), Atom.a("with"), Atom.a("precedence"), Precedence }), S0))
  1062. {
  1063. yield return false;
  1064. }
  1065. goto cutIf2;
  1066. }
  1067. if (YP.greaterThan(Flag, 0))
  1068. {
  1069. foreach (bool l6 in parse(S0, Aprec, Arg, S1))
  1070. {
  1071. foreach (bool l7 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
  1072. {
  1073. foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
  1074. {
  1075. yield return false;
  1076. }
  1077. }
  1078. yield break;
  1079. }
  1080. goto cutIf3;
  1081. }
  1082. foreach (bool l5 in peepop(S0, S1))
  1083. {
  1084. foreach (bool l6 in prefix_is_atom(S1, Oprec))
  1085. {
  1086. foreach (bool l7 in exprtl(S1, Oprec, new Functor2("/", Op, Pos), Precedence, Answer, S))
  1087. {
  1088. yield return false;
  1089. }
  1090. }
  1091. }
  1092. foreach (bool l5 in parse(S0, Aprec, Arg, S1))
  1093. {
  1094. foreach (bool l6 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
  1095. {
  1096. foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
  1097. {
  1098. yield return false;
  1099. }
  1100. }
  1101. yield break;
  1102. }
  1103. cutIf3:
  1104. cutIf2:
  1105. cutIf1:
  1106. { }
  1107. }
  1108. yield break;
  1109. }
  1110. }
  1111. }
  1112. {
  1113. object S0 = arg2;
  1114. Variable Atom_1 = new Variable();
  1115. Variable Pos = new Variable();
  1116. Variable Term = new Variable();
  1117. foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom_1, Pos)))
  1118. {
  1119. foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
  1120. {
  1121. foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
  1122. {
  1123. yield return false;
  1124. }
  1125. }
  1126. }
  1127. }
  1128. }
  1129. public static IEnumerable<bool> cannot_start(object Token, object S0)
  1130. {
  1131. {
  1132. foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("cannot"), Atom.a("start"), Atom.a("an"), Atom.a("expression") }), S0))
  1133. {
  1134. yield return false;
  1135. }
  1136. }
  1137. }
  1138. public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3)
  1139. {
  1140. {
  1141. object S = arg3;
  1142. Variable S1 = new Variable();
  1143. Variable Term = new Variable();
  1144. Variable Rest = new Variable();
  1145. Variable S2 = new Variable();
  1146. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(","), S1)))
  1147. {
  1148. foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
  1149. {
  1150. foreach (bool l4 in parse(S1, 999, Term, S2))
  1151. {
  1152. foreach (bool l5 in read_args(S2, Rest, S))
  1153. {
  1154. yield return false;
  1155. }
  1156. yield break;
  1157. }
  1158. yield break;
  1159. }
  1160. }
  1161. }
  1162. {
  1163. object S = arg3;
  1164. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(")"), S)))
  1165. {
  1166. foreach (bool l3 in YP.unify(arg2, Atom.NIL))
  1167. {
  1168. yield return true;
  1169. yield break;
  1170. }
  1171. }
  1172. }
  1173. {
  1174. object S = arg1;
  1175. object x2 = arg2;
  1176. object x3 = arg3;
  1177. foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", or )"), Atom.a("expected"), Atom.a("in"), Atom.a("arguments") }), S))
  1178. {
  1179. yield return false;
  1180. }
  1181. }
  1182. }
  1183. public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3)
  1184. {
  1185. {
  1186. object x1 = arg2;
  1187. object x2 = arg3;
  1188. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1189. {
  1190. foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), Atom.NIL))
  1191. {
  1192. yield return false;
  1193. }
  1194. }
  1195. }
  1196. {
  1197. object Rest = arg2;
  1198. object S = arg3;
  1199. Variable Token = new Variable();
  1200. Variable S1 = new Variable();
  1201. foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
  1202. {
  1203. foreach (bool l3 in read_list4(Token, S1, Rest, S))
  1204. {
  1205. yield return false;
  1206. }
  1207. }

Large files files are truncated, but you can click here to view the full file