Commits

ZyX_I committed 2a7c0b1

Made lexer detect unary minus
Fixed parser on more complex expressions then I tried previously

  • Participants
  • Parent commits 57154dc

Comments (0)

Files changed (2)

                         ELSE
                           C=S(I:I)
                           IF(INDEX('+-*/^()', C) .NE. 0)THEN
-                            CALL PUSH(OUT, OL, C)
+                            IF(C .EQ. '-' .AND.
+     $                         (     I .EQ. 1
+     $                          .OR. INDEX('(+-*/^', S(I-1:I-1)) .NE. 0)
+     $                        )THEN
+c                             Unary minus
+                              CALL PUSH(OUT, OL, '!')
+                            ELSE
+                              CALL PUSH(OUT, OL, C)
+                            END IF
                             I=I+1
                           ELSE
                             CI=ICHAR(C)
      $         .OR. I .EQ. START
      $         .OR. PLEV .GE. MLEVEL)THEN
               INL=INL+1
+              PLEV=5
               GO TO 200
             ELSE
               GO TO 300
               IF(INL .LT. 0)THEN
                 GO TO 300
               ELSE
+                PLEV=5
                 GO TO 200
               END IF
             ELSE
               IF(INL .GT. 0)THEN
+                PLEV=5
                 GO TO 200
               ELSE
                 LEV=LEVEL(C)
-                IF(     I .EQ. START
-     $             .OR. (1 .LE. PLEV .AND. PLEV .LE. 3))THEN
+                IF((     I .EQ. START
+     $              .OR. (1 .LE. PLEV .AND. PLEV .LE. 3)
+     $              .OR. (1 .LE.  LEV .AND.  LEV .LE. 3))
+     $             .AND. LEV .GE. MLEVEL)THEN
                   PLEV=LEV
-                ELSE
-                  PLEV=LEV
-                  GO TO 300
-                END IF
-                IF(PLEV .GE. MLEVEL)THEN
                   GO TO 200
                 ELSE
                   GO TO 300
      $     .OR. (ICHAR('A') .LE. AI .AND. AI .LE. ICHAR('Z')))THEN
           LEVEL=5
         ELSE
-          IF(ATOM .EQ. '(' .OR. ATOM .EQ. ')')THEN
+          IF(     ATOM .EQ. '('
+     $       .OR. ATOM .EQ. ')')THEN
             LEVEL=5
           ELSE
             IF(ICHAR('a') .LE. AI .AND. AI .LE. ICHAR('z'))THEN
               IF(ATOM .EQ. '^')THEN
                 LEVEL=3
               ELSE
-                IF(ATOM .EQ. '*' .OR. ATOM .EQ. '/')THEN
+                IF(     ATOM .EQ. '*'
+     $             .OR. ATOM .EQ. '/')THEN
                   LEVEL=2
                 ELSE
-                  IF(ATOM .EQ. '+' .OR. ATOM .EQ. '-')THEN
+                  IF(     ATOM .EQ. '+'
+     $               .OR. ATOM .EQ. '-'
+     $               .OR. ATOM .EQ. '!')THEN
                     LEVEL=1
                   ELSE
                     LEVEL=0