Skip to content

Commit

Permalink
Merge branch 'master' into py
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Jan 12, 2022
2 parents da6cdae + af1927c commit ea74a12
Show file tree
Hide file tree
Showing 266 changed files with 3,444 additions and 1,196 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Testing/Temporary
CPackConfig.cmake
CPackSourceConfig.cmake
_CPack_Packages
/CMakeSettings.json

## libraries
*.a
Expand All @@ -68,6 +69,7 @@ src/lfortran/parser/tokenizer.cpp
src/lfortran/parser/preprocessor.cpp
src/lfortran/ast.h
src/lfortran/asr.h
src/libasr/asr.h
src/lfortran/config.h
share/jupyter/kernels/fortran/kernel.json
src/runtime/*.o.empty.c
Expand Down Expand Up @@ -141,6 +143,7 @@ MANIFEST

## Editor Files
.vscode/
.vs/

## Build Files
*/bin/lfortran
Expand Down
20 changes: 20 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ cxx:
- ctest --output-on-failure
- ./src/bin/parse

# Test the C++ version
libasr:
stage: build
image: registry.gitlab.com/lfortran/ci-images:full-1.7.0
script:
- export PATH="$HOME/conda_root/bin:$PATH"
- conda install -c conda-forge rapidjson
- tar xzf dist/lfortran-*.tar.gz
- cd lfortran-*
- mkdir build
- cd build
- mv ../src/libasr .
- cd libasr
- CXXFLAGS="-Werror" cmake
-DCMAKE_PREFIX_PATH=$HOME/conda_root
-DCMAKE_INSTALL_PREFIX=`pwd`
-DCMAKE_BUILD_TYPE=Debug
.
- cmake --build .

# Create a binary tarball with the C++ based LFortran
cxx_binary:
stage: build
Expand Down
2 changes: 1 addition & 1 deletion bench.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Compile the latest master and a given MR in Release mode from scratch.
#
Expand Down
2 changes: 2 additions & 0 deletions build0.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

xonsh ./build1_win.sh
4 changes: 2 additions & 2 deletions build0.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand All @@ -13,7 +13,7 @@ python grammar/asdl_py.py
# Generate a Python AST from Python.asdl (C++)
python grammar/asdl_cpp.py grammar/Python.asdl src/lfortran/python_ast.h
# Generate a Fortran ASR from ASR.asdl (C++)
python grammar/asdl_cpp.py grammar/ASR.asdl src/lfortran/asr.h
python grammar/asdl_cpp.py grammar/ASR.asdl src/libasr/asr.h

# Generate the tokenizer and parser
(cd src/lfortran/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
Expand Down
2 changes: 1 addition & 1 deletion build1.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
8 changes: 8 additions & 0 deletions build1_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

bash ci/version.sh
python grammar/asdl_cpp.py
python grammar/asdl_cpp.py grammar/ASR.asdl src/libasr/asr.h
pushd src/lfortran/parser && re2c -W -b tokenizer.re -o tokenizer.cpp && popd
pushd src/lfortran/parser && re2c -W -b preprocessor.re -o preprocessor.cpp && popd
pushd src/lfortran/parser && bison -Wall -d -r all parser.yy && popd
2 changes: 1 addition & 1 deletion ci/azure_install_macos.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/azure_mirror.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/azure_status.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/build.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bash ci/version.sh
# Generate a Fortran AST from AST.asdl (C++)
python grammar/asdl_cpp.py
# Generate a Fortran ASR from ASR.asdl (C++)
python grammar/asdl_cpp.py grammar/ASR.asdl src/lfortran/asr.h
python grammar/asdl_cpp.py grammar/ASR.asdl src/libasr/asr.h

# Generate the tokenizer and parser
pushd src/lfortran/parser && re2c -W -b tokenizer.re -o tokenizer.cpp && popd
Expand Down
2 changes: 1 addition & 1 deletion ci/create_source_tarball.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/create_source_tarball0.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/github_mirror.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/grammar_conflicts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/upload_docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/upload_tarball.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script extracts the project's current version from git using
# `git describe`, which determines the version based on the latest tag, such as:
Expand Down
23 changes: 23 additions & 0 deletions doc/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@ Run an interactive prompt:
./src/bin/lfortran
```

## Build on Windows with Visual Studio

Install Conda for example by installing the Miniconda installation by following instructions there for your platform. If not already done, activate the Conda-Installation (cf. Conda installation instructions).

First, clone the repo to a local folder.

Launch a Conda command interpreter and run the following commands:
```bash
conda update -q conda
conda install -c conda-forge python=3.7 re2c m2-bison xonsh llvmdev=11.1.0 jupyter xeus=1.0.1 xtl nlohmann_json cppzmq jupyter_kernel_test pytest
```
Next, `cd` to the root of the repository and run
```bash
.\build0.bat
```

Now, you can launch Visual Studio and open the LFortran folder.
Before the first build you have to set up the `ZLib`-pathes: Go to the CMake-Settings (Project -> CMake Setttings for lfortran) and check `Show advanced variables`. Scroll to the `ZLIB_...` variables and set:
- `ZLIB_INCLUDE_DIR` = \<Conda-Installation-Path\>\Library\include
- `ZLIB_LIBRARY_[DEBUG|RELEASE]` = \<Conda-Installation-Path\>\Library\lib\zlib.lib

Then you can generate the CMake-Cache and build the project.

## Enabling the Jupyter Kernel

To install the Jupyter kernel, install the following Conda packages also:
Expand Down
3 changes: 2 additions & 1 deletion grammar/ASR.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ stmt
| SubroutineCall(symbol name, symbol? original_name, expr* args, expr? dt)
| Where(expr test, stmt* body, stmt* orelse)
| WhileLoop(expr test, stmt* body)
| Nullify(symbol* vars)


expr
Expand Down Expand Up @@ -231,7 +232,7 @@ ttype
| Class(symbol class_type, dimension* dims)
| Pointer(ttype type)

boolop = And | Or | NEqv | Eqv
boolop = And | Or | Xor | NEqv | Eqv

binop = Add | Sub | Mul | Div | Pow

Expand Down
4 changes: 2 additions & 2 deletions grammar/AST.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ trivia_node
| EndOfLine()
| Semicolon()

boolop = And | Or | Eqv | NEqv
boolop = And | Or | Xor | Eqv | NEqv

operator = Add | Sub | Mul | Div | Pow

Expand All @@ -242,7 +242,7 @@ unaryop = Invert | Not | UAdd | USub
cmpop = Eq | NotEq | Lt | LtE | Gt | GtE

intrinsicop
= AND | OR | EQV | NEQV
= AND | OR | XOR | EQV | NEQV
| PLUS | MINUS | STAR | DIV | POW
| NOT
| EQ | NOTEQ | LT | LTE | GT | GTE
Expand Down
12 changes: 6 additions & 6 deletions grammar/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,12 +1207,12 @@ def add_masks(fields, node):
// Generated by grammar/asdl_cpp.py
#include <lfortran/parser/alloc.h>
#include <lfortran/parser/location.h>
#include <lfortran/colors.h>
#include <lfortran/containers.h>
#include <lfortran/exception.h>
#include <lfortran/semantics/asr_scopes.h>
#include <libasr/alloc.h>
#include <libasr/location.h>
#include <libasr/colors.h>
#include <libasr/containers.h>
#include <libasr/exception.h>
#include <libasr/asr_scopes.h>
namespace LFortran::%(MOD)s {
Expand Down
16 changes: 16 additions & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ RUN(NAME subroutines_01 LABELS gfortran llvm cpp x86)
RUN(NAME subroutines_02 LABELS gfortran llvm cpp x86)
RUN(NAME subroutines_04 LABELS gfortran llvm)
RUN(NAME subroutines_06 LABELS gfortran)
RUN(NAME subroutines_07 LABELS gfortran)

RUN(NAME functions_01 LABELS gfortran llvm cpp x86)
RUN(NAME functions_02 LABELS gfortran llvm)
Expand Down Expand Up @@ -186,6 +187,7 @@ RUN(NAME modulo_01 LABELS gfortran llvm)

RUN(NAME int_01 LABELS gfortran llvm) # int body
RUN(NAME int_02 LABELS gfortran) # int symboltable
RUN(NAME int_03 LABELS gfortran llvm) # large int

RUN(NAME intrinsics_01 LABELS gfortran) # sqrt, abs, log
RUN(NAME intrinsics_02 LABELS gfortran llvm) # sin
Expand Down Expand Up @@ -218,6 +220,12 @@ RUN(NAME intrinsics_25 LABELS gfortran llvm) # ishft
RUN(NAME intrinsics_26 LABELS gfortran llvm)
RUN(NAME intrinsics_27 LABELS gfortran)
RUN(NAME intrinsics_28 LABELS gfortran llvm)
RUN(NAME intrinsics_29 LABELS gfortran llvm) # random_number
RUN(NAME intrinsics_30 LABELS gfortran llvm)
RUN(NAME intrinsics_31 LABELS gfortran llvm)
RUN(NAME intrinsics_32 LABELS gfortran)
RUN(NAME intrinsics_33 LABELS gfortran llvm)
RUN(NAME intrinsics_34 LABELS gfortran llvm)
RUN(NAME intrinsics_open_close_read_write LABELS gfortran)

RUN(NAME parameter_01 LABELS gfortran)
Expand Down Expand Up @@ -284,6 +292,7 @@ RUN(NAME interface_05 LABELS gfortran llvm)
RUN(NAME interface_06 LABELS gfortran)
RUN(NAME interface_07 LABELS gfortran llvm)
RUN(NAME interface_09 LABELS gfortran)
RUN(NAME interface_10 LABELS gfortran llvm)

RUN(NAME generic_name_01 LABELS gfortran llvm)

Expand Down Expand Up @@ -323,6 +332,9 @@ RUN(NAME derived_types_01 LABELS gfortran llvm)
RUN(NAME derived_types_02 LABELS gfortran)
RUN(NAME derived_types_03 LABELS gfortran)
RUN(NAME derived_types_04 LABELS gfortran)
RUN(NAME derived_types_06 LABELS gfortran llvm)
RUN(NAME derived_types_05 LABELS gfortran)
RUN(NAME derived_types_07 LABELS gfortran)

RUN(NAME line_continuation_01 LABELS gfortran llvm)
RUN(NAME line_continuation_02 LABELS gfortran llvm)
Expand Down Expand Up @@ -368,6 +380,7 @@ RUN(NAME string_10 LABELS gfortran llvm)
RUN(NAME string_11 LABELS gfortran llvm)
RUN(NAME string_12 LABELS gfortran)
RUN(NAME string_13 LABELS gfortran llvm)
RUN(NAME string_14 LABELS gfortran)

RUN(NAME nested_01 LABELS gfortran llvm)
RUN(NAME nested_02 LABELS gfortran llvm)
Expand Down Expand Up @@ -414,5 +427,8 @@ RUN(NAME sin_03 LABELS gfortran llvm)
RUN(NAME sin_04 LABELS gfortran llvm)
RUN(NAME bits_01 LABELS gfortran llvm)
RUN(NAME bits_02 LABELS gfortran llvm)
RUN(NAME bits_03 LABELS gfortran llvm)
RUN(NAME bits_04 LABELS gfortran llvm)
RUN(NAME bits_05 LABELS gfortran llvm)
RUN(NAME cpu_time_01 LABELS gfortran llvm)
RUN(NAME boz_01 LABELS gfortran llvm)
4 changes: 2 additions & 2 deletions integration_tests/arrays_05.f90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
program arrays_05
implicit none
real, dimension(5) :: numbers
real, dimension(5) :: numbers = [1.5, 3.2, 4.5, 0.9, 7.2]
integer :: i
do i = 1, 5
numbers(i) = i * 2.0
end do
numbers = (/ 1.5, 3.2, 4.5, 0.9, 7.2 /)
numbers = [1.5, 3.2, 4.5, 0.9, 7.2]
end program
37 changes: 37 additions & 0 deletions integration_tests/bits_03.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
program bits_03
implicit none
integer(4) :: from, to
integer(8) :: from8, to8
from = 10
to = 4
from8 = 10_8
to8 = 4_8
call mvbits(from, 2, 2, to, 0)
if (from /= 10) error stop
if (to /= 6) error stop
call mvbits(from8, 2, 2, to8, 0)
if (from8 /= 10) error stop
if (to8 /= 6_8) error stop
call mvbits(from, 0, 2, to, 2)
if (from /= 10) error stop
if (to /= 10) error stop
call mvbits(from8, 0, 2, to8, 2)
if (from8 /= 10) error stop
if (to8 /= 10_8) error stop
from = -20
to = 4
from8 = -20_8
to8 = 4_8
call mvbits(from, 29, 2, to, 2)
if (from /= -20) error stop
if (to /= 12) error stop
call mvbits(from8, 29, 2, to8, 2)
if (from8 /= -20) error stop
if (to8 /= 12_8) error stop
call mvbits(from, 2, 2, to, 29)
if (from /= -20) error stop
if (to /= 1610612748) error stop
call mvbits(from8, 2, 2, to8, 29)
if (from8 /= -20) error stop
if (to8 /= 1610612748_8) error stop
end program
Loading

0 comments on commit ea74a12

Please sign in to comment.