diff options
author | Camil Staps | 2015-07-04 19:53:55 +0200 |
---|---|---|
committer | Camil Staps | 2015-07-04 19:53:55 +0200 |
commit | af7f0d6b8103dbfa46b8d159be9c70e8db51e810 (patch) | |
tree | e347b06254819f2ba7c6c70adbcb9ed27aab4dbe | |
parent | Readme (diff) |
Fix show for expressions (parentheses); allow parentheses in input
-rw-r--r-- | Logic.icl | 11 | ||||
-rw-r--r-- | request.php | 2 |
2 files changed, 11 insertions, 2 deletions
@@ -117,7 +117,16 @@ where show opt (B b) = show opt b show opt (Atom a) = show opt a show opt (App1 op e) = show opt op +++ show opt e - show opt (App2 e1 op e2) = show opt e1 +++ " " +++ show opt op +++ " " +++ show opt e2 + show opt (App2 e1 op e2) = if needs_l "(" "" +++ + show opt e1 +++ + if needs_l ")" "" +++ + " " +++ show opt op +++ " " +++ + if needs_r "(" "" +++ + show opt e2 +++ + if needs_r ")" "" + where + needs_l = needs_parentheses_left (App2 e1 op e2) + needs_r = needs_parentheses_right (App2 e1 op e2) instance == Op1 where diff --git a/request.php b/request.php index 2866ada..9dfb4bc 100644 --- a/request.php +++ b/request.php @@ -36,7 +36,7 @@ if ($expressions == []) die('Not enough expressions requested'); foreach ($expressions as $k => $e) - if (preg_match('/[^a-zA-Z\|\&~\-><01 ]/', $e)) + if (preg_match('/[^a-zA-Z\|\&~\-><01 \(\)]/', $e)) die('Forbidden character in expression ' . $e); $expressions = array_map('escapeshellarg', $expressions); |