浏览代码

+ support for "return x" as equivalent for "exit(x)" in macpas mode

git-svn-id: trunk@2042 -
Jonas Maebe 19 年之前
父节点
当前提交
5ccbeea1d3
共有 4 个文件被更改,包括 19 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/pexpr.pas
  3. 2 0
      compiler/tokens.pas
  4. 11 0
      tests/webtbs/tw4136.pp

+ 1 - 0
.gitattributes

@@ -6587,6 +6587,7 @@ tests/webtbs/tw4100.pp svneol=native#text/plain
 tests/webtbs/tw4104.pp svneol=native#text/plain
 tests/webtbs/tw4115.pp svneol=native#text/plain
 tests/webtbs/tw4119.pp svneol=native#text/plain
+tests/webtbs/tw4136.pp svneol=native#text/plain
 tests/webtbs/tw4140.pp svneol=native#text/plain
 tests/webtbs/tw4150.pp svneol=native#text/plain
 tests/webtbs/tw4151.pp svneol=native#text/plain

+ 5 - 0
compiler/pexpr.pas

@@ -2016,6 +2016,11 @@ implementation
          end
         else
          case token of
+           _RETURN :
+              begin
+                consume(_RETURN);
+                p1 := cexitnode.create(comp_expr(true));
+              end;
            _INHERITED :
              begin
                again:=true;

+ 2 - 0
compiler/tokens.pas

@@ -167,6 +167,7 @@ type
     _RECORD,
     _REPEAT,
     _RESULT,
+    _RETURN,
     _STATIC,
     _STORED,
     _STRICT,
@@ -411,6 +412,7 @@ const
       (str:'RECORD'        ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'REPEAT'        ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'RESULT'        ;special:false;keyword:m_none;op:NOTOKEN),
+      (str:'RETURN'        ;special:false;keyword:m_mac;op:NOTOKEN),
       (str:'STATIC'        ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'STORED'        ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'STRICT'        ;special:false;keyword:m_none;op:NOTOKEN),

+ 11 - 0
tests/webtbs/tw4136.pp

@@ -0,0 +1,11 @@
+{$mode macpas}
+function f: longint;
+begin
+  return 3;
+end;
+
+begin
+  if f() <> 3 then
+    halt(1);
+end.
+