diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000000..cd0c4869e30 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,11 @@ +coverage: + precision: 0 + status: + project: + default: + # basic + target: auto + threshold: 1% # we accept a bit fluctuation, as we run random tests + base: auto + paths: + - "src" diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000..933e3bb46e1 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,12 @@ +# List of commits that shouldn't be included in `git blame`. +# Github and other tools already support it if it's this exact filename +# But you have to teach your own git about this by running this command (in this repo) +# git config blame.ignoreRevsFile .git-blame-ignore-revs + +# indent fix for JSON +31b1031ade5d84f9c60e30d17da3b55e78d291fb + +# fixing tabs & spaces mixed +0d048e15683740b5c944be5333ec0680df825e47 +23ec4b622bbe503ef013be5a458e45ae6fd89b97 +200b0352084be9435c64aa60c550edd24a59131b diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..2ce24899f27 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.dot diff=-astextplain diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..cbe6e7d3fb7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** + +A clear and concise description of what the bug is. + +**To Reproduce** + +Steps to reproduce the behavior: +1. Modules to define (attach files or inline code quotes) +2. REPL commands to type +3. AND/OR: Eclipse IDE actions to trigger +4. See error in? REPL, Error Log, Console log? + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Stack traces** + +Literally copy stacktraces from the console, or from the Eclipse Error log here. + +**Desktop (please complete the following information):** + - Context: Eclipse plugin, Commandline REPL + - Rascal Version [e.g. 0.17.0], stable or unstable release? + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..bbcbbe7d615 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/stable-release-manual-testing-template.md b/.github/ISSUE_TEMPLATE/stable-release-manual-testing-template.md new file mode 100644 index 00000000000..882269c7121 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/stable-release-manual-testing-template.md @@ -0,0 +1,90 @@ +--- +name: Stable release manual testing template +about: This is a list of things to do and to check at the time of a stable release +title: "[RELEASE] version 0.x.x" +labels: release testing +assignees: '' + +--- + +# Preliminaries + +* Every time this document says "release X" ; we mean to execute the instructions of this Wiki page: https://github.com/usethesource/rascal/wiki/How-to-make-a-release-of-a-Rascal-implemenation-project +* The current release instructions are focused on the Rascal commandline tools and the Eclipse IDE plugin +* If you edit this template, then please push relevant improvements to the template itself for future reference. + +# Pre-releasing dependent tools in unstable + +First a "pre-release" of the supporting compiler/typechecker tools must be done, so we know we are releasing a consistently compiled standard library. + +- [ ] typepal and rascal-core compile in the continuous integration environment and no tests fail +- [ ] release typepal +- [ ] release rascal-core +- [ ] bump typepal and rascal-core versions in rascal-maven-plugin to latest releases +- [ ] bump typepal and rascal-core versions in rascal-eclipse to latests SNAPSHOT releases +- [ ] release rascal-maven-plugin +- [ ] bump rascal-maven-plugin dependency in rascal and rascal-eclipse project +- [ ] fix new errors and warnings in rascal and rascal-eclipse project + +# Manual version checks + +- [ ] Continuous Integration runs all unit and integration tests and fails no test +- [ ] Maximum number of compiler warnings are resolved +- [ ] Version numbers are verified manually + +# Manual feature tests + +- [ ] Eclipse download and install latest unstable release from update site https://releases.usethesource.io/maven/org/rascalmpl/rascal-update-site/ +- [ ] Open a Rascal REPL using the toolbar button +- [ ] Can create new Rascal project using the wizard +- [ ] Can create new Rascal module using the wizard +- [ ] Can edit Rascal file in Rascal project +- [ ] Save on Rascal file triggers type-checker +- [ ] Rascal outline works +- [ ] Rascal navigator works +- [ ] Rascal navigator displays working sets +- [ ] Rascal navigator displays interpreter's search path +- [ ] Clicking links in REPL opens editors and websites +- [ ] `rascal>1 + 1` on the REPL +- [ ] `import IO; println("Hello Rascal!");` +- [ ] in editor, click on use of name jumps to definition +- [ ] jump-to-definition also works to library modules and inside library modules +- [ ] clicking in outline jumps to editor to right position +- [ ] syntax highlighting in editor works +- [ ] add dependency on another project by editing `pom.xml` ` tag, import a module and test the type-checker as well as the interpreter for correct resolution +- [ ] `import demo::lang::Pico::Plugin; registerPico();` and test the editor of the example pico files (syntax highlighting, menu options) +- [ ] `import demo::lang::Pico::Plugin; rascal>:edit demo::lang::Pico::Plugin` +- [ ] use util::IDEServices: + - [ ] registerDiagnostics with more than one file + - [ ] test edit function (for example with vis::Graph examples that use it) + - [ ] test showInteractiveContent function (for example with vis::Chart examples) + +# Actual release + +- [ ] release rascal project (when resolving SNAPSHOT dependencies choose the right versions of vallang etc, and make sure to bump the new rascal SNAPSHOT release one minor version) +- [ ] bootstrap documentation site + - [ ] bump rascal version in rascal-maven-project, mvn install + - [ ] bump rascal version in rascal-website project + - [ ] set rascal-maven-project snapshot dependency in rascal-website project + - [ ] run `mvn clean package` in rascal-website project + - [ ] fix errors, possibly release rascal project patch versions, and repeat the above. + - [ ] release rascal-maven-project + - [ ] bump rascal-maven-project dependency in rascal-website project + - [ ] run `mvn clean package` in rascal-website project and `git push` to publish new docs +- [ ] release rascal-eclipse project (take care to choose the right release versions of typepal and rascal-core you release earlier and choose their new SNAPSHOT dependencies to the latest) +- [ ] change the configuration of the stable version in `update-site-nexus-link-script/refresh-nexus-data` to the released version +- [ ] test the stable update site at https://update.rascal-mpl.org/stable +- [ ] write release notes and publish on the usethesource.io blog + +# Downstream implications + +The following items can be executed asynchronously, but are nevertheless not to be forgotten: + +- [ ] change dependencies on rascal-eclipse and rascal in rascal-eclipse-libraries and the projects it depends on +- [ ] change dependencies of typepal to latest rascal and rascal-eclipse +- [ ] change dependency of rascal-core to latest stable rascal +- [ ] change dependency in all projects on new rascal-maven-project +- [ ] change dependency of rascal-maven-project and rascal in rascal-tutor +- [ ] release rascal-tutor +- [ ] bump dependency of rascal-tutor in rascal-maven-project +- [ ] release rascal-maven-project again diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000000..1fb8ea3326c --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,233 @@ +name: Build and Deploy +on: + push: + branches: + - main + tags: + - 'v[0-9]+.*' + pull_request: + branches: + - main + - 'feat/*' +env: + MAVEN_OPTS: "-Xmx4G -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + IS_OWN_PR: "${{ secrets.MAVEN_MIRROR_URL }}" + +jobs: + test-linux: + if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }} + runs-on: ubicloud-standard-4 + steps: + - uses: actions/checkout@v4 + + - uses: s4u/maven-settings-action@v3.1.0 + if: ${{ env.IS_OWN_PR != '' }} + with: + servers: '[{"id": "usethesource-gh", "username":"github", "password": "${{ secrets.MAVEN_MIRROR_PASSWORD }}"}]' + mirrors: '[{"id": "usethesource-gh", "name": "uts mirror", "mirrorOf": "usethesource", "url": "${{ secrets.MAVEN_MIRROR_URL }}"}]' + - uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'temurin' + cache: 'maven' + overwrite-settings: false + - name: Run Tests + run: mvn -B -Drascal.compile.skip -Drascal.tutor.skip -Drascal.test.memory=14 test + + - uses: codecov/codecov-action@v4 + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + with: + fail_ci_if_error: false + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Publish Test Report on github action + if: ${{ always() && github.event_name != 'pull_request' }} # to bad this doesn't work nicely with external pull requests + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + uses: scacap/action-surefire-report@v1 + with: + check_name: "Test Report - ${{ runner.os }}" + + builds: + if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }} + needs: [test-linux] + permissions: + contents: write + runs-on: ubicloud-standard-4 + environment: ${{ startsWith(github.ref, 'refs/tags/v') && 'deployment' || '' }} + steps: + - uses: browser-actions/setup-chrome@latest + with: + chrome-version: 1047731 # v107 + - run: which chrome + - uses: nanasess/setup-chromedriver@v2 + with: + chromedriver-version: '107.0.5304.62' + - run: which chromedriver + + - uses: s4u/maven-settings-action@v3.1.0 + if: ${{ env.IS_OWN_PR != '' }} + with: + servers: '[{"id": "usethesource-gh", "username":"github", "password": "${{ secrets.MAVEN_MIRROR_PASSWORD }}"}]' + mirrors: '[{"id": "usethesource-gh", "name": "uts mirror", "mirrorOf": "usethesource", "url": "${{ secrets.MAVEN_MIRROR_URL }}"}]' + + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'temurin' + cache: 'maven' + overwrite-settings: false + + + - name: Compile & Bootstrap + run: mvn -B compile -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -Dwebdriver.chrome.browser=`which chrome` + env: + MAVEN_OPTS: "-Xmx14G -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + + - name: Test if release # just to be extra sure for a release + if: startsWith(github.ref, 'refs/tags/v') + run: mvn -Drascal.test.memory=14 -Drascal.compile.skip -Drascal.tutor.skip test + + - name: Attach artifact + id: build-artifact + uses: SWAT-engineering/maven-full-artifacts-action@v1 + with: + maven-options: | + -Drascal.compile.skip + -Drascal.tutor.skip + -DskipTests + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + + - name: Making sure test have succeeded in the parallel jobs + if: startsWith(github.ref, 'refs/tags/') + uses: yogeshlonkar/wait-for-jobs@v0 + with: + gh-token: ${{ secrets.GITHUB_TOKEN }} + jobs: | + tests (macos-latest) + tests (windows-latest) + ttl: 15 + + - name: Deploy + if: startsWith(github.ref, 'refs/tags/v') + uses: usethesource/releases-maven-action@v1 + with: + maven-username: ${{ secrets.RELEASE_MAVEN_USERNAME }} + maven-password: ${{ secrets.RELEASE_MAVEN_PASSWORD }} + maven-local-port: ${{ secrets.RELEASE_MAVEN_LOCAL_PORT }} + ssh-hostname: ${{ secrets.RELEASE_SSH_SERVER }} + ssh-known-host: ${{ secrets.RELEASE_SSH_KNOWN_HOSTS }} + ssh-username: ${{ secrets.RELEASE_SSH_USERNAME }} + ssh-private-key: ${{ secrets.RELEASE_SSH_PRIVATE_KEY }} + + - name: Prepare Draft Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + files: ${{ steps.build-artifact.outputs.artifact-root-dir}}/**/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +# - name: prepare-unshaded +# if: startsWith(github.ref, 'refs/tags/') +# run: sed -i 's#rascal#rascal-unshaded#' pom.xml +# +# - name: Deploy unshaded jar +# if: startsWith(github.ref, 'refs/tags/v') +# uses: usethesource/releases-maven-action@v1 +# with: +# maven-username: ${{ secrets.RELEASE_MAVEN_USERNAME }} +# maven-password: ${{ secrets.RELEASE_MAVEN_PASSWORD }} +# maven-local-port: ${{ secrets.RELEASE_MAVEN_LOCAL_PORT }} +# ssh-hostname: ${{ secrets.RELEASE_SSH_SERVER }} +# ssh-known-host: ${{ secrets.RELEASE_SSH_KNOWN_HOSTS }} +# ssh-username: ${{ secrets.RELEASE_SSH_USERNAME }} +# ssh-private-key: ${{ secrets.RELEASE_SSH_PRIVATE_KEY }} +# maven-options: -Punshaded -Drascal.compile.skip -Drascal.tutor.skip -DskipTests +# + tests: + if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }} + needs: [test-linux] + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [windows-latest, macos-latest] + env: + MAVEN_OPTS: "-Xmx512M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + steps: + - uses: actions/checkout@v4 + + - uses: s4u/maven-settings-action@v3.1.0 + if: ${{ env.IS_OWN_PR != '' }} + with: + servers: '[{"id": "usethesource-gh", "username":"github", "password": "${{ secrets.MAVEN_MIRROR_PASSWORD }}"}]' + mirrors: '[{"id": "usethesource-gh", "name": "uts mirror", "mirrorOf": "usethesource", "url": "${{ secrets.MAVEN_MIRROR_URL }}"}]' + - uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'temurin' + cache: 'maven' + overwrite-settings: false + + - name: Run Tests + # single quotes to help windows deal with argument splitting + run: mvn -B '-Drascal.compile.skip' '-Drascal.tutor.skip' '-Drascal.test.memory=2' test + + - uses: codecov/codecov-action@v4 + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + with: + token: e8b4481a-d178-4148-a4ff-502906390512 + + - name: Publish Test Report on github action + if: ${{ always() && github.event_name != 'pull_request' }} # to bad this doesn't work nicely with external pull requests + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + uses: scacap/action-surefire-report@v1 + with: + check_name: "Test Report - ${{ runner.os }}" + + compiler-tests: + if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }} + needs: [test-linux] + runs-on: ubicloud-standard-4 + env: + MAVEN_OPTS: "-Xmx512M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + steps: + - uses: actions/checkout@v4 + + - uses: s4u/maven-settings-action@v3.1.0 + if: ${{ env.IS_OWN_PR != '' }} + with: + servers: '[{"id": "usethesource-gh", "username":"github", "password": "${{ secrets.MAVEN_MIRROR_PASSWORD }}"}]' + mirrors: '[{"id": "usethesource-gh", "name": "uts mirror", "mirrorOf": "usethesource", "url": "${{ secrets.MAVEN_MIRROR_URL }}"}]' + - uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'temurin' + cache: 'maven' + overwrite-settings: false + + - name: Retrieve dependencies for integration tests + run: bash src/org/rascalmpl/compiler/lang/rascalcore/check/tests/download-test-jars.sh + + - name: Run Tests + run: mvn -B -Pcompiler-tests -Drascal.compile.skip -Drascal.tutor.skip -Drascal.test.memory=10 test + + - uses: codecov/codecov-action@v4 + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + with: + fail_ci_if_error: false + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Publish Test Report on github action + if: ${{ always() && github.event_name != 'pull_request' }} # to bad this doesn't work nicely with external pull requests + continue-on-error: true # sometimes this one fails, that shouldn't stop a build + uses: scacap/action-surefire-report@v1 + with: + check_name: "Compiler Test Report" + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..932f9c86198 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# eclipse stuff +.project +.metadata +.settings +.classpath +bin/** +tmp/** +tmp/**/* +**/*.rvm +*.tmp +*.bak +*.swp +*~.nib +local.properties +.loadpath + +# maven stuff +target/ +bin/ +bootstrap/ +pom.xml.releaseBackup +release.properties +pom.xml.versionsBackup +rascal-DEPENDENCIES.txt + +.DS_Store +/.apt_generated/ + +dependency-reduced-pom.xml +.ipynb_checkpoints +__pycache__ +.vscode/settings.json + +*.iml +.idea/ diff --git a/.project b/.project new file mode 100644 index 00000000000..d15a1c02d98 --- /dev/null +++ b/.project @@ -0,0 +1,46 @@ + + + rascal + + + + + + org.eclipse.jdt.core.javabuilder + + + + + rascal_eclipse.rascal_builder + + + + + rascal_eclipse.tutor_builder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + rascal_eclipse.rascal_nature + rascal_eclipse.tutor_nature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + + + 1666611214669 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..c4fecf63d6a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +encoding//src/org/rascalmpl/library=UTF-8 +encoding//src/org/rascalmpl/library/experiments/vis2/lib/MarkdownConverter.js=UTF-8 +encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.css=UTF-8 +encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.js=UTF-8 +encoding//src/org/rascalmpl/library/experiments/vis2/lib/reset.css=UTF-8 +encoding//src/org/rascalmpl/library/lang/rascal/tests/functionality/DataType.rsc=UTF-8 +encoding//test/org/rascalmpl/test/data=UTF-8 +encoding/=UTF-8 +encoding/src=UTF-8 +encoding/test=UTF-8 +org.eclipse.jdt.core.compiler.processAnnotations=enabled diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..8d92d59ecbc --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,576 @@ +eclipse.preferences.version=1 +enableParallelJavaIndexSearch=true +org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= +org.eclipse.jdt.core.circularClasspath=warning +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.camelCaseMatch=enabled +org.eclipse.jdt.core.codeComplete.deprecationCheck=disabled +org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=disabled +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.forbiddenReferenceCheck=enabled +org.eclipse.jdt.core.codeComplete.forceImplicitQualification=disabled +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.codeComplete.subwordMatch=disabled +org.eclipse.jdt.core.codeComplete.suggestStaticImports=enabled +org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.lambda.genericSignature=do not generate +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate +org.eclipse.jdt.core.compiler.codegen.shareCommonFinallyBlocks=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.emulateJavacBug8031744=enabled +org.eclipse.jdt.core.compiler.generateClassFiles=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement=disabled +org.eclipse.jdt.core.compiler.problem.deprecation=ignore +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.tasks=warning +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.uninternedIdentityComparison=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeArgumentsForMethodInvocation=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.storeAnnotations=disabled +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX +org.eclipse.jdt.core.computeJavaBuildOrder=ignore +org.eclipse.jdt.core.encoding=utf8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=false +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=0 +org.eclipse.jdt.core.formatter.alignment_for_assignment=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow=0 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=0 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=true +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator=false +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter +org.eclipse.jdt.core.timeoutForParameterNameFromAttachedJavadoc=50 diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..40998fa0ee7 --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +formatter_profile=_GoogleStyle +formatter_settings_version=12 +org.eclipse.jdt.ui.javadoc=false +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/.settings/org.eclipse.pde.prefs b/.settings/org.eclipse.pde.prefs new file mode 100644 index 00000000000..62cfa90dee9 --- /dev/null +++ b/.settings/org.eclipse.pde.prefs @@ -0,0 +1,32 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=2 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..fa9529bef36 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,97 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "RascalCheck", + "request": "launch", + "mainClass": "org.rascalmpl.shell.RascalCheck", + "projectName": "rascal" + }, + { + "type": "java", + "name": "Launch DocRunner", + "request": "launch", + "mainClass": "org.rascalmpl.shell.DocRunner", + "projectName": "rascal" + }, + { + "type": "java", + "name": "Launch DoubleRightNullableWithPrefixSharing", + "request": "launch", + "mainClass": "org.rascalmpl.test.parser.DoubleRightNullableWithPrefixSharing", + "projectName": "rascal" + }, + { + "type": "java", + "name": "Launch Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Launch RascalShell", + "request": "launch", + "mainClass": "org.rascalmpl.shell.RascalShell", + "projectName": "rascal", + "vmArgs": "-Xss80m -Xmx2g -ea", + "console": "integratedTerminal" + }, + { + "type": "java", + "name": "Launch RascalShell Tutor", + "request": "launch", + "mainClass": "org.rascalmpl.shell.RascalShell", + "projectName": "rascal", + "cwd": "${workspaceFolder}/../rascal-tutor", + "vmArgs": "-Xss80m -Xmx2g -ea" + }, + { + "type": "java", + "name": "Attach RascalShell", + "request": "attach", + "projectName": "rascal", + "hostName": "localhost", + "port": 9001 + }, + { + "type": "java", + "name": "Attach Mvn Rascal", + "request": "attach", + "projectName": "rascal-maven-plugin", + "hostName": "localhost", + "port": 8000 + }, + { + "type": "java", + "name": "Attach Rascal LSP Terminal", + "request": "attach", + "projectName": "rascal-lsp", + "hostName": "localhost", + "port": 9871 + }, + { + "type": "java", + "name": "Attach RascalNotebook", + "request": "attach", + "hostName": "localhost", + "port": 8000, + "projectName": "rascal-notebook" + }, + { + "type": "java", + "name": "Launch RascalShell in rascal-core", + "request": "launch", + "mainClass": "org.rascalmpl.shell.RascalShell", + "vmArgs": "-ea", + "classPaths": [ + "/Users/jurgenv/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/jurgenv/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/jurgenv/.m2/repository/org/rascalmpl/rascal/0.19.3-SNAPSHOT/rascal-0.19.3-SNAPSHOT.jar:/Users/jurgenv/.m2/repository/org/rascalmpl/typepal/0.4.11-SNAPSHOT/typepal-0.4.11-SNAPSHOT.jar:/Users/jurgenv/.m2/repository/io/usethesource/vallang/0.13.0/vallang-0.13.0.jar:/Users/jurgenv/.m2/repository/io/usethesource/capsule/0.6.3/capsule-0.6.3.jar:/Users/jurgenv/.m2/repository/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar:/Users/jurgenv/.m2/repository/org/tukaani/xz/1.8/xz-1.8.jar:/Users/jurgenv/.m2/repository/com/github/luben/zstd-jni/1.4.5-2/zstd-jni-1.4.5-2.jar:/Users/jurgenv/.m2/repository/com/github/ben-manes/caffeine/caffeine/2.8.8/caffeine-2.8.8.jar:/Users/jurgenv/.m2/repository/com/google/errorprone/error_prone_annotations/2.4.0/error_prone_annotations-2.4.0.jar:/Users/jurgenv/.m2/repository/org/checkerframework/checker-qual/2.9.0/checker-qual-2.9.0.jar" + ], + "projectName": "rascal", + "cwd": "${workspaceFolder}/../rascal-core" + } + ] +} diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000000..d938637046f --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,67 @@ +The main authors of the Rascal project are: +* Jurgen J. Vinju +* Paul Klint +* Tijs van der Storm +* Davy Landman +* Arnold Lankamp + +And this is a complete list of contributors ordered by the amount of commits: +* Anastasia Izmaylova +* Pieter Olivier +* Mark Hills +* Tijs van der Storm +* Atze van der Ploeg +* Rodin Aarssen +* Bert Lisser +* Ashim Shahi +* Michael Steindorfer +* Ali Afroozeh +* Ferry Rietveld +* Emilie Balland +* Bert Lisser +* Anya Helene Bagge +* Mauricio Verano Merino +* Jouke Stoel +* Lina Maria Ochoa Venegas +* Jasper Timmer +* Bas Basten +* Riemer van Rozen +* Sung-Shik Jongmans +* Wietse Venema +* Vadim Zaytsev +* Jeroen van den Bos +* Pieter Olivier +* Linus Wagner +* Joppe Kroon +* Pablo Inostroza Valdera +* Thomas Degueule +* Aiko Yamashita +* Toine Hartman +* Cindy Berghuizen +* Michael Godfrey +* Jeroen Peeters +* Athanasios Anastasiou +* Davy Meers +* Kevin van der Vlist +* Yoan-Alexander Grigorov +* Romain Briand +* Cleverton Hentz +* Magiel Bruntink +* Mike Bierlee +* Pieter Hijma +* Simon Baars +* Tim Soethout +* Waruzjan Shahbazian +* Yi Dai +* Arjo Bruijnes +* Auke Roorda +* Diego Marcílio +* Jimi van der Woning +* Jonathan Leitschuh +* Markus Klinik +* Mary Gouseti +* Mathijs Schuts +* Mats Stijlaart +* Nick Lodewijks +* Rodrigo Bonifácio +* Todd Hooper diff --git a/CITATION.md b/CITATION.md new file mode 100644 index 00000000000..c7b558878e6 --- /dev/null +++ b/CITATION.md @@ -0,0 +1,50 @@ + + +# General Language Reference + +You {c,sh,w}ould cite this if: + * you extended Rascal itself and publish about this + * you used Rascal as a component of your research method + * you used Rascal to implement an industrial software project and you wish to credit it + + +``` +@inproceedings{RascalGTTSE, + title = {EASY Meta-Programming with Rascal. Leveraging the Extract-Analyze-SYnthesize Paradigm for Meta-Programming}, + author = {Paul Klint and Tijs van der Storm and Jurgen J. Vinju}, + year = {2010}, + booktitle = {Proceedings of the 3rd International Summer School on Generative and Transformational Techniques in Software Engineering (GTTSE'09)}, + location = {Braga, Portugal}, + series = {LNCS}, + publisher = {Springer}, +} +``` + +# Software Analysis and Transformation (Refactoring) + +You {c,sh,w}ould cite this if: + * you are working on related work want to position w.r.t. Rascal's features + * you used Rascal as a component of your own tool + +``` +@inproceedings{rascal, + Author = {Paul Klint and Tijs van der Storm and Jurgen J. Vinju}, + Title = {RASCAL: A Domain Specific Language for Source Code Analysis and Manipulation}, + Booktitle = {Ninth IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM)}, + Doi = {http://doi.ieeecomputersociety.org/10.1109/SCAM.2009.28}, + Pages = {168-177}, + Publisher = {IEEE Computer Society}, + Year = {2009}, +} +``` + +# Specific Releases + +Here some citable zenodo snapshots, which you could cite instead of the above papers. The difference is you credit more the implementation of +the work than the conceptual contribution of Rascal. It's up to you. The author lists are different necessarily. So if you depend on a particular +piece of work inside Rascal authored by somebody who is not an author of the above papers, then this might have your preference. + +* https://zenodo.org/record/7595297 + + + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000000..7f265584171 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +/.github/ @DavyLandman diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..8650a62895b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ + +Please refer to http://usethesource.io/about/values.html for the origin of this text. This text +includes our Code of Conduct, which offers our basic social values, but first it lists a number of community values specific to meta programming and open-source software development. + +## Main Principles + +These are principles that we strive to uphold in the UseTheSource community. + +* Metaprogramming, software language engineering and generic programming are cool +* "real world" application (not just toy languages and toy examples) +* Striving for good design + * design code for readability: clear and simple code + * design for all programmers/users: clear and simple languages, API and UX + * avoid over-design, gold-plating and premature optimization +* Proper attribution + * open copyright licenses + * clear authorship/ownership trace + * clear funding/sponsorship trace + * due diligence with reuse of open-source +* Excellence + * generic & simple + * efficient & scalable + * accurate & correct + * continuously tested & delivered +* Social + * patience with both users and contributors + * open to feedback + * responsive + * visibly active + +## Contributor Code of Conduct + +As Contributors of the UseTheSource community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. + +We are committed to making participation in this community a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. + +Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. + +[Project Owners](http://www.usethesource.io/about/processes.html) have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Contributors who do not follow the Code of Conduct may be removed from the project team. + +This code of conduct applies both within project spaces and in public spaces when an individual is representing the UseTheSource community or one of its projects. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [opening an issue](https://github.com/usethesource/usethesource.github.io/issues) or contacting one or more of the [Project Owners](http://www.usethesource.io/projects/). + +This Code of Conduct is adapted from the Contributor Covenant, version 1.1.0, available from + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..4d1e158d384 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +Thanks for your interest in the Rascal MPL project! + +Rascal is a (meta) programming language with the following features: + +1. type-checker, +2. interpreter that type-checks, +3. compiler +4. standard library +4. parser generator +4. top-down context-free general parsing algorithm +4. hash-trie based implementation of relational calculus (via [capsule](https://github.com/usethesource/capsule)) +4. immutable values (sets, lists, numbers, maps, algebraic data-types), via [vallang](https://github.com/usethesource/vallang) +5. REPL +6. Eclipse IDE with IDE generator based on Eclipse IMP (see https://github.com/usethesource/rascal-eclipse) +7. VScode IDE with IDE generator based on LSP (see https://github.com/cwi-swat/rascal-vscode) +8. Interactive documentation (tutor) compiler +8. Interactive documentation content +8. Libraries for + * Java analysis + * C++ analysis + * PHP analysis + * Python analysis + * Javascript analysis + * HTML5-based UI implementations (salix library) + * Git analysis + * etc. + + +Contributing to libraries or the standard library is preferred over contributions to the core implementation features since +features in the core are tangled and therefore complex. We do have a lot of tests, so if you plan to contribute a bug-fix or +a new feature don't forget to run `mvn test`. If you are a parser, type-checking, or functional programming/term-rewriting expert, +please do not hesitate to give us feedback or suggestions, we love those topics and it's always good to talk to a fellow +enthusiast and learn something new. + +If you'd like to contribute a new library or library function do not hesitate to contact us: open an enhancement or bug issue +[here](https://github.com/usethesource/rascal/issues) and we can start discussing the ins and outs of your idea! Also +we'd be able to help out; you don't have to do it all alone. + diff --git a/FUNDING b/FUNDING new file mode 100644 index 00000000000..81220d2268d --- /dev/null +++ b/FUNDING @@ -0,0 +1,17 @@ +### Current funding + +* Centrum Wiskunde & Informatica, SWAT group (2009-...) +* Swat.engineering BV (2017..) +* GitHub donations (including anonymous donors) + +### Past funding + +* Universiteit van Amsterdam, Vrije Universiteit en Hogeschool van Amsterdam "Master Software Engineering", for courses in Sofware Construction and Software Evolution (2009-2013) +* EU FP7 OSSMETER Project Number **318736** (2012-2015) +* EU H2020 CROSSMINER Project Number **REP-732223-2** (2016-2019) +* NWO Big Software "MERITS" **NWO.628.008.002** (2016-2020) +* NWO TOPGO "Domain-Specific Languages: A Big Future for Small Programs" **NWO.612.001.011** (2011-2016) +* OU (Open Universiteit) support for courses in Software Quality Assurance (2012-2017) +* SIA RAAK-PRO "EQuA: Early Quality Assurance for Software Production" (2011-2015) +* SIA RAAK-MKB "Automated Game Design" (2014-2016) +* SIA RAAK-MKB "Live Game Design" (2016-2019) diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..411ebf6a590 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +This whole project is released under the BSD-2 simplified clause, with the noted exception that a number of older files still have an Eclipse license. + +----BSD license---- +Copyright (c) 2022, NWO-I Centrum Wiskunde & Informatica (CWI) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +----Eclipse v1 license---- + +Copyright (c) 2012-2022 CWI +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html diff --git a/META-INF/RASCAL.MF b/META-INF/RASCAL.MF new file mode 100644 index 00000000000..875f75774d6 --- /dev/null +++ b/META-INF/RASCAL.MF @@ -0,0 +1,2 @@ +Project-Name: rascal +Source: src/org/rascalmpl/library,src/org/rascalmpl/compiler,src/org/rascalmpl/library,src/org/rascalmpl/tutor,test/org/rascalmpl/benchmark,test/org/rascalmpl/test/data diff --git a/README.md b/README.md new file mode 100644 index 00000000000..928d471d171 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Rascal - Metaprogramming Language +[![Build and Deploy](https://github.com/usethesource/rascal/actions/workflows/build.yaml/badge.svg)](https://github.com/usethesource/rascal/actions/workflows/build.yaml) + +This is the core implementation of the Rascal meta-programming language. It contains the interpreter, the parser generator, the parser run-time, +the (documented) standard library, the type checker, the compiler, and the documentation compiler ("tutor"). + +Other relevant repositories: + +* https://github.com/usethesource/rascal-language-servers - for the Rascal's IDE features +* https://github.com/usethesource/rascal-maven-plugin - for Rascal via Maven commands +* https://github.com/usethesource/rascal-website - for the online documentation +* https://github.com/usethesource/vallang - for the core of the Rascal runtime values, types and IO. + +Please visit http://www.rascal-mpl.org for all information regarding Rascal. + +For questions use the [rascal tag on StackOverflow](http://stackoverflow.com/questions/tagged/rascal). diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..f6b71401137 --- /dev/null +++ b/pom.xml @@ -0,0 +1,665 @@ + + 4.0.0 + + org.rascalmpl + rascal + 0.42.2-RC2-SNAPSHOT + jar + + + scm:git:ssh://git@github.com/usethesource/rascal.git + v0.42.0-RC1-BOOT + + + + + + usethesource + https://releases.usethesource.io/maven/ + + + + + usethesource + https://releases.usethesource.io/maven/ + + + + + + UTF-8 + 3.9.12 + org.rascalmpl.shell.RascalShell + 3 + 11 + 0.30.7 + 3.29.0 + + + + + BSD-2-Clause + https://opensource.org/license/BSD-2-Clause + repo + + Note, some older files are still licensed under Eclipse v1 + + + + + + src + + + src + + **/*.java + **/*.class + + + + . + false + + META-INF/RASCAL.MF + rascal-DEPENDENCIES.txt + + + + ${project.build.directory}/generated-resources + + + test + + + test + + **/*.java + **/*.class + + + + test/org/rascalmpl/test/data/ + + + src/org/rascalmpl/library/ + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 3.2.1 + + + validate + + create + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + -parameters + + + + org.rascalmpl + rascal-maven-plugin + ${rascal-maven.version} + + 0.42.0 + true + +
${project.basedir}/src/org/rascalmpl/library/Prelude.rsc
+
+
+ + + default-compile + compile + + compile + + + true + +
${project.basedir}/src/org/rascalmpl/library/Prelude.rsc
+
+ false + ${project.build.outputDirectory} + + ${project.basedir}/src/org/rascalmpl/library + + + + + ${project.basedir}/src/org/rascalmpl/library/experiments + ${project.basedir}/src/org/rascalmpl/library/resource + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/tests + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/grammar/tests + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/syntax/tests + +
+
+ + default-resources + compile + + tutor + + + false + false + ${project.build.outputDirectory} + ${project.basedir}/FUNDING + ${project.basedir}/CITATION.md + ${project.basedir}/LICENSE + ${project.basedir}/AUTHORS.md + |http://github.com/usethesource/rascal/blob/main| + |http://github.com/usethesource/rascal/issues| + ${project.version} + + ${project.basedir}/src/org/rascalmpl/library + + + ${project.basedir}/src/org/rascalmpl/library/lang/rascal + ${project.basedir}/src/org/rascalmpl/library/experiments + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/tests + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/grammar/tests + ${project.basedir}/src/org/rascalmpl/library/lang/rascal/syntax/tests + + + + + default-package + prepare-package + + package + + + + ${project.basedir}/src/org/rascalmpl/library + + |std:///| + + +
+
+ + maven-clean-plugin + 3.4.0 + + + + ${project.basedir}/bin + + **/*.* + + false + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.2 + + + default-test + test + + test + + + + + + -ea + -Xmx${rascal.test.memory}G + -Dfile.encoding=UTF-8 + ${argLine} + + + **/org/rascalmpl/test/AllSuiteParallel.java + **/org/rascalmpl/test/library/LibraryLangPaths.java + **/org/rascalmpl/test/value/AllTests.java + **/org/rascalmpl/test/repl/*Test.java + **/org/rascalmpl/test/rpc/*Tests.java + **/org/rascalmpl/util/**/*Test.java + **/org/rascalmpl/util/**/*Tests.java + **/org/rascalmpl/uri/**/*Test.java + **/org/rascalmpl/*Test.java + + + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + + prepare-agent + + + + report + test + + report + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.8.1 + + + + tree + + package + + rascal-DEPENDENCIES.txt + + + + + + org.apache.maven.plugins + maven-release-plugin + 3.1.1 + + v@{project.version} + -Drascal.compile.skip -Drascal.tutor.skip -DskipTests + + + + org.codehaus.mojo + license-maven-plugin + 2.5.0 + + + download-licenses + + download-licenses + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + org.apache.logging.log4j + log4j-transform-maven-shade-plugin-extensions + 0.2.0 + + + + + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + plugin.xml + + + + org.rascalmpl:typepal + + META-INF/* + examples/** + src/examples/** + src/analysis/typepal/** + docs/Packages/Typepal/** + docs/** + rascal/analysis/typepal/** + **/*.tpl + + + + + + analysis/typepal + org/rascalmpl/typepal/analysis/typepal + + + + + + + + rascal + true + org.rascalmpl.shell.RascalShell + ${project.version} + http://www.usethesource.io + + + + org/rascalmpl/uri/resolvers.config + + + io/usethesource/vallang/type/types.config + + + META-INF/sisu/javax.inject.Named + + + + + false + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce-maven + + enforce + + + + + (3.8,) + + + + + + +
+ + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.mojo + + + exec-maven-plugin + + + [1.4.0,) + + + exec + + + + + + + + + + + + +
+ + + + + org.rascalmpl + typepal + 0.16.6-RC2 + + compile + + + + + junit + junit + 4.13.2 + + + io.usethesource + vallang + 1.0.1-RC1 + + + org.apache.commons + commons-math + 2.2 + + + org.apache.commons + commons-compress + 1.28.0 + + + com.github.luben + zstd-jni + 1.5.7-6 + + + org.tukaani + xz + 1.11 + + + commons-codec + commons-codec + 1.20.0 + + + com.google.code.gson + gson + 2.13.2 + + + org.jline + jline-reader + ${jline.version} + + + org.jline + jline-terminal + ${jline.version} + + + org.jline + jline-terminal-jni + ${jline.version} + + + org.jline + jline-style + ${jline.version} + + + org.jline + jline-console + ${jline.version} + + + org.jline + jansi-core + ${jline.version} + + + org.yaml + snakeyaml + 2.5 + + + org.jsoup + jsoup + 1.21.2 + + + org.jdom + jdom2 + 2.0.6.1 + + + org.nanohttpd + nanohttpd + 2.3.1 + + + com.ibm.icu + icu4j + 78.1 + + + org.apache.maven + maven-model + ${maven-version} + + + org.apache.maven + maven-model-builder + ${maven-version} + + + org.eclipse.sisu + org.eclipse.sisu.inject + + + + + org.apache.maven + maven-repository-metadata + ${maven-version} + + + org.apache.maven + maven-settings + ${maven-version} + + + engineering.swat + java-watch + 0.9.6 + + + org.eclipse.lsp4j + org.eclipse.lsp4j.debug + 0.24.0 + + + + + + compiler-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + + default-testnone + + test-compiler-tests + test + + test + + + + + + -Xmx${rascal.test.memory}G + -Dfile.encoding=UTF-8 + + + + **/org/rascalmpl/compiler/**/*Tests.java + **/org/rascalmpl/compiler/**/*Test.java + + + + + + + +
diff --git a/src/io/usethesource/vallang/type/types.config b/src/io/usethesource/vallang/type/types.config new file mode 100644 index 00000000000..456d7c9b25e --- /dev/null +++ b/src/io/usethesource/vallang/type/types.config @@ -0,0 +1,2 @@ +org.rascalmpl.types.NonTerminalType$Reifier +org.rascalmpl.types.ReifiedType$Reifier diff --git a/src/org/rascalmpl/ast/AbstractAST.java b/src/org/rascalmpl/ast/AbstractAST.java new file mode 100644 index 00000000000..b5955ecf515 --- /dev/null +++ b/src/org/rascalmpl/ast/AbstractAST.java @@ -0,0 +1,235 @@ +/******************************************************************************* + * Copyright (c) 2009-2013 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI +*******************************************************************************/ +package org.rascalmpl.ast; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +import org.rascalmpl.exceptions.ImplementationError; +import org.rascalmpl.exceptions.Throw; +import org.rascalmpl.interpreter.AssignableEvaluator; +import org.rascalmpl.interpreter.IEvaluator; +import org.rascalmpl.interpreter.IEvaluatorContext; +import org.rascalmpl.interpreter.asserts.NotYetImplemented; +import org.rascalmpl.interpreter.env.Environment; +import org.rascalmpl.interpreter.matching.IBooleanResult; +import org.rascalmpl.interpreter.matching.IMatchingResult; +import org.rascalmpl.interpreter.result.Result; +import org.rascalmpl.interpreter.result.ResultFactory; +import org.rascalmpl.interpreter.staticErrors.UnsupportedPattern; +import org.rascalmpl.types.RascalTypeFactory; +import org.rascalmpl.values.IRascalValueFactory; + +import io.usethesource.vallang.IBool; +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; +import io.usethesource.vallang.IValue; +import io.usethesource.vallang.type.Type; +import io.usethesource.vallang.type.TypeFactory; + +public abstract class AbstractAST implements IVisitable, Cloneable { + protected static final TypeFactory TF = TypeFactory.getInstance(); + protected static final RascalTypeFactory RTF = RascalTypeFactory.getInstance(); + protected static final IRascalValueFactory VF = IRascalValueFactory.getInstance(); + protected ISourceLocation src; + + AbstractAST(ISourceLocation src) { + this.src = src; + } + + /** + * @return a non-terminal type for ASTs which represent concrete syntax patterns or null otherwise + */ + public Type getConcreteSyntaxType() { + return null; + } + + @Override + public abstract Object clone(); + + @SuppressWarnings("unchecked") + /** + * Used in generated clone methods to avoid case distinctions in the code generator + */ + protected T clone(T in) { + if (in == null) { + return null; + } + return (T) in.clone(); + } + + @SuppressWarnings("unchecked") + /** + * Used in generated clone methods to avoid regenerating the same code; + */ + public java.util.List clone(java.util.List in) { + java.util.List tmp = new ArrayList(in.size()); + for (T elem : in) { + tmp.add((T) elem.clone()); + } + return tmp; + } + + /** + * Used in clone and AST Builder + */ + @SuppressWarnings("unchecked") + public static T newInstance(java.lang.Class clazz, Object... args) { + try { + Constructor cons = clazz.getConstructors()[0]; + cons.setAccessible(true); + return (T) cons.newInstance(args); + } + catch (ClassCastException | ArrayIndexOutOfBoundsException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new ImplementationError("Can not instantiate AST object for " + clazz.getName(), e); + } + } + + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset + && offset < src.getOffset() + src.getLength()) { + return this; + } + + return null; + } + + public static Result makeResult(Type declaredType, IValue value, IEvaluatorContext ctx) { + return ResultFactory.makeResult(declaredType, value, ctx); + } + + public static Result nothing() { + return org.rascalmpl.interpreter.result.ResultFactory.nothing(); + } + + public T accept(IASTVisitor v) { + return null; + } + + public ISourceLocation getLocation() { + return src; + } + + @Override + public boolean equals(Object obj) { + throw new ImplementationError("Missing generated hashCode/equals methods"); + } + + @Deprecated + public IConstructor getTree() { + throw new NotYetImplemented(this); + } + + @Override + public int hashCode() { + throw new ImplementationError("Missing generated concrete hashCode/equals methods"); + } + + @Override + @Deprecated + /** + * @deprecated YOU SHOULD NOT USE THIS METHOD for user information. Use {@link Names}. + */ + public String toString() { + return "AST debug info: " + getClass().getName() + " at " + src; + } + + public Result interpret(IEvaluator> eval) { + throw new NotYetImplemented(this); + } + + public Result assignment(AssignableEvaluator eval) { + throw new NotYetImplemented(this); + } + + /** + * Computes internal type representations for type literals and patterns. + * @param instantiateTypeParameters TODO + */ + public Type typeOf(Environment env, IEvaluator> eval, boolean instantiateTypeParameters) { + throw new NotYetImplemented(this); + } + + public Type __evaluate(org.rascalmpl.interpreter.BasicTypeEvaluator eval) { + throw new NotYetImplemented(this); + } + + /** + * Recursively build a matching data-structure, use getMatcher if you are just a client of IMatchingResult. + * @param bindTypeParameters TODO + */ + public IMatchingResult buildMatcher(IEvaluatorContext eval, boolean bindTypeParameters) { + throw new UnsupportedPattern(toString(), this); + } + + public IMatchingResult getMatcher(IEvaluatorContext eval, boolean bindTypeParameters) { + return buildMatcher(eval, bindTypeParameters); + } + + protected void addForLineNumber(int line, java.util.List result) { + return; + } + + public List breakpoints(int line) { + List candidates = new LinkedList<>(); + addForLineNumber(line, candidates); + return candidates.stream().filter(p -> p.isBreakable()).collect(Collectors.toList()); + } + + /** + * Recursively build a back-tracking data-structure, use getBacktracker if you are just a client of IBooleanResult + */ + public IBooleanResult buildBacktracker(IEvaluatorContext eval) { + throw new NotYetImplemented(this); + } + + public IBooleanResult getBacktracker(IEvaluatorContext ctx) { + return buildBacktracker(ctx); + } + + /** + * If the debugger can suspend (i.e. break) before interpretation. + * @return true if suspension is supported, otherwise false + */ + public boolean isBreakable() { + return false; + } + + /** + * The debugger uses this to decide where to continue when you do "step-over". + * By default this is beyond the current statement, but for block statements + * we really want to go into the block (for example). + */ + public ISourceLocation getDebugStepScope() { + return getLocation(); + } + + public Result isDefined(IEvaluator> __eval) { + __eval.warning("INTERNAL WARNING: generic implementation of isDefined triggered", getLocation()); + try { + interpret(__eval); + return ResultFactory.makeResult(TF.boolType(), VF.bool(true), __eval); + } + catch (Throw e) { + return ResultFactory.makeResult(TF.boolType(), VF.bool(false), __eval); + } + } +} diff --git a/src/org/rascalmpl/ast/Assignable.java b/src/org/rascalmpl/ast/Assignable.java new file mode 100644 index 00000000000..4920dfa5ce3 --- /dev/null +++ b/src/org/rascalmpl/ast/Assignable.java @@ -0,0 +1,1058 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Assignable extends AbstractAST { + public Assignable(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasArguments() { + return false; + } + + public java.util.List getArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElements() { + return false; + } + + public java.util.List getElements() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasArg() { + return false; + } + + public org.rascalmpl.ast.Assignable getArg() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasReceiver() { + return false; + } + + public org.rascalmpl.ast.Assignable getReceiver() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDefaultExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getDefaultExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSecond() { + return false; + } + + public org.rascalmpl.ast.Expression getSecond() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSubscript() { + return false; + } + + public org.rascalmpl.ast.Expression getSubscript() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasAnnotation() { + return false; + } + + public org.rascalmpl.ast.Name getAnnotation() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasField() { + return false; + } + + public org.rascalmpl.ast.Name getField() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptFirst() { + return false; + } + + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptLast() { + return false; + } + + public org.rascalmpl.ast.OptionalExpression getOptLast() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasQualifiedName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getQualifiedName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAnnotation() { + return false; + } + + static public class Annotation extends Assignable { + // Production: sig("Annotation",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.Name","annotation")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.Name annotation; + + public Annotation(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.Name annotation) { + super(src, node); + + this.receiver = receiver; + this.annotation = annotation; + } + + @Override + public boolean isAnnotation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableAnnotation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = annotation.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + annotation.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Annotation)) { + return false; + } + Annotation tmp = (Annotation) o; + return true && tmp.receiver.equals(this.receiver) && tmp.annotation.equals(this.annotation) ; + } + + @Override + public int hashCode() { + return 233 + 383 * receiver.hashCode() + 227 * annotation.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.Name getAnnotation() { + return this.annotation; + } + + @Override + public boolean hasAnnotation() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(annotation)); + } + + } + public boolean isBracket() { + return false; + } + + static public class Bracket extends Assignable { + // Production: sig("Bracket",[arg("org.rascalmpl.ast.Assignable","arg")],breakable=false) + + + private final org.rascalmpl.ast.Assignable arg; + + public Bracket(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable arg) { + super(src, node); + + this.arg = arg; + } + + @Override + public boolean isBracket() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableBracket(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = arg.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + arg.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bracket)) { + return false; + } + Bracket tmp = (Bracket) o; + return true && tmp.arg.equals(this.arg) ; + } + + @Override + public int hashCode() { + return 977 + 797 * arg.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getArg() { + return this.arg; + } + + @Override + public boolean hasArg() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(arg)); + } + + } + public boolean isConstructor() { + return false; + } + + static public class Constructor extends Assignable { + // Production: sig("Constructor",[arg("org.rascalmpl.ast.Name","name"),arg("java.util.List\","arguments")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final java.util.List arguments; + + public Constructor(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, java.util.List arguments) { + super(src, node); + + this.name = name; + this.arguments = arguments; + } + + @Override + public boolean isConstructor() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableConstructor(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : arguments) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Constructor)) { + return false; + } + Constructor tmp = (Constructor) o; + return true && tmp.name.equals(this.name) && tmp.arguments.equals(this.arguments) ; + } + + @Override + public int hashCode() { + return 601 + 619 * name.hashCode() + 167 * arguments.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getArguments() { + return this.arguments; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(arguments)); + } + + } + public boolean isFieldAccess() { + return false; + } + + static public class FieldAccess extends Assignable { + // Production: sig("FieldAccess",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.Name","field")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.Name field; + + public FieldAccess(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.Name field) { + super(src, node); + + this.receiver = receiver; + this.field = field; + } + + @Override + public boolean isFieldAccess() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableFieldAccess(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = field.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + field.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FieldAccess)) { + return false; + } + FieldAccess tmp = (FieldAccess) o; + return true && tmp.receiver.equals(this.receiver) && tmp.field.equals(this.field) ; + } + + @Override + public int hashCode() { + return 263 + 557 * receiver.hashCode() + 167 * field.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.Name getField() { + return this.field; + } + + @Override + public boolean hasField() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(field)); + } + + } + public boolean isIfDefinedOrDefault() { + return false; + } + + static public class IfDefinedOrDefault extends Assignable { + // Production: sig("IfDefinedOrDefault",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.Expression","defaultExpression")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.Expression defaultExpression; + + public IfDefinedOrDefault(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.Expression defaultExpression) { + super(src, node); + + this.receiver = receiver; + this.defaultExpression = defaultExpression; + } + + @Override + public boolean isIfDefinedOrDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableIfDefinedOrDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = defaultExpression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + defaultExpression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfDefinedOrDefault)) { + return false; + } + IfDefinedOrDefault tmp = (IfDefinedOrDefault) o; + return true && tmp.receiver.equals(this.receiver) && tmp.defaultExpression.equals(this.defaultExpression) ; + } + + @Override + public int hashCode() { + return 937 + 439 * receiver.hashCode() + 439 * defaultExpression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getDefaultExpression() { + return this.defaultExpression; + } + + @Override + public boolean hasDefaultExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(defaultExpression)); + } + + } + public boolean isSlice() { + return false; + } + + static public class Slice extends Assignable { + // Production: sig("Slice",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.OptionalExpression","optFirst"),arg("org.rascalmpl.ast.OptionalExpression","optLast")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.OptionalExpression optFirst; + private final org.rascalmpl.ast.OptionalExpression optLast; + + public Slice(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.OptionalExpression optFirst, org.rascalmpl.ast.OptionalExpression optLast) { + super(src, node); + + this.receiver = receiver; + this.optFirst = optFirst; + this.optLast = optLast; + } + + @Override + public boolean isSlice() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableSlice(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optFirst.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optFirst.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optLast.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optLast.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Slice)) { + return false; + } + Slice tmp = (Slice) o; + return true && tmp.receiver.equals(this.receiver) && tmp.optFirst.equals(this.optFirst) && tmp.optLast.equals(this.optLast) ; + } + + @Override + public int hashCode() { + return 487 + 419 * receiver.hashCode() + 2 * optFirst.hashCode() + 797 * optLast.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + return this.optFirst; + } + + @Override + public boolean hasOptFirst() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptLast() { + return this.optLast; + } + + @Override + public boolean hasOptLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(optFirst), clone(optLast)); + } + + } + public boolean isSliceStep() { + return false; + } + + static public class SliceStep extends Assignable { + // Production: sig("SliceStep",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.OptionalExpression","optFirst"),arg("org.rascalmpl.ast.Expression","second"),arg("org.rascalmpl.ast.OptionalExpression","optLast")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.OptionalExpression optFirst; + private final org.rascalmpl.ast.Expression second; + private final org.rascalmpl.ast.OptionalExpression optLast; + + public SliceStep(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.OptionalExpression optFirst, org.rascalmpl.ast.Expression second, org.rascalmpl.ast.OptionalExpression optLast) { + super(src, node); + + this.receiver = receiver; + this.optFirst = optFirst; + this.second = second; + this.optLast = optLast; + } + + @Override + public boolean isSliceStep() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableSliceStep(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optFirst.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optFirst.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = second.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + second.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optLast.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optLast.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SliceStep)) { + return false; + } + SliceStep tmp = (SliceStep) o; + return true && tmp.receiver.equals(this.receiver) && tmp.optFirst.equals(this.optFirst) && tmp.second.equals(this.second) && tmp.optLast.equals(this.optLast) ; + } + + @Override + public int hashCode() { + return 19 + 317 * receiver.hashCode() + 883 * optFirst.hashCode() + 719 * second.hashCode() + 233 * optLast.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + return this.optFirst; + } + + @Override + public boolean hasOptFirst() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getSecond() { + return this.second; + } + + @Override + public boolean hasSecond() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptLast() { + return this.optLast; + } + + @Override + public boolean hasOptLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(optFirst), clone(second), clone(optLast)); + } + + } + public boolean isSubscript() { + return false; + } + + static public class Subscript extends Assignable { + // Production: sig("Subscript",[arg("org.rascalmpl.ast.Assignable","receiver"),arg("org.rascalmpl.ast.Expression","subscript")],breakable=false) + + + private final org.rascalmpl.ast.Assignable receiver; + private final org.rascalmpl.ast.Expression subscript; + + public Subscript(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable receiver, org.rascalmpl.ast.Expression subscript) { + super(src, node); + + this.receiver = receiver; + this.subscript = subscript; + } + + @Override + public boolean isSubscript() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableSubscript(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = receiver.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + receiver.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = subscript.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + subscript.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Subscript)) { + return false; + } + Subscript tmp = (Subscript) o; + return true && tmp.receiver.equals(this.receiver) && tmp.subscript.equals(this.subscript) ; + } + + @Override + public int hashCode() { + return 29 + 151 * receiver.hashCode() + 29 * subscript.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getReceiver() { + return this.receiver; + } + + @Override + public boolean hasReceiver() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getSubscript() { + return this.subscript; + } + + @Override + public boolean hasSubscript() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(receiver), clone(subscript)); + } + + } + public boolean isTuple() { + return false; + } + + static public class Tuple extends Assignable { + // Production: sig("Tuple",[arg("java.util.List\","elements")],breakable=false) + + + private final java.util.List elements; + + public Tuple(ISourceLocation src, IConstructor node , java.util.List elements) { + super(src, node); + + this.elements = elements; + } + + @Override + public boolean isTuple() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableTuple(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : elements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tuple)) { + return false; + } + Tuple tmp = (Tuple) o; + return true && tmp.elements.equals(this.elements) ; + } + + @Override + public int hashCode() { + return 353 + 31 * elements.hashCode() ; + } + + + @Override + public java.util.List getElements() { + return this.elements; + } + + @Override + public boolean hasElements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(elements)); + } + + } + public boolean isVariable() { + return false; + } + + static public class Variable extends Assignable { + // Production: sig("Variable",[arg("org.rascalmpl.ast.QualifiedName","qualifiedName")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName qualifiedName; + + public Variable(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName qualifiedName) { + super(src, node); + + this.qualifiedName = qualifiedName; + } + + @Override + public boolean isVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignableVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = qualifiedName.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + qualifiedName.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Variable)) { + return false; + } + Variable tmp = (Variable) o; + return true && tmp.qualifiedName.equals(this.qualifiedName) ; + } + + @Override + public int hashCode() { + return 337 + 257 * qualifiedName.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getQualifiedName() { + return this.qualifiedName; + } + + @Override + public boolean hasQualifiedName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(qualifiedName)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Assignment.java b/src/org/rascalmpl/ast/Assignment.java new file mode 100644 index 00000000000..7e0e90af453 --- /dev/null +++ b/src/org/rascalmpl/ast/Assignment.java @@ -0,0 +1,473 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Assignment extends AbstractAST { + public Assignment(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isAddition() { + return false; + } + + static public class Addition extends Assignment { + // Production: sig("Addition",[],breakable=false) + + + + public Addition(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAddition() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentAddition(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Addition)) { + return false; + } + Addition tmp = (Addition) o; + return true ; + } + + @Override + public int hashCode() { + return 431 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isAppend() { + return false; + } + + static public class Append extends Assignment { + // Production: sig("Append",[],breakable=false) + + + + public Append(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAppend() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentAppend(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Append)) { + return false; + } + Append tmp = (Append) o; + return true ; + } + + @Override + public int hashCode() { + return 751 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isDefault() { + return false; + } + + static public class Default extends Assignment { + // Production: sig("Default",[],breakable=false) + + + + public Default(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true ; + } + + @Override + public int hashCode() { + return 449 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isDivision() { + return false; + } + + static public class Division extends Assignment { + // Production: sig("Division",[],breakable=false) + + + + public Division(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isDivision() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentDivision(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Division)) { + return false; + } + Division tmp = (Division) o; + return true ; + } + + @Override + public int hashCode() { + return 557 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isIfDefined() { + return false; + } + + static public class IfDefined extends Assignment { + // Production: sig("IfDefined",[],breakable=false) + + + + public IfDefined(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isIfDefined() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentIfDefined(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfDefined)) { + return false; + } + IfDefined tmp = (IfDefined) o; + return true ; + } + + @Override + public int hashCode() { + return 61 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isIntersection() { + return false; + } + + static public class Intersection extends Assignment { + // Production: sig("Intersection",[],breakable=false) + + + + public Intersection(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isIntersection() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentIntersection(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Intersection)) { + return false; + } + Intersection tmp = (Intersection) o; + return true ; + } + + @Override + public int hashCode() { + return 503 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isProduct() { + return false; + } + + static public class Product extends Assignment { + // Production: sig("Product",[],breakable=false) + + + + public Product(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isProduct() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentProduct(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Product)) { + return false; + } + Product tmp = (Product) o; + return true ; + } + + @Override + public int hashCode() { + return 41 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isSubtraction() { + return false; + } + + static public class Subtraction extends Assignment { + // Production: sig("Subtraction",[],breakable=false) + + + + public Subtraction(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isSubtraction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssignmentSubtraction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Subtraction)) { + return false; + } + Subtraction tmp = (Subtraction) o; + return true ; + } + + @Override + public int hashCode() { + return 293 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Assoc.java b/src/org/rascalmpl/ast/Assoc.java new file mode 100644 index 00000000000..7d88c11bbdb --- /dev/null +++ b/src/org/rascalmpl/ast/Assoc.java @@ -0,0 +1,253 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Assoc extends AbstractAST { + public Assoc(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isAssociative() { + return false; + } + + static public class Associative extends Assoc { + // Production: sig("Associative",[],breakable=false) + + + + public Associative(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAssociative() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssocAssociative(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Associative)) { + return false; + } + Associative tmp = (Associative) o; + return true ; + } + + @Override + public int hashCode() { + return 229 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isLeft() { + return false; + } + + static public class Left extends Assoc { + // Production: sig("Left",[],breakable=false) + + + + public Left(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isLeft() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssocLeft(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Left)) { + return false; + } + Left tmp = (Left) o; + return true ; + } + + @Override + public int hashCode() { + return 751 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isNonAssociative() { + return false; + } + + static public class NonAssociative extends Assoc { + // Production: sig("NonAssociative",[],breakable=false) + + + + public NonAssociative(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNonAssociative() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssocNonAssociative(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonAssociative)) { + return false; + } + NonAssociative tmp = (NonAssociative) o; + return true ; + } + + @Override + public int hashCode() { + return 433 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isRight() { + return false; + } + + static public class Right extends Assoc { + // Production: sig("Right",[],breakable=false) + + + + public Right(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isRight() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitAssocRight(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Right)) { + return false; + } + Right tmp = (Right) o; + return true ; + } + + @Override + public int hashCode() { + return 839 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Backslash.java b/src/org/rascalmpl/ast/Backslash.java new file mode 100644 index 00000000000..7e1505d1ab5 --- /dev/null +++ b/src/org/rascalmpl/ast/Backslash.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Backslash extends AbstractAST { + public Backslash(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Backslash { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitBackslashLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/BasicType.java b/src/org/rascalmpl/ast/BasicType.java new file mode 100644 index 00000000000..e5eca14ed6b --- /dev/null +++ b/src/org/rascalmpl/ast/BasicType.java @@ -0,0 +1,1078 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class BasicType extends AbstractAST { + public BasicType(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isBag() { + return false; + } + + static public class Bag extends BasicType { + // Production: sig("Bag",[],breakable=false) + + + + public Bag(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isBag() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeBag(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bag)) { + return false; + } + Bag tmp = (Bag) o; + return true ; + } + + @Override + public int hashCode() { + return 659 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isBool() { + return false; + } + + static public class Bool extends BasicType { + // Production: sig("Bool",[],breakable=false) + + + + public Bool(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isBool() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeBool(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bool)) { + return false; + } + Bool tmp = (Bool) o; + return true ; + } + + @Override + public int hashCode() { + return 229 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isDateTime() { + return false; + } + + static public class DateTime extends BasicType { + // Production: sig("DateTime",[],breakable=false) + + + + public DateTime(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isDateTime() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeDateTime(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DateTime)) { + return false; + } + DateTime tmp = (DateTime) o; + return true ; + } + + @Override + public int hashCode() { + return 827 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isInt() { + return false; + } + + static public class Int extends BasicType { + // Production: sig("Int",[],breakable=false) + + + + public Int(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isInt() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeInt(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Int)) { + return false; + } + Int tmp = (Int) o; + return true ; + } + + @Override + public int hashCode() { + return 709 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isList() { + return false; + } + + static public class List extends BasicType { + // Production: sig("List",[],breakable=false) + + + + public List(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isList() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeList(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof List)) { + return false; + } + List tmp = (List) o; + return true ; + } + + @Override + public int hashCode() { + return 263 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isListRelation() { + return false; + } + + static public class ListRelation extends BasicType { + // Production: sig("ListRelation",[],breakable=false) + + + + public ListRelation(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isListRelation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeListRelation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ListRelation)) { + return false; + } + ListRelation tmp = (ListRelation) o; + return true ; + } + + @Override + public int hashCode() { + return 89 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isLoc() { + return false; + } + + static public class Loc extends BasicType { + // Production: sig("Loc",[],breakable=false) + + + + public Loc(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isLoc() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeLoc(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Loc)) { + return false; + } + Loc tmp = (Loc) o; + return true ; + } + + @Override + public int hashCode() { + return 43 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isMap() { + return false; + } + + static public class Map extends BasicType { + // Production: sig("Map",[],breakable=false) + + + + public Map(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeMap(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Map)) { + return false; + } + Map tmp = (Map) o; + return true ; + } + + @Override + public int hashCode() { + return 641 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isNode() { + return false; + } + + static public class Node extends BasicType { + // Production: sig("Node",[],breakable=false) + + + + public Node(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNode() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeNode(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Node)) { + return false; + } + Node tmp = (Node) o; + return true ; + } + + @Override + public int hashCode() { + return 839 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isNum() { + return false; + } + + static public class Num extends BasicType { + // Production: sig("Num",[],breakable=false) + + + + public Num(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNum() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeNum(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Num)) { + return false; + } + Num tmp = (Num) o; + return true ; + } + + @Override + public int hashCode() { + return 269 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isRational() { + return false; + } + + static public class Rational extends BasicType { + // Production: sig("Rational",[],breakable=false) + + + + public Rational(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isRational() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeRational(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Rational)) { + return false; + } + Rational tmp = (Rational) o; + return true ; + } + + @Override + public int hashCode() { + return 449 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isReal() { + return false; + } + + static public class Real extends BasicType { + // Production: sig("Real",[],breakable=false) + + + + public Real(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isReal() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeReal(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Real)) { + return false; + } + Real tmp = (Real) o; + return true ; + } + + @Override + public int hashCode() { + return 859 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isRelation() { + return false; + } + + static public class Relation extends BasicType { + // Production: sig("Relation",[],breakable=false) + + + + public Relation(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isRelation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeRelation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Relation)) { + return false; + } + Relation tmp = (Relation) o; + return true ; + } + + @Override + public int hashCode() { + return 727 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isSet() { + return false; + } + + static public class Set extends BasicType { + // Production: sig("Set",[],breakable=false) + + + + public Set(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isSet() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeSet(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Set)) { + return false; + } + Set tmp = (Set) o; + return true ; + } + + @Override + public int hashCode() { + return 907 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isString() { + return false; + } + + static public class String extends BasicType { + // Production: sig("String",[],breakable=false) + + + + public String(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isString() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeString(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof String)) { + return false; + } + String tmp = (String) o; + return true ; + } + + @Override + public int hashCode() { + return 229 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTuple() { + return false; + } + + static public class Tuple extends BasicType { + // Production: sig("Tuple",[],breakable=false) + + + + public Tuple(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isTuple() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeTuple(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tuple)) { + return false; + } + Tuple tmp = (Tuple) o; + return true ; + } + + @Override + public int hashCode() { + return 479 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isType() { + return false; + } + + static public class Type extends BasicType { + // Production: sig("Type",[],breakable=false) + + + + public Type(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isType() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeType(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Type)) { + return false; + } + Type tmp = (Type) o; + return true ; + } + + @Override + public int hashCode() { + return 821 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isValue() { + return false; + } + + static public class Value extends BasicType { + // Production: sig("Value",[],breakable=false) + + + + public Value(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isValue() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeValue(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Value)) { + return false; + } + Value tmp = (Value) o; + return true ; + } + + @Override + public int hashCode() { + return 7 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isVoid() { + return false; + } + + static public class Void extends BasicType { + // Production: sig("Void",[],breakable=false) + + + + public Void(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isVoid() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBasicTypeVoid(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Void)) { + return false; + } + Void tmp = (Void) o; + return true ; + } + + @Override + public int hashCode() { + return 229 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Body.java b/src/org/rascalmpl/ast/Body.java new file mode 100644 index 00000000000..9f0e55f5621 --- /dev/null +++ b/src/org/rascalmpl/ast/Body.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Body extends AbstractAST { + public Body(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasToplevels() { + return false; + } + + public java.util.List getToplevels() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isToplevels() { + return false; + } + + static public class Toplevels extends Body { + // Production: sig("Toplevels",[arg("java.util.List\","toplevels")],breakable=false) + + + private final java.util.List toplevels; + + public Toplevels(ISourceLocation src, IConstructor node , java.util.List toplevels) { + super(src, node); + + this.toplevels = toplevels; + } + + @Override + public boolean isToplevels() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBodyToplevels(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : toplevels) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Toplevels)) { + return false; + } + Toplevels tmp = (Toplevels) o; + return true && tmp.toplevels.equals(this.toplevels) ; + } + + @Override + public int hashCode() { + return 743 + 137 * toplevels.hashCode() ; + } + + + @Override + public java.util.List getToplevels() { + return this.toplevels; + } + + @Override + public boolean hasToplevels() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(toplevels)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/BooleanLiteral.java b/src/org/rascalmpl/ast/BooleanLiteral.java new file mode 100644 index 00000000000..f1528b1bc94 --- /dev/null +++ b/src/org/rascalmpl/ast/BooleanLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class BooleanLiteral extends AbstractAST { + public BooleanLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends BooleanLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitBooleanLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Bound.java b/src/org/rascalmpl/ast/Bound.java new file mode 100644 index 00000000000..35e36d89471 --- /dev/null +++ b/src/org/rascalmpl/ast/Bound.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Bound extends AbstractAST { + public Bound(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Bound { + // Production: sig("Default",[arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBoundDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 673 + 761 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + + } + public boolean isEmpty() { + return false; + } + + static public class Empty extends Bound { + // Production: sig("Empty",[],breakable=false) + + + + public Empty(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitBoundEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true ; + } + + @Override + public int hashCode() { + return 5 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Case.java b/src/org/rascalmpl/ast/Case.java new file mode 100644 index 00000000000..f55856dcdc2 --- /dev/null +++ b/src/org/rascalmpl/ast/Case.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Case extends AbstractAST { + public Case(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasPatternWithAction() { + return false; + } + + public org.rascalmpl.ast.PatternWithAction getPatternWithAction() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Case { + // Production: sig("Default",[arg("org.rascalmpl.ast.Statement","statement")],breakable=false) + + + private final org.rascalmpl.ast.Statement statement; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.statement = statement; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCaseDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 307 + 881 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statement)); + } + + } + public boolean isPatternWithAction() { + return false; + } + + static public class PatternWithAction extends Case { + // Production: sig("PatternWithAction",[arg("org.rascalmpl.ast.PatternWithAction","patternWithAction")],breakable=false) + + + private final org.rascalmpl.ast.PatternWithAction patternWithAction; + + public PatternWithAction(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PatternWithAction patternWithAction) { + super(src, node); + + this.patternWithAction = patternWithAction; + } + + @Override + public boolean isPatternWithAction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCasePatternWithAction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = patternWithAction.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + patternWithAction.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof PatternWithAction)) { + return false; + } + PatternWithAction tmp = (PatternWithAction) o; + return true && tmp.patternWithAction.equals(this.patternWithAction) ; + } + + @Override + public int hashCode() { + return 613 + 383 * patternWithAction.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PatternWithAction getPatternWithAction() { + return this.patternWithAction; + } + + @Override + public boolean hasPatternWithAction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(patternWithAction)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/CaseInsensitiveStringConstant.java b/src/org/rascalmpl/ast/CaseInsensitiveStringConstant.java new file mode 100644 index 00000000000..8006993d3f9 --- /dev/null +++ b/src/org/rascalmpl/ast/CaseInsensitiveStringConstant.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class CaseInsensitiveStringConstant extends AbstractAST { + public CaseInsensitiveStringConstant(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends CaseInsensitiveStringConstant { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitCaseInsensitiveStringConstantLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Catch.java b/src/org/rascalmpl/ast/Catch.java new file mode 100644 index 00000000000..e836b1c7c82 --- /dev/null +++ b/src/org/rascalmpl/ast/Catch.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Catch extends AbstractAST { + public Catch(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasPattern() { + return false; + } + + public org.rascalmpl.ast.Expression getPattern() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBody() { + return false; + } + + public org.rascalmpl.ast.Statement getBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isBinding() { + return false; + } + + static public class Binding extends Catch { + // Production: sig("Binding",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Statement","body")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Statement body; + + public Binding(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Statement body) { + super(src, node); + + this.pattern = pattern; + this.body = body; + } + + @Override + public boolean isBinding() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCatchBinding(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Binding)) { + return false; + } + Binding tmp = (Binding) o; + return true && tmp.pattern.equals(this.pattern) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 499 + 113 * pattern.hashCode() + 601 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(body)); + } + + } + public boolean isDefault() { + return false; + } + + static public class Default extends Catch { + // Production: sig("Default",[arg("org.rascalmpl.ast.Statement","body")],breakable=false) + + + private final org.rascalmpl.ast.Statement body; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement body) { + super(src, node); + + this.body = body; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCatchDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 757 + 443 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(body)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Char.java b/src/org/rascalmpl/ast/Char.java new file mode 100644 index 00000000000..c89bfe3c285 --- /dev/null +++ b/src/org/rascalmpl/ast/Char.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Char extends AbstractAST { + public Char(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Char { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitCharLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Class.java b/src/org/rascalmpl/ast/Class.java new file mode 100644 index 00000000000..d55800fdc4d --- /dev/null +++ b/src/org/rascalmpl/ast/Class.java @@ -0,0 +1,564 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Class extends AbstractAST { + public Class(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasRanges() { + return false; + } + + public java.util.List getRanges() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCharClass() { + return false; + } + + public org.rascalmpl.ast.Class getCharClass() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLhs() { + return false; + } + + public org.rascalmpl.ast.Class getLhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRhs() { + return false; + } + + public org.rascalmpl.ast.Class getRhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isBracket() { + return false; + } + + static public class Bracket extends Class { + // Production: sig("Bracket",[arg("org.rascalmpl.ast.Class","charClass")],breakable=false) + + + private final org.rascalmpl.ast.Class charClass; + + public Bracket(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class charClass) { + super(src, node); + + this.charClass = charClass; + } + + @Override + public boolean isBracket() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassBracket(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = charClass.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + charClass.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bracket)) { + return false; + } + Bracket tmp = (Bracket) o; + return true && tmp.charClass.equals(this.charClass) ; + } + + @Override + public int hashCode() { + return 13 + 103 * charClass.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getCharClass() { + return this.charClass; + } + + @Override + public boolean hasCharClass() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(charClass)); + } + + } + public boolean isComplement() { + return false; + } + + static public class Complement extends Class { + // Production: sig("Complement",[arg("org.rascalmpl.ast.Class","charClass")],breakable=false) + + + private final org.rascalmpl.ast.Class charClass; + + public Complement(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class charClass) { + super(src, node); + + this.charClass = charClass; + } + + @Override + public boolean isComplement() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassComplement(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = charClass.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + charClass.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Complement)) { + return false; + } + Complement tmp = (Complement) o; + return true && tmp.charClass.equals(this.charClass) ; + } + + @Override + public int hashCode() { + return 109 + 61 * charClass.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getCharClass() { + return this.charClass; + } + + @Override + public boolean hasCharClass() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(charClass)); + } + + } + public boolean isDifference() { + return false; + } + + static public class Difference extends Class { + // Production: sig("Difference",[arg("org.rascalmpl.ast.Class","lhs"),arg("org.rascalmpl.ast.Class","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Class lhs; + private final org.rascalmpl.ast.Class rhs; + + public Difference(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class lhs, org.rascalmpl.ast.Class rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isDifference() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassDifference(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Difference)) { + return false; + } + Difference tmp = (Difference) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 79 + 367 * lhs.hashCode() + 587 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Class getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isIntersection() { + return false; + } + + static public class Intersection extends Class { + // Production: sig("Intersection",[arg("org.rascalmpl.ast.Class","lhs"),arg("org.rascalmpl.ast.Class","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Class lhs; + private final org.rascalmpl.ast.Class rhs; + + public Intersection(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class lhs, org.rascalmpl.ast.Class rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isIntersection() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassIntersection(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Intersection)) { + return false; + } + Intersection tmp = (Intersection) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 433 + 47 * lhs.hashCode() + 131 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Class getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isSimpleCharclass() { + return false; + } + + static public class SimpleCharclass extends Class { + // Production: sig("SimpleCharclass",[arg("java.util.List\","ranges")],breakable=false) + + + private final java.util.List ranges; + + public SimpleCharclass(ISourceLocation src, IConstructor node , java.util.List ranges) { + super(src, node); + + this.ranges = ranges; + } + + @Override + public boolean isSimpleCharclass() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassSimpleCharclass(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : ranges) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SimpleCharclass)) { + return false; + } + SimpleCharclass tmp = (SimpleCharclass) o; + return true && tmp.ranges.equals(this.ranges) ; + } + + @Override + public int hashCode() { + return 733 + 491 * ranges.hashCode() ; + } + + + @Override + public java.util.List getRanges() { + return this.ranges; + } + + @Override + public boolean hasRanges() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(ranges)); + } + + } + public boolean isUnion() { + return false; + } + + static public class Union extends Class { + // Production: sig("Union",[arg("org.rascalmpl.ast.Class","lhs"),arg("org.rascalmpl.ast.Class","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Class lhs; + private final org.rascalmpl.ast.Class rhs; + + public Union(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class lhs, org.rascalmpl.ast.Class rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isUnion() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitClassUnion(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Union)) { + return false; + } + Union tmp = (Union) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 829 + 937 * lhs.hashCode() + 409 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Class getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Command.java b/src/org/rascalmpl/ast/Command.java new file mode 100644 index 00000000000..927ae5d2402 --- /dev/null +++ b/src/org/rascalmpl/ast/Command.java @@ -0,0 +1,438 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Command extends AbstractAST { + public Command(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDeclaration() { + return false; + } + + public org.rascalmpl.ast.Declaration getDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasImported() { + return false; + } + + public org.rascalmpl.ast.Import getImported() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCommand() { + return false; + } + + public org.rascalmpl.ast.ShellCommand getCommand() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDeclaration() { + return false; + } + + static public class Declaration extends Command { + // Production: sig("Declaration",[arg("org.rascalmpl.ast.Declaration","declaration")],breakable=false) + + + private final org.rascalmpl.ast.Declaration declaration; + + public Declaration(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declaration declaration) { + super(src, node); + + this.declaration = declaration; + } + + @Override + public boolean isDeclaration() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandDeclaration(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Declaration)) { + return false; + } + Declaration tmp = (Declaration) o; + return true && tmp.declaration.equals(this.declaration) ; + } + + @Override + public int hashCode() { + return 857 + 509 * declaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Declaration getDeclaration() { + return this.declaration; + } + + @Override + public boolean hasDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declaration)); + } + + } + public boolean isExpression() { + return false; + } + + static public class Expression extends Command { + // Production: sig("Expression",[arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + + public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Expression)) { + return false; + } + Expression tmp = (Expression) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 7 + 173 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + + } + public boolean isImport() { + return false; + } + + static public class Import extends Command { + // Production: sig("Import",[arg("org.rascalmpl.ast.Import","imported")],breakable=false) + + + private final org.rascalmpl.ast.Import imported; + + public Import(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Import imported) { + super(src, node); + + this.imported = imported; + } + + @Override + public boolean isImport() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandImport(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = imported.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + imported.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Import)) { + return false; + } + Import tmp = (Import) o; + return true && tmp.imported.equals(this.imported) ; + } + + @Override + public int hashCode() { + return 827 + 941 * imported.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Import getImported() { + return this.imported; + } + + @Override + public boolean hasImported() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(imported)); + } + + } + public boolean isShell() { + return false; + } + + static public class Shell extends Command { + // Production: sig("Shell",[arg("org.rascalmpl.ast.ShellCommand","command")],breakable=false) + + + private final org.rascalmpl.ast.ShellCommand command; + + public Shell(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ShellCommand command) { + super(src, node); + + this.command = command; + } + + @Override + public boolean isShell() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandShell(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = command.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + command.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Shell)) { + return false; + } + Shell tmp = (Shell) o; + return true && tmp.command.equals(this.command) ; + } + + @Override + public int hashCode() { + return 199 + 661 * command.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.ShellCommand getCommand() { + return this.command; + } + + @Override + public boolean hasCommand() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(command)); + } + + } + public boolean isStatement() { + return false; + } + + static public class Statement extends Command { + // Production: sig("Statement",[arg("org.rascalmpl.ast.Statement","statement")],breakable=false) + + + private final org.rascalmpl.ast.Statement statement; + + public Statement(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.statement = statement; + } + + @Override + public boolean isStatement() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandStatement(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Statement)) { + return false; + } + Statement tmp = (Statement) o; + return true && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 487 + 59 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statement)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Commands.java b/src/org/rascalmpl/ast/Commands.java new file mode 100644 index 00000000000..8d33b0e1ab2 --- /dev/null +++ b/src/org/rascalmpl/ast/Commands.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Commands extends AbstractAST { + public Commands(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasCommands() { + return false; + } + + public java.util.List getCommands() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isCommandlist() { + return false; + } + + static public class Commandlist extends Commands { + // Production: sig("Commandlist",[arg("java.util.List\","commands")],breakable=false) + + + private final java.util.List commands; + + public Commandlist(ISourceLocation src, IConstructor node , java.util.List commands) { + super(src, node); + + this.commands = commands; + } + + @Override + public boolean isCommandlist() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommandsCommandlist(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : commands) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Commandlist)) { + return false; + } + Commandlist tmp = (Commandlist) o; + return true && tmp.commands.equals(this.commands) ; + } + + @Override + public int hashCode() { + return 127 + 389 * commands.hashCode() ; + } + + + @Override + public java.util.List getCommands() { + return this.commands; + } + + @Override + public boolean hasCommands() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(commands)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Comment.java b/src/org/rascalmpl/ast/Comment.java new file mode 100644 index 00000000000..fba5214745b --- /dev/null +++ b/src/org/rascalmpl/ast/Comment.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Comment extends AbstractAST { + public Comment(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Comment { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitCommentLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/CommonKeywordParameters.java b/src/org/rascalmpl/ast/CommonKeywordParameters.java new file mode 100644 index 00000000000..e9bd9f3c92b --- /dev/null +++ b/src/org/rascalmpl/ast/CommonKeywordParameters.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class CommonKeywordParameters extends AbstractAST { + public CommonKeywordParameters(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasKeywordFormalList() { + return false; + } + + public java.util.List getKeywordFormalList() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAbsent() { + return false; + } + + static public class Absent extends CommonKeywordParameters { + // Production: sig("Absent",[],breakable=false) + + + + public Absent(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAbsent() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommonKeywordParametersAbsent(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Absent)) { + return false; + } + Absent tmp = (Absent) o; + return true ; + } + + @Override + public int hashCode() { + return 157 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isPresent() { + return false; + } + + static public class Present extends CommonKeywordParameters { + // Production: sig("Present",[arg("java.util.List\","keywordFormalList")],breakable=false) + + + private final java.util.List keywordFormalList; + + public Present(ISourceLocation src, IConstructor node , java.util.List keywordFormalList) { + super(src, node); + + this.keywordFormalList = keywordFormalList; + } + + @Override + public boolean isPresent() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitCommonKeywordParametersPresent(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : keywordFormalList) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Present)) { + return false; + } + Present tmp = (Present) o; + return true && tmp.keywordFormalList.equals(this.keywordFormalList) ; + } + + @Override + public int hashCode() { + return 443 + 503 * keywordFormalList.hashCode() ; + } + + + @Override + public java.util.List getKeywordFormalList() { + return this.keywordFormalList; + } + + @Override + public boolean hasKeywordFormalList() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(keywordFormalList)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Comprehension.java b/src/org/rascalmpl/ast/Comprehension.java new file mode 100644 index 00000000000..15892f22da4 --- /dev/null +++ b/src/org/rascalmpl/ast/Comprehension.java @@ -0,0 +1,369 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Comprehension extends AbstractAST { + public Comprehension(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasGenerators() { + return false; + } + + public java.util.List getGenerators() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasResults() { + return false; + } + + public java.util.List getResults() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFrom() { + return false; + } + + public org.rascalmpl.ast.Expression getFrom() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTo() { + return false; + } + + public org.rascalmpl.ast.Expression getTo() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isList() { + return false; + } + + static public class List extends Comprehension { + // Production: sig("List",[arg("java.util.List\","results"),arg("java.util.List\","generators")],breakable=false) + + + private final java.util.List results; + private final java.util.List generators; + + public List(ISourceLocation src, IConstructor node , java.util.List results, java.util.List generators) { + super(src, node); + + this.results = results; + this.generators = generators; + } + + @Override + public boolean isList() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitComprehensionList(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : results) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof List)) { + return false; + } + List tmp = (List) o; + return true && tmp.results.equals(this.results) && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 881 + 349 * results.hashCode() + 449 * generators.hashCode() ; + } + + + @Override + public java.util.List getResults() { + return this.results; + } + + @Override + public boolean hasResults() { + return true; + } + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(results), clone(generators)); + } + + } + public boolean isMap() { + return false; + } + + static public class Map extends Comprehension { + // Production: sig("Map",[arg("org.rascalmpl.ast.Expression","from"),arg("org.rascalmpl.ast.Expression","to"),arg("java.util.List\","generators")],breakable=false) + + + private final org.rascalmpl.ast.Expression from; + private final org.rascalmpl.ast.Expression to; + private final java.util.List generators; + + public Map(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression from, org.rascalmpl.ast.Expression to, java.util.List generators) { + super(src, node); + + this.from = from; + this.to = to; + this.generators = generators; + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitComprehensionMap(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = from.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + from.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = to.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + to.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Map)) { + return false; + } + Map tmp = (Map) o; + return true && tmp.from.equals(this.from) && tmp.to.equals(this.to) && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 71 + 523 * from.hashCode() + 937 * to.hashCode() + 617 * generators.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getFrom() { + return this.from; + } + + @Override + public boolean hasFrom() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getTo() { + return this.to; + } + + @Override + public boolean hasTo() { + return true; + } + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(from), clone(to), clone(generators)); + } + + } + public boolean isSet() { + return false; + } + + static public class Set extends Comprehension { + // Production: sig("Set",[arg("java.util.List\","results"),arg("java.util.List\","generators")],breakable=false) + + + private final java.util.List results; + private final java.util.List generators; + + public Set(ISourceLocation src, IConstructor node , java.util.List results, java.util.List generators) { + super(src, node); + + this.results = results; + this.generators = generators; + } + + @Override + public boolean isSet() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitComprehensionSet(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : results) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Set)) { + return false; + } + Set tmp = (Set) o; + return true && tmp.results.equals(this.results) && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 821 + 971 * results.hashCode() + 173 * generators.hashCode() ; + } + + + @Override + public java.util.List getResults() { + return this.results; + } + + @Override + public boolean hasResults() { + return true; + } + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(results), clone(generators)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Concrete.java b/src/org/rascalmpl/ast/Concrete.java new file mode 100644 index 00000000000..74ee3ea1569 --- /dev/null +++ b/src/org/rascalmpl/ast/Concrete.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Concrete extends AbstractAST { + public Concrete(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Concrete { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitConcreteLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ConcreteHole.java b/src/org/rascalmpl/ast/ConcreteHole.java new file mode 100644 index 00000000000..063f1fe5470 --- /dev/null +++ b/src/org/rascalmpl/ast/ConcreteHole.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ConcreteHole extends AbstractAST { + public ConcreteHole(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSymbol() { + return false; + } + + public org.rascalmpl.ast.Sym getSymbol() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isOne() { + return false; + } + + static public class One extends ConcreteHole { + // Production: sig("One",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Name name; + + public One(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Name name) { + super(src, node); + + this.symbol = symbol; + this.name = name; + } + + @Override + public boolean isOne() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitConcreteHoleOne(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof One)) { + return false; + } + One tmp = (One) o; + return true && tmp.symbol.equals(this.symbol) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 257 + 83 * symbol.hashCode() + 71 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(name)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ConcretePart.java b/src/org/rascalmpl/ast/ConcretePart.java new file mode 100644 index 00000000000..1565ed34c37 --- /dev/null +++ b/src/org/rascalmpl/ast/ConcretePart.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ConcretePart extends AbstractAST { + public ConcretePart(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends ConcretePart { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitConcretePartLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DataTarget.java b/src/org/rascalmpl/ast/DataTarget.java new file mode 100644 index 00000000000..a151a5d46ce --- /dev/null +++ b/src/org/rascalmpl/ast/DataTarget.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DataTarget extends AbstractAST { + public DataTarget(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasLabel() { + return false; + } + + public org.rascalmpl.ast.Name getLabel() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isEmpty() { + return false; + } + + static public class Empty extends DataTarget { + // Production: sig("Empty",[],breakable=false) + + + + public Empty(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDataTargetEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true ; + } + + @Override + public int hashCode() { + return 167 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isLabeled() { + return false; + } + + static public class Labeled extends DataTarget { + // Production: sig("Labeled",[arg("org.rascalmpl.ast.Name","label")],breakable=false) + + + private final org.rascalmpl.ast.Name label; + + public Labeled(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name label) { + super(src, node); + + this.label = label; + } + + @Override + public boolean isLabeled() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDataTargetLabeled(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Labeled)) { + return false; + } + Labeled tmp = (Labeled) o; + return true && tmp.label.equals(this.label) ; + } + + @Override + public int hashCode() { + return 769 + 17 * label.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DataTypeSelector.java b/src/org/rascalmpl/ast/DataTypeSelector.java new file mode 100644 index 00000000000..514daa9a9a6 --- /dev/null +++ b/src/org/rascalmpl/ast/DataTypeSelector.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DataTypeSelector extends AbstractAST { + public DataTypeSelector(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasProduction() { + return false; + } + + public org.rascalmpl.ast.Name getProduction() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSort() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getSort() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isSelector() { + return false; + } + + static public class Selector extends DataTypeSelector { + // Production: sig("Selector",[arg("org.rascalmpl.ast.QualifiedName","sort"),arg("org.rascalmpl.ast.Name","production")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName sort; + private final org.rascalmpl.ast.Name production; + + public Selector(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName sort, org.rascalmpl.ast.Name production) { + super(src, node); + + this.sort = sort; + this.production = production; + } + + @Override + public boolean isSelector() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDataTypeSelectorSelector(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = sort.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + sort.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = production.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + production.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Selector)) { + return false; + } + Selector tmp = (Selector) o; + return true && tmp.sort.equals(this.sort) && tmp.production.equals(this.production) ; + } + + @Override + public int hashCode() { + return 41 + 761 * sort.hashCode() + 971 * production.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getSort() { + return this.sort; + } + + @Override + public boolean hasSort() { + return true; + } + @Override + public org.rascalmpl.ast.Name getProduction() { + return this.production; + } + + @Override + public boolean hasProduction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(sort), clone(production)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DateAndTime.java b/src/org/rascalmpl/ast/DateAndTime.java new file mode 100644 index 00000000000..1edc5392933 --- /dev/null +++ b/src/org/rascalmpl/ast/DateAndTime.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DateAndTime extends AbstractAST { + public DateAndTime(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends DateAndTime { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitDateAndTimeLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DatePart.java b/src/org/rascalmpl/ast/DatePart.java new file mode 100644 index 00000000000..271f84a1602 --- /dev/null +++ b/src/org/rascalmpl/ast/DatePart.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DatePart extends AbstractAST { + public DatePart(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends DatePart { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitDatePartLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DateTimeLiteral.java b/src/org/rascalmpl/ast/DateTimeLiteral.java new file mode 100644 index 00000000000..1e6c37406a0 --- /dev/null +++ b/src/org/rascalmpl/ast/DateTimeLiteral.java @@ -0,0 +1,276 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DateTimeLiteral extends AbstractAST { + public DateTimeLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDateAndTime() { + return false; + } + + public org.rascalmpl.ast.DateAndTime getDateAndTime() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDate() { + return false; + } + + public org.rascalmpl.ast.JustDate getDate() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTime() { + return false; + } + + public org.rascalmpl.ast.JustTime getTime() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDateAndTimeLiteral() { + return false; + } + + static public class DateAndTimeLiteral extends DateTimeLiteral { + // Production: sig("DateAndTimeLiteral",[arg("org.rascalmpl.ast.DateAndTime","dateAndTime")],breakable=false) + + + private final org.rascalmpl.ast.DateAndTime dateAndTime; + + public DateAndTimeLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DateAndTime dateAndTime) { + super(src, node); + + this.dateAndTime = dateAndTime; + } + + @Override + public boolean isDateAndTimeLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDateTimeLiteralDateAndTimeLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = dateAndTime.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + dateAndTime.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DateAndTimeLiteral)) { + return false; + } + DateAndTimeLiteral tmp = (DateAndTimeLiteral) o; + return true && tmp.dateAndTime.equals(this.dateAndTime) ; + } + + @Override + public int hashCode() { + return 643 + 751 * dateAndTime.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DateAndTime getDateAndTime() { + return this.dateAndTime; + } + + @Override + public boolean hasDateAndTime() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(dateAndTime)); + } + + } + public boolean isDateLiteral() { + return false; + } + + static public class DateLiteral extends DateTimeLiteral { + // Production: sig("DateLiteral",[arg("org.rascalmpl.ast.JustDate","date")],breakable=false) + + + private final org.rascalmpl.ast.JustDate date; + + public DateLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.JustDate date) { + super(src, node); + + this.date = date; + } + + @Override + public boolean isDateLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDateTimeLiteralDateLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = date.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + date.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DateLiteral)) { + return false; + } + DateLiteral tmp = (DateLiteral) o; + return true && tmp.date.equals(this.date) ; + } + + @Override + public int hashCode() { + return 907 + 857 * date.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.JustDate getDate() { + return this.date; + } + + @Override + public boolean hasDate() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(date)); + } + + } + public boolean isTimeLiteral() { + return false; + } + + static public class TimeLiteral extends DateTimeLiteral { + // Production: sig("TimeLiteral",[arg("org.rascalmpl.ast.JustTime","time")],breakable=false) + + + private final org.rascalmpl.ast.JustTime time; + + public TimeLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.JustTime time) { + super(src, node); + + this.time = time; + } + + @Override + public boolean isTimeLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDateTimeLiteralTimeLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = time.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + time.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TimeLiteral)) { + return false; + } + TimeLiteral tmp = (TimeLiteral) o; + return true && tmp.time.equals(this.time) ; + } + + @Override + public int hashCode() { + return 373 + 149 * time.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.JustTime getTime() { + return this.time; + } + + @Override + public boolean hasTime() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(time)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/DecimalIntegerLiteral.java b/src/org/rascalmpl/ast/DecimalIntegerLiteral.java new file mode 100644 index 00000000000..87b314c8228 --- /dev/null +++ b/src/org/rascalmpl/ast/DecimalIntegerLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class DecimalIntegerLiteral extends AbstractAST { + public DecimalIntegerLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends DecimalIntegerLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitDecimalIntegerLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Declaration.java b/src/org/rascalmpl/ast/Declaration.java new file mode 100644 index 00000000000..7665fa5a38d --- /dev/null +++ b/src/org/rascalmpl/ast/Declaration.java @@ -0,0 +1,1054 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Declaration extends AbstractAST { + public Declaration(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasTypes() { + return false; + } + + public java.util.List getTypes() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVariables() { + return false; + } + + public java.util.List getVariables() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVariants() { + return false; + } + + public java.util.List getVariants() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCommonKeywordParameters() { + return false; + } + + public org.rascalmpl.ast.CommonKeywordParameters getCommonKeywordParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFunctionDeclaration() { + return false; + } + + public org.rascalmpl.ast.FunctionDeclaration getFunctionDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasKind() { + return false; + } + + public org.rascalmpl.ast.Kind getKind() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTags() { + return false; + } + + public org.rascalmpl.ast.Tags getTags() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasAnnoType() { + return false; + } + + public org.rascalmpl.ast.Type getAnnoType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBase() { + return false; + } + + public org.rascalmpl.ast.Type getBase() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOnType() { + return false; + } + + public org.rascalmpl.ast.Type getOnType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasUser() { + return false; + } + + public org.rascalmpl.ast.UserType getUser() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVisibility() { + return false; + } + + public org.rascalmpl.ast.Visibility getVisibility() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAlias() { + return false; + } + + static public class Alias extends Declaration { + // Production: sig("Alias",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.UserType","user"),arg("org.rascalmpl.ast.Type","base")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.UserType user; + private final org.rascalmpl.ast.Type base; + + public Alias(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.UserType user, org.rascalmpl.ast.Type base) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.user = user; + this.base = base; + } + + @Override + public boolean isAlias() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationAlias(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = user.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + user.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = base.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + base.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Alias)) { + return false; + } + Alias tmp = (Alias) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.user.equals(this.user) && tmp.base.equals(this.base) ; + } + + @Override + public int hashCode() { + return 313 + 73 * tags.hashCode() + 499 * visibility.hashCode() + 691 * user.hashCode() + 227 * base.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.UserType getUser() { + return this.user; + } + + @Override + public boolean hasUser() { + return true; + } + @Override + public org.rascalmpl.ast.Type getBase() { + return this.base; + } + + @Override + public boolean hasBase() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(user), clone(base)); + } + + } + public boolean isAnnotation() { + return false; + } + + static public class Annotation extends Declaration { + // Production: sig("Annotation",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Type","annoType"),arg("org.rascalmpl.ast.Type","onType"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Type annoType; + private final org.rascalmpl.ast.Type onType; + private final org.rascalmpl.ast.Name name; + + public Annotation(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Type annoType, org.rascalmpl.ast.Type onType, org.rascalmpl.ast.Name name) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.annoType = annoType; + this.onType = onType; + this.name = name; + } + + @Override + public boolean isAnnotation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationAnnotation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = annoType.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + annoType.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = onType.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + onType.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Annotation)) { + return false; + } + Annotation tmp = (Annotation) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.annoType.equals(this.annoType) && tmp.onType.equals(this.onType) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 137 + 983 * tags.hashCode() + 677 * visibility.hashCode() + 433 * annoType.hashCode() + 673 * onType.hashCode() + 13 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Type getAnnoType() { + return this.annoType; + } + + @Override + public boolean hasAnnoType() { + return true; + } + @Override + public org.rascalmpl.ast.Type getOnType() { + return this.onType; + } + + @Override + public boolean hasOnType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(annoType), clone(onType), clone(name)); + } + + } + public boolean isData() { + return false; + } + + static public class Data extends Declaration { + // Production: sig("Data",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.UserType","user"),arg("org.rascalmpl.ast.CommonKeywordParameters","commonKeywordParameters"),arg("java.util.List\","variants")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.UserType user; + private final org.rascalmpl.ast.CommonKeywordParameters commonKeywordParameters; + private final java.util.List variants; + + public Data(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.UserType user, org.rascalmpl.ast.CommonKeywordParameters commonKeywordParameters, java.util.List variants) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.user = user; + this.commonKeywordParameters = commonKeywordParameters; + this.variants = variants; + } + + @Override + public boolean isData() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationData(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = user.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + user.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = commonKeywordParameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + commonKeywordParameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : variants) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Data)) { + return false; + } + Data tmp = (Data) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.user.equals(this.user) && tmp.commonKeywordParameters.equals(this.commonKeywordParameters) && tmp.variants.equals(this.variants) ; + } + + @Override + public int hashCode() { + return 281 + 101 * tags.hashCode() + 433 * visibility.hashCode() + 419 * user.hashCode() + 911 * commonKeywordParameters.hashCode() + 191 * variants.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.UserType getUser() { + return this.user; + } + + @Override + public boolean hasUser() { + return true; + } + @Override + public org.rascalmpl.ast.CommonKeywordParameters getCommonKeywordParameters() { + return this.commonKeywordParameters; + } + + @Override + public boolean hasCommonKeywordParameters() { + return true; + } + @Override + public java.util.List getVariants() { + return this.variants; + } + + @Override + public boolean hasVariants() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(user), clone(commonKeywordParameters), clone(variants)); + } + + } + public boolean isDataAbstract() { + return false; + } + + static public class DataAbstract extends Declaration { + // Production: sig("DataAbstract",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.UserType","user"),arg("org.rascalmpl.ast.CommonKeywordParameters","commonKeywordParameters")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.UserType user; + private final org.rascalmpl.ast.CommonKeywordParameters commonKeywordParameters; + + public DataAbstract(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.UserType user, org.rascalmpl.ast.CommonKeywordParameters commonKeywordParameters) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.user = user; + this.commonKeywordParameters = commonKeywordParameters; + } + + @Override + public boolean isDataAbstract() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationDataAbstract(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = user.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + user.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = commonKeywordParameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + commonKeywordParameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DataAbstract)) { + return false; + } + DataAbstract tmp = (DataAbstract) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.user.equals(this.user) && tmp.commonKeywordParameters.equals(this.commonKeywordParameters) ; + } + + @Override + public int hashCode() { + return 397 + 131 * tags.hashCode() + 863 * visibility.hashCode() + 211 * user.hashCode() + 593 * commonKeywordParameters.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.UserType getUser() { + return this.user; + } + + @Override + public boolean hasUser() { + return true; + } + @Override + public org.rascalmpl.ast.CommonKeywordParameters getCommonKeywordParameters() { + return this.commonKeywordParameters; + } + + @Override + public boolean hasCommonKeywordParameters() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(user), clone(commonKeywordParameters)); + } + + } + public boolean isFunction() { + return false; + } + + static public class Function extends Declaration { + // Production: sig("Function",[arg("org.rascalmpl.ast.FunctionDeclaration","functionDeclaration")],breakable=false) + + + private final org.rascalmpl.ast.FunctionDeclaration functionDeclaration; + + public Function(ISourceLocation src, IConstructor node , org.rascalmpl.ast.FunctionDeclaration functionDeclaration) { + super(src, node); + + this.functionDeclaration = functionDeclaration; + } + + @Override + public boolean isFunction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationFunction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = functionDeclaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + functionDeclaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Function)) { + return false; + } + Function tmp = (Function) o; + return true && tmp.functionDeclaration.equals(this.functionDeclaration) ; + } + + @Override + public int hashCode() { + return 13 + 7 * functionDeclaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.FunctionDeclaration getFunctionDeclaration() { + return this.functionDeclaration; + } + + @Override + public boolean hasFunctionDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(functionDeclaration)); + } + + } + public boolean isTag() { + return false; + } + + static public class Tag extends Declaration { + // Production: sig("Tag",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Kind","kind"),arg("org.rascalmpl.ast.Name","name"),arg("java.util.List\","types")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Kind kind; + private final org.rascalmpl.ast.Name name; + private final java.util.List types; + + public Tag(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Kind kind, org.rascalmpl.ast.Name name, java.util.List types) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.kind = kind; + this.name = name; + this.types = types; + } + + @Override + public boolean isTag() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationTag(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = kind.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + kind.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : types) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tag)) { + return false; + } + Tag tmp = (Tag) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.kind.equals(this.kind) && tmp.name.equals(this.name) && tmp.types.equals(this.types) ; + } + + @Override + public int hashCode() { + return 101 + 479 * tags.hashCode() + 137 * visibility.hashCode() + 223 * kind.hashCode() + 307 * name.hashCode() + 733 * types.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Kind getKind() { + return this.kind; + } + + @Override + public boolean hasKind() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getTypes() { + return this.types; + } + + @Override + public boolean hasTypes() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(kind), clone(name), clone(types)); + } + + } + public boolean isVariable() { + return false; + } + + static public class Variable extends Declaration { + // Production: sig("Variable",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Type","type"),arg("java.util.List\","variables")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Type type; + private final java.util.List variables; + + public Variable(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Type type, java.util.List variables) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.type = type; + this.variables = variables; + } + + @Override + public boolean isVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclarationVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : variables) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Variable)) { + return false; + } + Variable tmp = (Variable) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.type.equals(this.type) && tmp.variables.equals(this.variables) ; + } + + @Override + public int hashCode() { + return 859 + 599 * tags.hashCode() + 643 * visibility.hashCode() + 853 * type.hashCode() + 3 * variables.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public java.util.List getVariables() { + return this.variables; + } + + @Override + public boolean hasVariables() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(type), clone(variables)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Declarator.java b/src/org/rascalmpl/ast/Declarator.java new file mode 100644 index 00000000000..0b4347e45ba --- /dev/null +++ b/src/org/rascalmpl/ast/Declarator.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Declarator extends AbstractAST { + public Declarator(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasVariables() { + return false; + } + + public java.util.List getVariables() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Declarator { + // Production: sig("Default",[arg("org.rascalmpl.ast.Type","type"),arg("java.util.List\","variables")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final java.util.List variables; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, java.util.List variables) { + super(src, node); + + this.type = type; + this.variables = variables; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitDeclaratorDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : variables) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.type.equals(this.type) && tmp.variables.equals(this.variables) ; + } + + @Override + public int hashCode() { + return 257 + 307 * type.hashCode() + 577 * variables.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public java.util.List getVariables() { + return this.variables; + } + + @Override + public boolean hasVariables() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(variables)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/EvalCommand.java b/src/org/rascalmpl/ast/EvalCommand.java new file mode 100644 index 00000000000..03e72fe0f86 --- /dev/null +++ b/src/org/rascalmpl/ast/EvalCommand.java @@ -0,0 +1,331 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class EvalCommand extends AbstractAST { + public EvalCommand(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDeclaration() { + return false; + } + + public org.rascalmpl.ast.Declaration getDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasImported() { + return false; + } + + public org.rascalmpl.ast.Import getImported() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDeclaration() { + return false; + } + + static public class Declaration extends EvalCommand { + // Production: sig("Declaration",[arg("org.rascalmpl.ast.Declaration","declaration")],breakable=false) + + + private final org.rascalmpl.ast.Declaration declaration; + + public Declaration(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declaration declaration) { + super(src, node); + + this.declaration = declaration; + } + + @Override + public boolean isDeclaration() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitEvalCommandDeclaration(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Declaration)) { + return false; + } + Declaration tmp = (Declaration) o; + return true && tmp.declaration.equals(this.declaration) ; + } + + @Override + public int hashCode() { + return 397 + 641 * declaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Declaration getDeclaration() { + return this.declaration; + } + + @Override + public boolean hasDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declaration)); + } + + } + public boolean isImport() { + return false; + } + + static public class Import extends EvalCommand { + // Production: sig("Import",[arg("org.rascalmpl.ast.Import","imported")],breakable=false) + + + private final org.rascalmpl.ast.Import imported; + + public Import(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Import imported) { + super(src, node); + + this.imported = imported; + } + + @Override + public boolean isImport() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitEvalCommandImport(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = imported.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + imported.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Import)) { + return false; + } + Import tmp = (Import) o; + return true && tmp.imported.equals(this.imported) ; + } + + @Override + public int hashCode() { + return 197 + 233 * imported.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Import getImported() { + return this.imported; + } + + @Override + public boolean hasImported() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(imported)); + } + + } + public boolean isOutput() { + return false; + } + + static public class Output extends EvalCommand { + // Production: sig("Output",[],breakable=false) + + + + public Output(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isOutput() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitEvalCommandOutput(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Output)) { + return false; + } + Output tmp = (Output) o; + return true ; + } + + @Override + public int hashCode() { + return 647 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isStatement() { + return false; + } + + static public class Statement extends EvalCommand { + // Production: sig("Statement",[arg("org.rascalmpl.ast.Statement","statement")],breakable=false) + + + private final org.rascalmpl.ast.Statement statement; + + public Statement(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.statement = statement; + } + + @Override + public boolean isStatement() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitEvalCommandStatement(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Statement)) { + return false; + } + Statement tmp = (Statement) o; + return true && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 157 + 83 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statement)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Expression.java b/src/org/rascalmpl/ast/Expression.java new file mode 100644 index 00000000000..11ec0392f4b --- /dev/null +++ b/src/org/rascalmpl/ast/Expression.java @@ -0,0 +1,6955 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Expression extends AbstractAST { + public Expression(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasArguments() { + return false; + } + + public java.util.List getArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElements() { + return false; + } + + public java.util.List getElements() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElements0() { + return false; + } + + public java.util.List getElements0() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasGenerators() { + return false; + } + + public java.util.List getGenerators() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSubscripts() { + return false; + } + + public java.util.List getSubscripts() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFields() { + return false; + } + + public java.util.List getFields() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMappings() { + return false; + } + + public java.util.List getMappings() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatements() { + return false; + } + + public java.util.List getStatements() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatements0() { + return false; + } + + public java.util.List getStatements0() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasComprehension() { + return false; + } + + public org.rascalmpl.ast.Comprehension getComprehension() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasConcrete() { + return false; + } + + public org.rascalmpl.ast.Concrete getConcrete() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasArgument() { + return false; + } + + public org.rascalmpl.ast.Expression getArgument() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCondition() { + return false; + } + + public org.rascalmpl.ast.Expression getCondition() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDefinitions() { + return false; + } + + public org.rascalmpl.ast.Expression getDefinitions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElseExp() { + return false; + } + + public org.rascalmpl.ast.Expression getElseExp() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFirst() { + return false; + } + + public org.rascalmpl.ast.Expression getFirst() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasInit() { + return false; + } + + public org.rascalmpl.ast.Expression getInit() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLast() { + return false; + } + + public org.rascalmpl.ast.Expression getLast() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLhs() { + return false; + } + + public org.rascalmpl.ast.Expression getLhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPattern() { + return false; + } + + public org.rascalmpl.ast.Expression getPattern() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasReplacement() { + return false; + } + + public org.rascalmpl.ast.Expression getReplacement() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasResult() { + return false; + } + + public org.rascalmpl.ast.Expression getResult() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRhs() { + return false; + } + + public org.rascalmpl.ast.Expression getRhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSecond() { + return false; + } + + public org.rascalmpl.ast.Expression getSecond() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSymbol() { + return false; + } + + public org.rascalmpl.ast.Expression getSymbol() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasThenExp() { + return false; + } + + public org.rascalmpl.ast.Expression getThenExp() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasValue() { + return false; + } + + public org.rascalmpl.ast.Expression getValue() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasKeywordArguments() { + return false; + } + + public org.rascalmpl.ast.KeywordArguments_Expression getKeywordArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLabel() { + return false; + } + + public org.rascalmpl.ast.Label getLabel() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLiteral() { + return false; + } + + public org.rascalmpl.ast.Literal getLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasField() { + return false; + } + + public org.rascalmpl.ast.Name getField() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasKey() { + return false; + } + + public org.rascalmpl.ast.Name getKey() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptFirst() { + return false; + } + + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptLast() { + return false; + } + + public org.rascalmpl.ast.OptionalExpression getOptLast() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasParameters() { + return false; + } + + public org.rascalmpl.ast.Parameters getParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasQualifiedName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getQualifiedName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVisit() { + return false; + } + + public org.rascalmpl.ast.Visit getVisit() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAddition() { + return false; + } + + static public class Addition extends Expression { + // Production: sig("Addition",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Addition(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isAddition() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAddition(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Addition)) { + return false; + } + Addition tmp = (Addition) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 271 + 41 * lhs.hashCode() + 919 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isAll() { + return false; + } + + static public class All extends Expression { + // Production: sig("All",[arg("java.util.List\","generators")],breakable=false) + + + private final java.util.List generators; + + public All(ISourceLocation src, IConstructor node , java.util.List generators) { + super(src, node); + + this.generators = generators; + } + + @Override + public boolean isAll() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAll(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof All)) { + return false; + } + All tmp = (All) o; + return true && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 673 + 499 * generators.hashCode() ; + } + + + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(generators)); + } + + } + public boolean isAnd() { + return false; + } + + static public class And extends Expression { + // Production: sig("And",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public And(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isAnd() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAnd(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof And)) { + return false; + } + And tmp = (And) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 937 + 443 * lhs.hashCode() + 523 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isAnti() { + return false; + } + + static public class Anti extends Expression { + // Production: sig("Anti",[arg("org.rascalmpl.ast.Expression","pattern")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + + public Anti(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern) { + super(src, node); + + this.pattern = pattern; + } + + @Override + public boolean isAnti() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAnti(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Anti)) { + return false; + } + Anti tmp = (Anti) o; + return true && tmp.pattern.equals(this.pattern) ; + } + + @Override + public int hashCode() { + return 881 + 401 * pattern.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern)); + } + + } + public boolean isAny() { + return false; + } + + static public class Any extends Expression { + // Production: sig("Any",[arg("java.util.List\","generators")],breakable=false) + + + private final java.util.List generators; + + public Any(ISourceLocation src, IConstructor node , java.util.List generators) { + super(src, node); + + this.generators = generators; + } + + @Override + public boolean isAny() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAny(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Any)) { + return false; + } + Any tmp = (Any) o; + return true && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 953 + 2 * generators.hashCode() ; + } + + + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(generators)); + } + + } + public boolean isAppendAfter() { + return false; + } + + static public class AppendAfter extends Expression { + // Production: sig("AppendAfter",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public AppendAfter(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isAppendAfter() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAppendAfter(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof AppendAfter)) { + return false; + } + AppendAfter tmp = (AppendAfter) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 271 + 599 * lhs.hashCode() + 383 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isAsType() { + return false; + } + + static public class AsType extends Expression { + // Production: sig("AsType",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Expression argument; + + public AsType(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.type = type; + this.argument = argument; + } + + @Override + public boolean isAsType() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionAsType(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof AsType)) { + return false; + } + AsType tmp = (AsType) o; + return true && tmp.type.equals(this.type) && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 167 + 199 * type.hashCode() + 103 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(argument)); + } + + } + public boolean isBracket() { + return false; + } + + static public class Bracket extends Expression { + // Production: sig("Bracket",[arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + + public Bracket(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isBracket() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionBracket(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bracket)) { + return false; + } + Bracket tmp = (Bracket) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 149 + 709 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + + } + public boolean isCallOrTree() { + return false; + } + + static public class CallOrTree extends Expression { + // Production: sig("CallOrTree",[arg("org.rascalmpl.ast.Expression","expression"),arg("java.util.List\","arguments"),arg("org.rascalmpl.ast.KeywordArguments_Expression","keywordArguments")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final java.util.List arguments; + private final org.rascalmpl.ast.KeywordArguments_Expression keywordArguments; + + public CallOrTree(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, java.util.List arguments, org.rascalmpl.ast.KeywordArguments_Expression keywordArguments) { + super(src, node); + + this.expression = expression; + this.arguments = arguments; + this.keywordArguments = keywordArguments; + } + + @Override + public boolean isCallOrTree() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionCallOrTree(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : arguments) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = keywordArguments.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + keywordArguments.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof CallOrTree)) { + return false; + } + CallOrTree tmp = (CallOrTree) o; + return true && tmp.expression.equals(this.expression) && tmp.arguments.equals(this.arguments) && tmp.keywordArguments.equals(this.keywordArguments) ; + } + + @Override + public int hashCode() { + return 151 + 13 * expression.hashCode() + 997 * arguments.hashCode() + 373 * keywordArguments.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public java.util.List getArguments() { + return this.arguments; + } + + @Override + public boolean hasArguments() { + return true; + } + @Override + public org.rascalmpl.ast.KeywordArguments_Expression getKeywordArguments() { + return this.keywordArguments; + } + + @Override + public boolean hasKeywordArguments() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(arguments), clone(keywordArguments)); + } + + } + public boolean isClosure() { + return false; + } + + static public class Closure extends Expression { + // Production: sig("Closure",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Parameters","parameters"),arg("java.util.List\","statements")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Parameters parameters; + private final java.util.List statements; + + public Closure(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Parameters parameters, java.util.List statements) { + super(src, node); + + this.type = type; + this.parameters = parameters; + this.statements = statements; + } + + @Override + public boolean isClosure() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionClosure(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = parameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + parameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : statements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Closure)) { + return false; + } + Closure tmp = (Closure) o; + return true && tmp.type.equals(this.type) && tmp.parameters.equals(this.parameters) && tmp.statements.equals(this.statements) ; + } + + @Override + public int hashCode() { + return 257 + 271 * type.hashCode() + 811 * parameters.hashCode() + 67 * statements.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Parameters getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + @Override + public java.util.List getStatements() { + return this.statements; + } + + @Override + public boolean hasStatements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(parameters), clone(statements)); + } + + } + public boolean isComposition() { + return false; + } + + static public class Composition extends Expression { + // Production: sig("Composition",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Composition(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isComposition() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionComposition(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Composition)) { + return false; + } + Composition tmp = (Composition) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 643 + 251 * lhs.hashCode() + 521 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isComprehension() { + return false; + } + + static public class Comprehension extends Expression { + // Production: sig("Comprehension",[arg("org.rascalmpl.ast.Comprehension","comprehension")],breakable=false) + + + private final org.rascalmpl.ast.Comprehension comprehension; + + public Comprehension(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Comprehension comprehension) { + super(src, node); + + this.comprehension = comprehension; + } + + @Override + public boolean isComprehension() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionComprehension(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = comprehension.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + comprehension.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Comprehension)) { + return false; + } + Comprehension tmp = (Comprehension) o; + return true && tmp.comprehension.equals(this.comprehension) ; + } + + @Override + public int hashCode() { + return 797 + 131 * comprehension.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Comprehension getComprehension() { + return this.comprehension; + } + + @Override + public boolean hasComprehension() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(comprehension)); + } + + } + public boolean isConcrete() { + return false; + } + + static public class Concrete extends Expression { + // Production: sig("Concrete",[arg("org.rascalmpl.ast.Concrete","concrete")],breakable=false) + + + private final org.rascalmpl.ast.Concrete concrete; + + public Concrete(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Concrete concrete) { + super(src, node); + + this.concrete = concrete; + } + + @Override + public boolean isConcrete() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionConcrete(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = concrete.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + concrete.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Concrete)) { + return false; + } + Concrete tmp = (Concrete) o; + return true && tmp.concrete.equals(this.concrete) ; + } + + @Override + public int hashCode() { + return 499 + 73 * concrete.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Concrete getConcrete() { + return this.concrete; + } + + @Override + public boolean hasConcrete() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(concrete)); + } + + } + public boolean isDescendant() { + return false; + } + + static public class Descendant extends Expression { + // Production: sig("Descendant",[arg("org.rascalmpl.ast.Expression","pattern")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + + public Descendant(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern) { + super(src, node); + + this.pattern = pattern; + } + + @Override + public boolean isDescendant() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionDescendant(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Descendant)) { + return false; + } + Descendant tmp = (Descendant) o; + return true && tmp.pattern.equals(this.pattern) ; + } + + @Override + public int hashCode() { + return 877 + 757 * pattern.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern)); + } + + } + public boolean isDivision() { + return false; + } + + static public class Division extends Expression { + // Production: sig("Division",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Division(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isDivision() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionDivision(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Division)) { + return false; + } + Division tmp = (Division) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 269 + 241 * lhs.hashCode() + 353 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isEnumerator() { + return false; + } + + static public class Enumerator extends Expression { + // Production: sig("Enumerator",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Expression expression; + + public Enumerator(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.pattern = pattern; + this.expression = expression; + } + + @Override + public boolean isEnumerator() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionEnumerator(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Enumerator)) { + return false; + } + Enumerator tmp = (Enumerator) o; + return true && tmp.pattern.equals(this.pattern) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 229 + 659 * pattern.hashCode() + 743 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(expression)); + } + + } + public boolean isEquals() { + return false; + } + + static public class Equals extends Expression { + // Production: sig("Equals",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Equals(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isEquals() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionEquals(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Equals)) { + return false; + } + Equals tmp = (Equals) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 223 + 193 * lhs.hashCode() + 743 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isEquivalence() { + return false; + } + + static public class Equivalence extends Expression { + // Production: sig("Equivalence",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Equivalence(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isEquivalence() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionEquivalence(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Equivalence)) { + return false; + } + Equivalence tmp = (Equivalence) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 863 + 263 * lhs.hashCode() + 151 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isFieldAccess() { + return false; + } + + static public class FieldAccess extends Expression { + // Production: sig("FieldAccess",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","field")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name field; + + public FieldAccess(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name field) { + super(src, node); + + this.expression = expression; + this.field = field; + } + + @Override + public boolean isFieldAccess() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionFieldAccess(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = field.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + field.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FieldAccess)) { + return false; + } + FieldAccess tmp = (FieldAccess) o; + return true && tmp.expression.equals(this.expression) && tmp.field.equals(this.field) ; + } + + @Override + public int hashCode() { + return 421 + 619 * expression.hashCode() + 179 * field.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getField() { + return this.field; + } + + @Override + public boolean hasField() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(field)); + } + + } + public boolean isFieldProject() { + return false; + } + + static public class FieldProject extends Expression { + // Production: sig("FieldProject",[arg("org.rascalmpl.ast.Expression","expression"),arg("java.util.List\","fields")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final java.util.List fields; + + public FieldProject(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, java.util.List fields) { + super(src, node); + + this.expression = expression; + this.fields = fields; + } + + @Override + public boolean isFieldProject() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionFieldProject(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : fields) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FieldProject)) { + return false; + } + FieldProject tmp = (FieldProject) o; + return true && tmp.expression.equals(this.expression) && tmp.fields.equals(this.fields) ; + } + + @Override + public int hashCode() { + return 757 + 991 * expression.hashCode() + 71 * fields.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public java.util.List getFields() { + return this.fields; + } + + @Override + public boolean hasFields() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(fields)); + } + + } + public boolean isFieldUpdate() { + return false; + } + + static public class FieldUpdate extends Expression { + // Production: sig("FieldUpdate",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","key"),arg("org.rascalmpl.ast.Expression","replacement")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name key; + private final org.rascalmpl.ast.Expression replacement; + + public FieldUpdate(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name key, org.rascalmpl.ast.Expression replacement) { + super(src, node); + + this.expression = expression; + this.key = key; + this.replacement = replacement; + } + + @Override + public boolean isFieldUpdate() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionFieldUpdate(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = key.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + key.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = replacement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + replacement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FieldUpdate)) { + return false; + } + FieldUpdate tmp = (FieldUpdate) o; + return true && tmp.expression.equals(this.expression) && tmp.key.equals(this.key) && tmp.replacement.equals(this.replacement) ; + } + + @Override + public int hashCode() { + return 199 + 3 * expression.hashCode() + 991 * key.hashCode() + 541 * replacement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getKey() { + return this.key; + } + + @Override + public boolean hasKey() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getReplacement() { + return this.replacement; + } + + @Override + public boolean hasReplacement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(key), clone(replacement)); + } + + } + public boolean isGetAnnotation() { + return false; + } + + static public class GetAnnotation extends Expression { + // Production: sig("GetAnnotation",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name name; + + public GetAnnotation(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name name) { + super(src, node); + + this.expression = expression; + this.name = name; + } + + @Override + public boolean isGetAnnotation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionGetAnnotation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GetAnnotation)) { + return false; + } + GetAnnotation tmp = (GetAnnotation) o; + return true && tmp.expression.equals(this.expression) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 467 + 7 * expression.hashCode() + 809 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(name)); + } + + } + public boolean isGreaterThan() { + return false; + } + + static public class GreaterThan extends Expression { + // Production: sig("GreaterThan",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public GreaterThan(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isGreaterThan() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionGreaterThan(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GreaterThan)) { + return false; + } + GreaterThan tmp = (GreaterThan) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 401 + 953 * lhs.hashCode() + 967 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isGreaterThanOrEq() { + return false; + } + + static public class GreaterThanOrEq extends Expression { + // Production: sig("GreaterThanOrEq",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public GreaterThanOrEq(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isGreaterThanOrEq() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionGreaterThanOrEq(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GreaterThanOrEq)) { + return false; + } + GreaterThanOrEq tmp = (GreaterThanOrEq) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 797 + 709 * lhs.hashCode() + 223 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isHas() { + return false; + } + + static public class Has extends Expression { + // Production: sig("Has",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name name; + + public Has(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name name) { + super(src, node); + + this.expression = expression; + this.name = name; + } + + @Override + public boolean isHas() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionHas(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Has)) { + return false; + } + Has tmp = (Has) o; + return true && tmp.expression.equals(this.expression) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 499 + 227 * expression.hashCode() + 577 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(name)); + } + + } + public boolean isIfDefinedOtherwise() { + return false; + } + + static public class IfDefinedOtherwise extends Expression { + // Production: sig("IfDefinedOtherwise",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public IfDefinedOtherwise(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isIfDefinedOtherwise() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIfDefinedOtherwise(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfDefinedOtherwise)) { + return false; + } + IfDefinedOtherwise tmp = (IfDefinedOtherwise) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 163 + 151 * lhs.hashCode() + 467 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isIfThenElse() { + return false; + } + + static public class IfThenElse extends Expression { + // Production: sig("IfThenElse",[arg("org.rascalmpl.ast.Expression","condition"),arg("org.rascalmpl.ast.Expression","thenExp"),arg("org.rascalmpl.ast.Expression","elseExp")],breakable=false) + + + private final org.rascalmpl.ast.Expression condition; + private final org.rascalmpl.ast.Expression thenExp; + private final org.rascalmpl.ast.Expression elseExp; + + public IfThenElse(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression condition, org.rascalmpl.ast.Expression thenExp, org.rascalmpl.ast.Expression elseExp) { + super(src, node); + + this.condition = condition; + this.thenExp = thenExp; + this.elseExp = elseExp; + } + + @Override + public boolean isIfThenElse() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIfThenElse(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = condition.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + condition.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = thenExp.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + thenExp.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = elseExp.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + elseExp.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfThenElse)) { + return false; + } + IfThenElse tmp = (IfThenElse) o; + return true && tmp.condition.equals(this.condition) && tmp.thenExp.equals(this.thenExp) && tmp.elseExp.equals(this.elseExp) ; + } + + @Override + public int hashCode() { + return 641 + 887 * condition.hashCode() + 491 * thenExp.hashCode() + 619 * elseExp.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getCondition() { + return this.condition; + } + + @Override + public boolean hasCondition() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getThenExp() { + return this.thenExp; + } + + @Override + public boolean hasThenExp() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getElseExp() { + return this.elseExp; + } + + @Override + public boolean hasElseExp() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(condition), clone(thenExp), clone(elseExp)); + } + + } + public boolean isImplication() { + return false; + } + + static public class Implication extends Expression { + // Production: sig("Implication",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Implication(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isImplication() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionImplication(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Implication)) { + return false; + } + Implication tmp = (Implication) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 421 + 79 * lhs.hashCode() + 173 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isIn() { + return false; + } + + static public class In extends Expression { + // Production: sig("In",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public In(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isIn() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIn(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof In)) { + return false; + } + In tmp = (In) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 911 + 239 * lhs.hashCode() + 613 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isInsertBefore() { + return false; + } + + static public class InsertBefore extends Expression { + // Production: sig("InsertBefore",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public InsertBefore(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isInsertBefore() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionInsertBefore(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof InsertBefore)) { + return false; + } + InsertBefore tmp = (InsertBefore) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 71 + 167 * lhs.hashCode() + 491 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isIntersection() { + return false; + } + + static public class Intersection extends Expression { + // Production: sig("Intersection",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Intersection(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isIntersection() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIntersection(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Intersection)) { + return false; + } + Intersection tmp = (Intersection) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 509 + 179 * lhs.hashCode() + 773 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isIs() { + return false; + } + + static public class Is extends Expression { + // Production: sig("Is",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name name; + + public Is(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name name) { + super(src, node); + + this.expression = expression; + this.name = name; + } + + @Override + public boolean isIs() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIs(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Is)) { + return false; + } + Is tmp = (Is) o; + return true && tmp.expression.equals(this.expression) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 337 + 181 * expression.hashCode() + 911 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(name)); + } + + } + public boolean isIsDefined() { + return false; + } + + static public class IsDefined extends Expression { + // Production: sig("IsDefined",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public IsDefined(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isIsDefined() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIsDefined(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IsDefined)) { + return false; + } + IsDefined tmp = (IsDefined) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 239 + 401 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isIt() { + return false; + } + + static public class It extends Expression { + // Production: sig("It",[],breakable=false) + + + + public It(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isIt() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionIt(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof It)) { + return false; + } + It tmp = (It) o; + return true ; + } + + @Override + public int hashCode() { + return 607 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isJoin() { + return false; + } + + static public class Join extends Expression { + // Production: sig("Join",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Join(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isJoin() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionJoin(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Join)) { + return false; + } + Join tmp = (Join) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 599 + 283 * lhs.hashCode() + 881 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isLessThan() { + return false; + } + + static public class LessThan extends Expression { + // Production: sig("LessThan",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public LessThan(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isLessThan() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionLessThan(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof LessThan)) { + return false; + } + LessThan tmp = (LessThan) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 449 + 457 * lhs.hashCode() + 967 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isLessThanOrEq() { + return false; + } + + static public class LessThanOrEq extends Expression { + // Production: sig("LessThanOrEq",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public LessThanOrEq(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isLessThanOrEq() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionLessThanOrEq(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof LessThanOrEq)) { + return false; + } + LessThanOrEq tmp = (LessThanOrEq) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 991 + 683 * lhs.hashCode() + 31 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isList() { + return false; + } + + static public class List extends Expression { + // Production: sig("List",[arg("java.util.List\","elements0")],breakable=false) + + + private final java.util.List elements0; + + public List(ISourceLocation src, IConstructor node , java.util.List elements0) { + super(src, node); + + this.elements0 = elements0; + } + + @Override + public boolean isList() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionList(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : elements0) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof List)) { + return false; + } + List tmp = (List) o; + return true && tmp.elements0.equals(this.elements0) ; + } + + @Override + public int hashCode() { + return 71 + 223 * elements0.hashCode() ; + } + + + @Override + public java.util.List getElements0() { + return this.elements0; + } + + @Override + public boolean hasElements0() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(elements0)); + } + + } + public boolean isLiteral() { + return false; + } + + static public class Literal extends Expression { + // Production: sig("Literal",[arg("org.rascalmpl.ast.Literal","literal")],breakable=false) + + + private final org.rascalmpl.ast.Literal literal; + + public Literal(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Literal literal) { + super(src, node); + + this.literal = literal; + } + + @Override + public boolean isLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = literal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + literal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Literal)) { + return false; + } + Literal tmp = (Literal) o; + return true && tmp.literal.equals(this.literal) ; + } + + @Override + public int hashCode() { + return 919 + 139 * literal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Literal getLiteral() { + return this.literal; + } + + @Override + public boolean hasLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(literal)); + } + + } + public boolean isMap() { + return false; + } + + static public class Map extends Expression { + // Production: sig("Map",[arg("java.util.List\","mappings")],breakable=false) + + + private final java.util.List mappings; + + public Map(ISourceLocation src, IConstructor node , java.util.List mappings) { + super(src, node); + + this.mappings = mappings; + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionMap(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : mappings) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Map)) { + return false; + } + Map tmp = (Map) o; + return true && tmp.mappings.equals(this.mappings) ; + } + + @Override + public int hashCode() { + return 907 + 467 * mappings.hashCode() ; + } + + + @Override + public java.util.List getMappings() { + return this.mappings; + } + + @Override + public boolean hasMappings() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mappings)); + } + + } + public boolean isMatch() { + return false; + } + + static public class Match extends Expression { + // Production: sig("Match",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Expression expression; + + public Match(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.pattern = pattern; + this.expression = expression; + } + + @Override + public boolean isMatch() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionMatch(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Match)) { + return false; + } + Match tmp = (Match) o; + return true && tmp.pattern.equals(this.pattern) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 971 + 811 * pattern.hashCode() + 199 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(expression)); + } + + } + public boolean isModulo() { + return false; + } + + static public class Modulo extends Expression { + // Production: sig("Modulo",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Modulo(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isModulo() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionModulo(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Modulo)) { + return false; + } + Modulo tmp = (Modulo) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 307 + 2 * lhs.hashCode() + 67 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isMultiVariable() { + return false; + } + + static public class MultiVariable extends Expression { + // Production: sig("MultiVariable",[arg("org.rascalmpl.ast.QualifiedName","qualifiedName")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName qualifiedName; + + public MultiVariable(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName qualifiedName) { + super(src, node); + + this.qualifiedName = qualifiedName; + } + + @Override + public boolean isMultiVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionMultiVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = qualifiedName.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + qualifiedName.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MultiVariable)) { + return false; + } + MultiVariable tmp = (MultiVariable) o; + return true && tmp.qualifiedName.equals(this.qualifiedName) ; + } + + @Override + public int hashCode() { + return 641 + 233 * qualifiedName.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getQualifiedName() { + return this.qualifiedName; + } + + @Override + public boolean hasQualifiedName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(qualifiedName)); + } + + } + public boolean isNegation() { + return false; + } + + static public class Negation extends Expression { + // Production: sig("Negation",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public Negation(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isNegation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNegation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Negation)) { + return false; + } + Negation tmp = (Negation) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 37 + 251 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isNegative() { + return false; + } + + static public class Negative extends Expression { + // Production: sig("Negative",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public Negative(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isNegative() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNegative(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Negative)) { + return false; + } + Negative tmp = (Negative) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 239 + 569 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isNoMatch() { + return false; + } + + static public class NoMatch extends Expression { + // Production: sig("NoMatch",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Expression expression; + + public NoMatch(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.pattern = pattern; + this.expression = expression; + } + + @Override + public boolean isNoMatch() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNoMatch(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NoMatch)) { + return false; + } + NoMatch tmp = (NoMatch) o; + return true && tmp.pattern.equals(this.pattern) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 61 + 3 * pattern.hashCode() + 503 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(expression)); + } + + } + public boolean isNonEmptyBlock() { + return false; + } + + static public class NonEmptyBlock extends Expression { + // Production: sig("NonEmptyBlock",[arg("java.util.List\","statements")],breakable=false) + + + private final java.util.List statements; + + public NonEmptyBlock(ISourceLocation src, IConstructor node , java.util.List statements) { + super(src, node); + + this.statements = statements; + } + + @Override + public boolean isNonEmptyBlock() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNonEmptyBlock(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : statements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonEmptyBlock)) { + return false; + } + NonEmptyBlock tmp = (NonEmptyBlock) o; + return true && tmp.statements.equals(this.statements) ; + } + + @Override + public int hashCode() { + return 757 + 877 * statements.hashCode() ; + } + + + @Override + public java.util.List getStatements() { + return this.statements; + } + + @Override + public boolean hasStatements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statements)); + } + + } + public boolean isNonEquals() { + return false; + } + + static public class NonEquals extends Expression { + // Production: sig("NonEquals",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public NonEquals(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isNonEquals() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNonEquals(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonEquals)) { + return false; + } + NonEquals tmp = (NonEquals) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 331 + 2 * lhs.hashCode() + 577 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isNotIn() { + return false; + } + + static public class NotIn extends Expression { + // Production: sig("NotIn",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public NotIn(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isNotIn() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionNotIn(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NotIn)) { + return false; + } + NotIn tmp = (NotIn) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 3 + 521 * lhs.hashCode() + 31 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isOr() { + return false; + } + + static public class Or extends Expression { + // Production: sig("Or",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Or(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isOr() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionOr(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Or)) { + return false; + } + Or tmp = (Or) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 23 + 863 * lhs.hashCode() + 5 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isProduct() { + return false; + } + + static public class Product extends Expression { + // Production: sig("Product",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Product(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isProduct() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionProduct(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Product)) { + return false; + } + Product tmp = (Product) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 313 + 853 * lhs.hashCode() + 151 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isQualifiedName() { + return false; + } + + static public class QualifiedName extends Expression { + // Production: sig("QualifiedName",[arg("org.rascalmpl.ast.QualifiedName","qualifiedName")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName qualifiedName; + + public QualifiedName(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName qualifiedName) { + super(src, node); + + this.qualifiedName = qualifiedName; + } + + @Override + public boolean isQualifiedName() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionQualifiedName(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = qualifiedName.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + qualifiedName.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof QualifiedName)) { + return false; + } + QualifiedName tmp = (QualifiedName) o; + return true && tmp.qualifiedName.equals(this.qualifiedName) ; + } + + @Override + public int hashCode() { + return 761 + 641 * qualifiedName.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getQualifiedName() { + return this.qualifiedName; + } + + @Override + public boolean hasQualifiedName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(qualifiedName)); + } + + } + public boolean isRange() { + return false; + } + + static public class Range extends Expression { + // Production: sig("Range",[arg("org.rascalmpl.ast.Expression","first"),arg("org.rascalmpl.ast.Expression","last")],breakable=false) + + + private final org.rascalmpl.ast.Expression first; + private final org.rascalmpl.ast.Expression last; + + public Range(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression first, org.rascalmpl.ast.Expression last) { + super(src, node); + + this.first = first; + this.last = last; + } + + @Override + public boolean isRange() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionRange(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = first.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + first.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = last.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + last.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Range)) { + return false; + } + Range tmp = (Range) o; + return true && tmp.first.equals(this.first) && tmp.last.equals(this.last) ; + } + + @Override + public int hashCode() { + return 163 + 647 * first.hashCode() + 269 * last.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getFirst() { + return this.first; + } + + @Override + public boolean hasFirst() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getLast() { + return this.last; + } + + @Override + public boolean hasLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(first), clone(last)); + } + + } + public boolean isReducer() { + return false; + } + + static public class Reducer extends Expression { + // Production: sig("Reducer",[arg("org.rascalmpl.ast.Expression","init"),arg("org.rascalmpl.ast.Expression","result"),arg("java.util.List\","generators")],breakable=false) + + + private final org.rascalmpl.ast.Expression init; + private final org.rascalmpl.ast.Expression result; + private final java.util.List generators; + + public Reducer(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression init, org.rascalmpl.ast.Expression result, java.util.List generators) { + super(src, node); + + this.init = init; + this.result = result; + this.generators = generators; + } + + @Override + public boolean isReducer() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionReducer(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = init.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + init.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = result.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + result.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Reducer)) { + return false; + } + Reducer tmp = (Reducer) o; + return true && tmp.init.equals(this.init) && tmp.result.equals(this.result) && tmp.generators.equals(this.generators) ; + } + + @Override + public int hashCode() { + return 107 + 163 * init.hashCode() + 17 * result.hashCode() + 443 * generators.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getInit() { + return this.init; + } + + @Override + public boolean hasInit() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getResult() { + return this.result; + } + + @Override + public boolean hasResult() { + return true; + } + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(init), clone(result), clone(generators)); + } + + } + public boolean isReifiedType() { + return false; + } + + static public class ReifiedType extends Expression { + // Production: sig("ReifiedType",[arg("org.rascalmpl.ast.Expression","symbol"),arg("org.rascalmpl.ast.Expression","definitions")],breakable=false) + + + private final org.rascalmpl.ast.Expression symbol; + private final org.rascalmpl.ast.Expression definitions; + + public ReifiedType(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression symbol, org.rascalmpl.ast.Expression definitions) { + super(src, node); + + this.symbol = symbol; + this.definitions = definitions; + } + + @Override + public boolean isReifiedType() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionReifiedType(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = definitions.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + definitions.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ReifiedType)) { + return false; + } + ReifiedType tmp = (ReifiedType) o; + return true && tmp.symbol.equals(this.symbol) && tmp.definitions.equals(this.definitions) ; + } + + @Override + public int hashCode() { + return 23 + 17 * symbol.hashCode() + 557 * definitions.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getDefinitions() { + return this.definitions; + } + + @Override + public boolean hasDefinitions() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(definitions)); + } + + } + public boolean isReifyType() { + return false; + } + + static public class ReifyType extends Expression { + // Production: sig("ReifyType",[arg("org.rascalmpl.ast.Type","type")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + + public ReifyType(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type) { + super(src, node); + + this.type = type; + } + + @Override + public boolean isReifyType() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionReifyType(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ReifyType)) { + return false; + } + ReifyType tmp = (ReifyType) o; + return true && tmp.type.equals(this.type) ; + } + + @Override + public int hashCode() { + return 251 + 191 * type.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type)); + } + + } + public boolean isRemainder() { + return false; + } + + static public class Remainder extends Expression { + // Production: sig("Remainder",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Remainder(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isRemainder() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionRemainder(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Remainder)) { + return false; + } + Remainder tmp = (Remainder) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 563 + 23 * lhs.hashCode() + 953 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isSet() { + return false; + } + + static public class Set extends Expression { + // Production: sig("Set",[arg("java.util.List\","elements0")],breakable=false) + + + private final java.util.List elements0; + + public Set(ISourceLocation src, IConstructor node , java.util.List elements0) { + super(src, node); + + this.elements0 = elements0; + } + + @Override + public boolean isSet() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSet(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : elements0) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Set)) { + return false; + } + Set tmp = (Set) o; + return true && tmp.elements0.equals(this.elements0) ; + } + + @Override + public int hashCode() { + return 863 + 521 * elements0.hashCode() ; + } + + + @Override + public java.util.List getElements0() { + return this.elements0; + } + + @Override + public boolean hasElements0() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(elements0)); + } + + } + public boolean isSetAnnotation() { + return false; + } + + static public class SetAnnotation extends Expression { + // Production: sig("SetAnnotation",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","value")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression value; + + public SetAnnotation(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression value) { + super(src, node); + + this.expression = expression; + this.name = name; + this.value = value; + } + + @Override + public boolean isSetAnnotation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSetAnnotation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = value.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + value.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SetAnnotation)) { + return false; + } + SetAnnotation tmp = (SetAnnotation) o; + return true && tmp.expression.equals(this.expression) && tmp.name.equals(this.name) && tmp.value.equals(this.value) ; + } + + @Override + public int hashCode() { + return 977 + 269 * expression.hashCode() + 373 * name.hashCode() + 373 * value.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getValue() { + return this.value; + } + + @Override + public boolean hasValue() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(name), clone(value)); + } + + } + public boolean isSlice() { + return false; + } + + static public class Slice extends Expression { + // Production: sig("Slice",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.OptionalExpression","optFirst"),arg("org.rascalmpl.ast.OptionalExpression","optLast")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.OptionalExpression optFirst; + private final org.rascalmpl.ast.OptionalExpression optLast; + + public Slice(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.OptionalExpression optFirst, org.rascalmpl.ast.OptionalExpression optLast) { + super(src, node); + + this.expression = expression; + this.optFirst = optFirst; + this.optLast = optLast; + } + + @Override + public boolean isSlice() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSlice(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optFirst.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optFirst.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optLast.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optLast.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Slice)) { + return false; + } + Slice tmp = (Slice) o; + return true && tmp.expression.equals(this.expression) && tmp.optFirst.equals(this.optFirst) && tmp.optLast.equals(this.optLast) ; + } + + @Override + public int hashCode() { + return 809 + 103 * expression.hashCode() + 79 * optFirst.hashCode() + 67 * optLast.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + return this.optFirst; + } + + @Override + public boolean hasOptFirst() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptLast() { + return this.optLast; + } + + @Override + public boolean hasOptLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(optFirst), clone(optLast)); + } + + } + public boolean isSliceStep() { + return false; + } + + static public class SliceStep extends Expression { + // Production: sig("SliceStep",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.OptionalExpression","optFirst"),arg("org.rascalmpl.ast.Expression","second"),arg("org.rascalmpl.ast.OptionalExpression","optLast")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.OptionalExpression optFirst; + private final org.rascalmpl.ast.Expression second; + private final org.rascalmpl.ast.OptionalExpression optLast; + + public SliceStep(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.OptionalExpression optFirst, org.rascalmpl.ast.Expression second, org.rascalmpl.ast.OptionalExpression optLast) { + super(src, node); + + this.expression = expression; + this.optFirst = optFirst; + this.second = second; + this.optLast = optLast; + } + + @Override + public boolean isSliceStep() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSliceStep(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optFirst.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optFirst.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = second.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + second.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = optLast.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optLast.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SliceStep)) { + return false; + } + SliceStep tmp = (SliceStep) o; + return true && tmp.expression.equals(this.expression) && tmp.optFirst.equals(this.optFirst) && tmp.second.equals(this.second) && tmp.optLast.equals(this.optLast) ; + } + + @Override + public int hashCode() { + return 457 + 509 * expression.hashCode() + 337 * optFirst.hashCode() + 269 * second.hashCode() + 277 * optLast.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptFirst() { + return this.optFirst; + } + + @Override + public boolean hasOptFirst() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getSecond() { + return this.second; + } + + @Override + public boolean hasSecond() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalExpression getOptLast() { + return this.optLast; + } + + @Override + public boolean hasOptLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(optFirst), clone(second), clone(optLast)); + } + + } + public boolean isSplice() { + return false; + } + + static public class Splice extends Expression { + // Production: sig("Splice",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public Splice(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isSplice() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSplice(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Splice)) { + return false; + } + Splice tmp = (Splice) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 983 + 613 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isSplicePlus() { + return false; + } + + static public class SplicePlus extends Expression { + // Production: sig("SplicePlus",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public SplicePlus(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isSplicePlus() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSplicePlus(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SplicePlus)) { + return false; + } + SplicePlus tmp = (SplicePlus) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 449 + 227 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isStepRange() { + return false; + } + + static public class StepRange extends Expression { + // Production: sig("StepRange",[arg("org.rascalmpl.ast.Expression","first"),arg("org.rascalmpl.ast.Expression","second"),arg("org.rascalmpl.ast.Expression","last")],breakable=false) + + + private final org.rascalmpl.ast.Expression first; + private final org.rascalmpl.ast.Expression second; + private final org.rascalmpl.ast.Expression last; + + public StepRange(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression first, org.rascalmpl.ast.Expression second, org.rascalmpl.ast.Expression last) { + super(src, node); + + this.first = first; + this.second = second; + this.last = last; + } + + @Override + public boolean isStepRange() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionStepRange(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = first.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + first.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = second.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + second.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = last.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + last.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof StepRange)) { + return false; + } + StepRange tmp = (StepRange) o; + return true && tmp.first.equals(this.first) && tmp.second.equals(this.second) && tmp.last.equals(this.last) ; + } + + @Override + public int hashCode() { + return 601 + 29 * first.hashCode() + 283 * second.hashCode() + 751 * last.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getFirst() { + return this.first; + } + + @Override + public boolean hasFirst() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getSecond() { + return this.second; + } + + @Override + public boolean hasSecond() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getLast() { + return this.last; + } + + @Override + public boolean hasLast() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(first), clone(second), clone(last)); + } + + } + public boolean isSubscript() { + return false; + } + + static public class Subscript extends Expression { + // Production: sig("Subscript",[arg("org.rascalmpl.ast.Expression","expression"),arg("java.util.List\","subscripts")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + private final java.util.List subscripts; + + public Subscript(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, java.util.List subscripts) { + super(src, node); + + this.expression = expression; + this.subscripts = subscripts; + } + + @Override + public boolean isSubscript() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSubscript(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : subscripts) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Subscript)) { + return false; + } + Subscript tmp = (Subscript) o; + return true && tmp.expression.equals(this.expression) && tmp.subscripts.equals(this.subscripts) ; + } + + @Override + public int hashCode() { + return 839 + 739 * expression.hashCode() + 347 * subscripts.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public java.util.List getSubscripts() { + return this.subscripts; + } + + @Override + public boolean hasSubscripts() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(subscripts)); + } + + } + public boolean isSubtraction() { + return false; + } + + static public class Subtraction extends Expression { + // Production: sig("Subtraction",[arg("org.rascalmpl.ast.Expression","lhs"),arg("org.rascalmpl.ast.Expression","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Expression lhs; + private final org.rascalmpl.ast.Expression rhs; + + public Subtraction(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression lhs, org.rascalmpl.ast.Expression rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isSubtraction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionSubtraction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Subtraction)) { + return false; + } + Subtraction tmp = (Subtraction) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 719 + 691 * lhs.hashCode() + 433 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isTransitiveClosure() { + return false; + } + + static public class TransitiveClosure extends Expression { + // Production: sig("TransitiveClosure",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public TransitiveClosure(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isTransitiveClosure() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionTransitiveClosure(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TransitiveClosure)) { + return false; + } + TransitiveClosure tmp = (TransitiveClosure) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 953 + 367 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isTransitiveReflexiveClosure() { + return false; + } + + static public class TransitiveReflexiveClosure extends Expression { + // Production: sig("TransitiveReflexiveClosure",[arg("org.rascalmpl.ast.Expression","argument")],breakable=false) + + + private final org.rascalmpl.ast.Expression argument; + + public TransitiveReflexiveClosure(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression argument) { + super(src, node); + + this.argument = argument; + } + + @Override + public boolean isTransitiveReflexiveClosure() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionTransitiveReflexiveClosure(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = argument.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + argument.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TransitiveReflexiveClosure)) { + return false; + } + TransitiveReflexiveClosure tmp = (TransitiveReflexiveClosure) o; + return true && tmp.argument.equals(this.argument) ; + } + + @Override + public int hashCode() { + return 991 + 461 * argument.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getArgument() { + return this.argument; + } + + @Override + public boolean hasArgument() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(argument)); + } + + } + public boolean isTuple() { + return false; + } + + static public class Tuple extends Expression { + // Production: sig("Tuple",[arg("java.util.List\","elements")],breakable=false) + + + private final java.util.List elements; + + public Tuple(ISourceLocation src, IConstructor node , java.util.List elements) { + super(src, node); + + this.elements = elements; + } + + @Override + public boolean isTuple() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionTuple(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : elements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tuple)) { + return false; + } + Tuple tmp = (Tuple) o; + return true && tmp.elements.equals(this.elements) ; + } + + @Override + public int hashCode() { + return 599 + 863 * elements.hashCode() ; + } + + + @Override + public java.util.List getElements() { + return this.elements; + } + + @Override + public boolean hasElements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(elements)); + } + + } + public boolean isTypedVariable() { + return false; + } + + static public class TypedVariable extends Expression { + // Production: sig("TypedVariable",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + + public TypedVariable(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name) { + super(src, node); + + this.type = type; + this.name = name; + } + + @Override + public boolean isTypedVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionTypedVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TypedVariable)) { + return false; + } + TypedVariable tmp = (TypedVariable) o; + return true && tmp.type.equals(this.type) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 331 + 347 * type.hashCode() + 487 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(name)); + } + + } + public boolean isTypedVariableBecomes() { + return false; + } + + static public class TypedVariableBecomes extends Expression { + // Production: sig("TypedVariableBecomes",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","pattern")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression pattern; + + public TypedVariableBecomes(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression pattern) { + super(src, node); + + this.type = type; + this.name = name; + this.pattern = pattern; + } + + @Override + public boolean isTypedVariableBecomes() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionTypedVariableBecomes(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TypedVariableBecomes)) { + return false; + } + TypedVariableBecomes tmp = (TypedVariableBecomes) o; + return true && tmp.type.equals(this.type) && tmp.name.equals(this.name) && tmp.pattern.equals(this.pattern) ; + } + + @Override + public int hashCode() { + return 53 + 983 * type.hashCode() + 653 * name.hashCode() + 29 * pattern.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(name), clone(pattern)); + } + + } + public boolean isVariableBecomes() { + return false; + } + + static public class VariableBecomes extends Expression { + // Production: sig("VariableBecomes",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","pattern")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression pattern; + + public VariableBecomes(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression pattern) { + super(src, node); + + this.name = name; + this.pattern = pattern; + } + + @Override + public boolean isVariableBecomes() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionVariableBecomes(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof VariableBecomes)) { + return false; + } + VariableBecomes tmp = (VariableBecomes) o; + return true && tmp.name.equals(this.name) && tmp.pattern.equals(this.pattern) ; + } + + @Override + public int hashCode() { + return 487 + 653 * name.hashCode() + 373 * pattern.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(pattern)); + } + + } + public boolean isVisit() { + return false; + } + + static public class Visit extends Expression { + // Production: sig("Visit",[arg("org.rascalmpl.ast.Label","label"),arg("org.rascalmpl.ast.Visit","visit")],breakable=false) + + + private final org.rascalmpl.ast.Label label; + private final org.rascalmpl.ast.Visit visit; + + public Visit(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, org.rascalmpl.ast.Visit visit) { + super(src, node); + + this.label = label; + this.visit = visit; + } + + @Override + public boolean isVisit() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionVisit(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visit.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visit.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Visit)) { + return false; + } + Visit tmp = (Visit) o; + return true && tmp.label.equals(this.label) && tmp.visit.equals(this.visit) ; + } + + @Override + public int hashCode() { + return 449 + 251 * label.hashCode() + 109 * visit.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public org.rascalmpl.ast.Visit getVisit() { + return this.visit; + } + + @Override + public boolean hasVisit() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(visit)); + } + + } + public boolean isVoidClosure() { + return false; + } + + static public class VoidClosure extends Expression { + // Production: sig("VoidClosure",[arg("org.rascalmpl.ast.Parameters","parameters"),arg("java.util.List\","statements0")],breakable=false) + + + private final org.rascalmpl.ast.Parameters parameters; + private final java.util.List statements0; + + public VoidClosure(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Parameters parameters, java.util.List statements0) { + super(src, node); + + this.parameters = parameters; + this.statements0 = statements0; + } + + @Override + public boolean isVoidClosure() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitExpressionVoidClosure(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = parameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + parameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : statements0) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof VoidClosure)) { + return false; + } + VoidClosure tmp = (VoidClosure) o; + return true && tmp.parameters.equals(this.parameters) && tmp.statements0.equals(this.statements0) ; + } + + @Override + public int hashCode() { + return 967 + 269 * parameters.hashCode() + 97 * statements0.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Parameters getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + @Override + public java.util.List getStatements0() { + return this.statements0; + } + + @Override + public boolean hasStatements0() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(parameters), clone(statements0)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Field.java b/src/org/rascalmpl/ast/Field.java new file mode 100644 index 00000000000..bf68c41a5f8 --- /dev/null +++ b/src/org/rascalmpl/ast/Field.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Field extends AbstractAST { + public Field(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasFieldIndex() { + return false; + } + + public org.rascalmpl.ast.IntegerLiteral getFieldIndex() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFieldName() { + return false; + } + + public org.rascalmpl.ast.Name getFieldName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isIndex() { + return false; + } + + static public class Index extends Field { + // Production: sig("Index",[arg("org.rascalmpl.ast.IntegerLiteral","fieldIndex")],breakable=false) + + + private final org.rascalmpl.ast.IntegerLiteral fieldIndex; + + public Index(ISourceLocation src, IConstructor node , org.rascalmpl.ast.IntegerLiteral fieldIndex) { + super(src, node); + + this.fieldIndex = fieldIndex; + } + + @Override + public boolean isIndex() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFieldIndex(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = fieldIndex.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + fieldIndex.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Index)) { + return false; + } + Index tmp = (Index) o; + return true && tmp.fieldIndex.equals(this.fieldIndex) ; + } + + @Override + public int hashCode() { + return 101 + 467 * fieldIndex.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.IntegerLiteral getFieldIndex() { + return this.fieldIndex; + } + + @Override + public boolean hasFieldIndex() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(fieldIndex)); + } + + } + public boolean isName() { + return false; + } + + static public class Name extends Field { + // Production: sig("Name",[arg("org.rascalmpl.ast.Name","fieldName")],breakable=false) + + + private final org.rascalmpl.ast.Name fieldName; + + public Name(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name fieldName) { + super(src, node); + + this.fieldName = fieldName; + } + + @Override + public boolean isName() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFieldName(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = fieldName.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + fieldName.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Name)) { + return false; + } + Name tmp = (Name) o; + return true && tmp.fieldName.equals(this.fieldName) ; + } + + @Override + public int hashCode() { + return 89 + 727 * fieldName.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getFieldName() { + return this.fieldName; + } + + @Override + public boolean hasFieldName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(fieldName)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Formals.java b/src/org/rascalmpl/ast/Formals.java new file mode 100644 index 00000000000..debccfce33f --- /dev/null +++ b/src/org/rascalmpl/ast/Formals.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Formals extends AbstractAST { + public Formals(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasFormals() { + return false; + } + + public java.util.List getFormals() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Formals { + // Production: sig("Default",[arg("java.util.List\","formals")],breakable=false) + + + private final java.util.List formals; + + public Default(ISourceLocation src, IConstructor node , java.util.List formals) { + super(src, node); + + this.formals = formals; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFormalsDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : formals) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.formals.equals(this.formals) ; + } + + @Override + public int hashCode() { + return 673 + 743 * formals.hashCode() ; + } + + + @Override + public java.util.List getFormals() { + return this.formals; + } + + @Override + public boolean hasFormals() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(formals)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/FunctionBody.java b/src/org/rascalmpl/ast/FunctionBody.java new file mode 100644 index 00000000000..c997e848acd --- /dev/null +++ b/src/org/rascalmpl/ast/FunctionBody.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class FunctionBody extends AbstractAST { + public FunctionBody(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasStatements() { + return false; + } + + public java.util.List getStatements() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends FunctionBody { + // Production: sig("Default",[arg("java.util.List\","statements")],breakable=false) + + + private final java.util.List statements; + + public Default(ISourceLocation src, IConstructor node , java.util.List statements) { + super(src, node); + + this.statements = statements; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionBodyDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : statements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.statements.equals(this.statements) ; + } + + @Override + public int hashCode() { + return 29 + 571 * statements.hashCode() ; + } + + + @Override + public java.util.List getStatements() { + return this.statements; + } + + @Override + public boolean hasStatements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statements)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/FunctionDeclaration.java b/src/org/rascalmpl/ast/FunctionDeclaration.java new file mode 100644 index 00000000000..b216215840c --- /dev/null +++ b/src/org/rascalmpl/ast/FunctionDeclaration.java @@ -0,0 +1,601 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class FunctionDeclaration extends AbstractAST { + public FunctionDeclaration(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasConditions() { + return false; + } + + public java.util.List getConditions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBody() { + return false; + } + + public org.rascalmpl.ast.FunctionBody getBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSignature() { + return false; + } + + public org.rascalmpl.ast.Signature getSignature() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTags() { + return false; + } + + public org.rascalmpl.ast.Tags getTags() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVisibility() { + return false; + } + + public org.rascalmpl.ast.Visibility getVisibility() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAbstract() { + return false; + } + + static public class Abstract extends FunctionDeclaration { + // Production: sig("Abstract",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Signature","signature")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Signature signature; + + public Abstract(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Signature signature) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.signature = signature; + } + + @Override + public boolean isAbstract() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionDeclarationAbstract(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = signature.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + signature.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Abstract)) { + return false; + } + Abstract tmp = (Abstract) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.signature.equals(this.signature) ; + } + + @Override + public int hashCode() { + return 211 + 727 * tags.hashCode() + 251 * visibility.hashCode() + 131 * signature.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Signature getSignature() { + return this.signature; + } + + @Override + public boolean hasSignature() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(signature)); + } + + } + public boolean isConditional() { + return false; + } + + static public class Conditional extends FunctionDeclaration { + // Production: sig("Conditional",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Signature","signature"),arg("org.rascalmpl.ast.Expression","expression"),arg("java.util.List\","conditions")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Signature signature; + private final org.rascalmpl.ast.Expression expression; + private final java.util.List conditions; + + public Conditional(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Signature signature, org.rascalmpl.ast.Expression expression, java.util.List conditions) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.signature = signature; + this.expression = expression; + this.conditions = conditions; + } + + @Override + public boolean isConditional() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionDeclarationConditional(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = signature.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + signature.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Conditional)) { + return false; + } + Conditional tmp = (Conditional) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.signature.equals(this.signature) && tmp.expression.equals(this.expression) && tmp.conditions.equals(this.conditions) ; + } + + @Override + public int hashCode() { + return 811 + 199 * tags.hashCode() + 5 * visibility.hashCode() + 157 * signature.hashCode() + 389 * expression.hashCode() + 163 * conditions.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Signature getSignature() { + return this.signature; + } + + @Override + public boolean hasSignature() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(signature), clone(expression), clone(conditions)); + } + + } + public boolean isDefault() { + return false; + } + + static public class Default extends FunctionDeclaration { + // Production: sig("Default",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Signature","signature"),arg("org.rascalmpl.ast.FunctionBody","body")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Signature signature; + private final org.rascalmpl.ast.FunctionBody body; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Signature signature, org.rascalmpl.ast.FunctionBody body) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.signature = signature; + this.body = body; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionDeclarationDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = signature.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + signature.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.signature.equals(this.signature) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 163 + 71 * tags.hashCode() + 503 * visibility.hashCode() + 31 * signature.hashCode() + 181 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Signature getSignature() { + return this.signature; + } + + @Override + public boolean hasSignature() { + return true; + } + @Override + public org.rascalmpl.ast.FunctionBody getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(signature), clone(body)); + } + + } + public boolean isExpression() { + return false; + } + + static public class Expression extends FunctionDeclaration { + // Production: sig("Expression",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.Visibility","visibility"),arg("org.rascalmpl.ast.Signature","signature"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.Visibility visibility; + private final org.rascalmpl.ast.Signature signature; + private final org.rascalmpl.ast.Expression expression; + + public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.Visibility visibility, org.rascalmpl.ast.Signature signature, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.tags = tags; + this.visibility = visibility; + this.signature = signature; + this.expression = expression; + } + + @Override + public boolean isExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionDeclarationExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visibility.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visibility.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = signature.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + signature.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Expression)) { + return false; + } + Expression tmp = (Expression) o; + return true && tmp.tags.equals(this.tags) && tmp.visibility.equals(this.visibility) && tmp.signature.equals(this.signature) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 313 + 463 * tags.hashCode() + 257 * visibility.hashCode() + 211 * signature.hashCode() + 179 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.Visibility getVisibility() { + return this.visibility; + } + + @Override + public boolean hasVisibility() { + return true; + } + @Override + public org.rascalmpl.ast.Signature getSignature() { + return this.signature; + } + + @Override + public boolean hasSignature() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(visibility), clone(signature), clone(expression)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/FunctionModifier.java b/src/org/rascalmpl/ast/FunctionModifier.java new file mode 100644 index 00000000000..165fe167584 --- /dev/null +++ b/src/org/rascalmpl/ast/FunctionModifier.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class FunctionModifier extends AbstractAST { + public FunctionModifier(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends FunctionModifier { + // Production: sig("Default",[],breakable=false) + + + + public Default(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionModifierDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true ; + } + + @Override + public int hashCode() { + return 457 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isJava() { + return false; + } + + static public class Java extends FunctionModifier { + // Production: sig("Java",[],breakable=false) + + + + public Java(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isJava() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionModifierJava(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Java)) { + return false; + } + Java tmp = (Java) o; + return true ; + } + + @Override + public int hashCode() { + return 839 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTest() { + return false; + } + + static public class Test extends FunctionModifier { + // Production: sig("Test",[],breakable=false) + + + + public Test(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isTest() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionModifierTest(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Test)) { + return false; + } + Test tmp = (Test) o; + return true ; + } + + @Override + public int hashCode() { + return 2 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/FunctionModifiers.java b/src/org/rascalmpl/ast/FunctionModifiers.java new file mode 100644 index 00000000000..d6095642881 --- /dev/null +++ b/src/org/rascalmpl/ast/FunctionModifiers.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class FunctionModifiers extends AbstractAST { + public FunctionModifiers(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasModifiers() { + return false; + } + + public java.util.List getModifiers() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isModifierlist() { + return false; + } + + static public class Modifierlist extends FunctionModifiers { + // Production: sig("Modifierlist",[arg("java.util.List\","modifiers")],breakable=false) + + + private final java.util.List modifiers; + + public Modifierlist(ISourceLocation src, IConstructor node , java.util.List modifiers) { + super(src, node); + + this.modifiers = modifiers; + } + + @Override + public boolean isModifierlist() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionModifiersModifierlist(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : modifiers) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Modifierlist)) { + return false; + } + Modifierlist tmp = (Modifierlist) o; + return true && tmp.modifiers.equals(this.modifiers) ; + } + + @Override + public int hashCode() { + return 461 + 877 * modifiers.hashCode() ; + } + + + @Override + public java.util.List getModifiers() { + return this.modifiers; + } + + @Override + public boolean hasModifiers() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(modifiers)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/FunctionType.java b/src/org/rascalmpl/ast/FunctionType.java new file mode 100644 index 00000000000..a11f806d066 --- /dev/null +++ b/src/org/rascalmpl/ast/FunctionType.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class FunctionType extends AbstractAST { + public FunctionType(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasArguments() { + return false; + } + + public java.util.List getArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isTypeArguments() { + return false; + } + + static public class TypeArguments extends FunctionType { + // Production: sig("TypeArguments",[arg("org.rascalmpl.ast.Type","type"),arg("java.util.List\","arguments")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final java.util.List arguments; + + public TypeArguments(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, java.util.List arguments) { + super(src, node); + + this.type = type; + this.arguments = arguments; + } + + @Override + public boolean isTypeArguments() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitFunctionTypeTypeArguments(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : arguments) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TypeArguments)) { + return false; + } + TypeArguments tmp = (TypeArguments) o; + return true && tmp.type.equals(this.type) && tmp.arguments.equals(this.arguments) ; + } + + @Override + public int hashCode() { + return 599 + 281 * type.hashCode() + 43 * arguments.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public java.util.List getArguments() { + return this.arguments; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(arguments)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Header.java b/src/org/rascalmpl/ast/Header.java new file mode 100644 index 00000000000..8afe64a16ce --- /dev/null +++ b/src/org/rascalmpl/ast/Header.java @@ -0,0 +1,308 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Header extends AbstractAST { + public Header(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasImports() { + return false; + } + + public java.util.List getImports() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasParams() { + return false; + } + + public org.rascalmpl.ast.ModuleParameters getParams() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTags() { + return false; + } + + public org.rascalmpl.ast.Tags getTags() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Header { + // Production: sig("Default",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.QualifiedName","name"),arg("java.util.List\","imports")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.QualifiedName name; + private final java.util.List imports; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.QualifiedName name, java.util.List imports) { + super(src, node); + + this.tags = tags; + this.name = name; + this.imports = imports; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitHeaderDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : imports) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.tags.equals(this.tags) && tmp.name.equals(this.name) && tmp.imports.equals(this.imports) ; + } + + @Override + public int hashCode() { + return 103 + 673 * tags.hashCode() + 509 * name.hashCode() + 61 * imports.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getImports() { + return this.imports; + } + + @Override + public boolean hasImports() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(name), clone(imports)); + } + + } + public boolean isParameters() { + return false; + } + + static public class Parameters extends Header { + // Production: sig("Parameters",[arg("org.rascalmpl.ast.Tags","tags"),arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.ModuleParameters","params"),arg("java.util.List\","imports")],breakable=false) + + + private final org.rascalmpl.ast.Tags tags; + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.ModuleParameters params; + private final java.util.List imports; + + public Parameters(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tags tags, org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.ModuleParameters params, java.util.List imports) { + super(src, node); + + this.tags = tags; + this.name = name; + this.params = params; + this.imports = imports; + } + + @Override + public boolean isParameters() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitHeaderParameters(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tags.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tags.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = params.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + params.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : imports) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Parameters)) { + return false; + } + Parameters tmp = (Parameters) o; + return true && tmp.tags.equals(this.tags) && tmp.name.equals(this.name) && tmp.params.equals(this.params) && tmp.imports.equals(this.imports) ; + } + + @Override + public int hashCode() { + return 173 + 761 * tags.hashCode() + 409 * name.hashCode() + 997 * params.hashCode() + 367 * imports.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tags getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.ModuleParameters getParams() { + return this.params; + } + + @Override + public boolean hasParams() { + return true; + } + @Override + public java.util.List getImports() { + return this.imports; + } + + @Override + public boolean hasImports() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags), clone(name), clone(params), clone(imports)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/HexIntegerLiteral.java b/src/org/rascalmpl/ast/HexIntegerLiteral.java new file mode 100644 index 00000000000..e7f248973df --- /dev/null +++ b/src/org/rascalmpl/ast/HexIntegerLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class HexIntegerLiteral extends AbstractAST { + public HexIntegerLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends HexIntegerLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitHexIntegerLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/IASTVisitor.java b/src/org/rascalmpl/ast/IASTVisitor.java new file mode 100644 index 00000000000..97542a0e7de --- /dev/null +++ b/src/org/rascalmpl/ast/IASTVisitor.java @@ -0,0 +1,855 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + +public interface IASTVisitor { + + public T visitAssignableAnnotation(Assignable.Annotation x); + + public T visitAssignableBracket(Assignable.Bracket x); + + public T visitAssignableConstructor(Assignable.Constructor x); + + public T visitAssignableFieldAccess(Assignable.FieldAccess x); + + public T visitAssignableIfDefinedOrDefault(Assignable.IfDefinedOrDefault x); + + public T visitAssignableSlice(Assignable.Slice x); + + public T visitAssignableSliceStep(Assignable.SliceStep x); + + public T visitAssignableSubscript(Assignable.Subscript x); + + public T visitAssignableTuple(Assignable.Tuple x); + + public T visitAssignableVariable(Assignable.Variable x); + + public T visitAssignmentAddition(Assignment.Addition x); + + public T visitAssignmentAppend(Assignment.Append x); + + public T visitAssignmentDefault(Assignment.Default x); + + public T visitAssignmentDivision(Assignment.Division x); + + public T visitAssignmentIfDefined(Assignment.IfDefined x); + + public T visitAssignmentIntersection(Assignment.Intersection x); + + public T visitAssignmentProduct(Assignment.Product x); + + public T visitAssignmentSubtraction(Assignment.Subtraction x); + + public T visitAssocAssociative(Assoc.Associative x); + + public T visitAssocLeft(Assoc.Left x); + + public T visitAssocNonAssociative(Assoc.NonAssociative x); + + public T visitAssocRight(Assoc.Right x); + + public T visitBasicTypeBag(BasicType.Bag x); + + public T visitBasicTypeBool(BasicType.Bool x); + + public T visitBasicTypeDateTime(BasicType.DateTime x); + + public T visitBasicTypeInt(BasicType.Int x); + + public T visitBasicTypeList(BasicType.List x); + + public T visitBasicTypeListRelation(BasicType.ListRelation x); + + public T visitBasicTypeLoc(BasicType.Loc x); + + public T visitBasicTypeMap(BasicType.Map x); + + public T visitBasicTypeNode(BasicType.Node x); + + public T visitBasicTypeNum(BasicType.Num x); + + public T visitBasicTypeRational(BasicType.Rational x); + + public T visitBasicTypeReal(BasicType.Real x); + + public T visitBasicTypeRelation(BasicType.Relation x); + + public T visitBasicTypeSet(BasicType.Set x); + + public T visitBasicTypeString(BasicType.String x); + + public T visitBasicTypeTuple(BasicType.Tuple x); + + public T visitBasicTypeType(BasicType.Type x); + + public T visitBasicTypeValue(BasicType.Value x); + + public T visitBasicTypeVoid(BasicType.Void x); + + public T visitBodyToplevels(Body.Toplevels x); + + public T visitBoundDefault(Bound.Default x); + + public T visitBoundEmpty(Bound.Empty x); + + public T visitCaseDefault(Case.Default x); + + public T visitCasePatternWithAction(Case.PatternWithAction x); + + public T visitCatchBinding(Catch.Binding x); + + public T visitCatchDefault(Catch.Default x); + + public T visitClassBracket(Class.Bracket x); + + public T visitClassComplement(Class.Complement x); + + public T visitClassDifference(Class.Difference x); + + public T visitClassIntersection(Class.Intersection x); + + public T visitClassSimpleCharclass(Class.SimpleCharclass x); + + public T visitClassUnion(Class.Union x); + + public T visitCommandDeclaration(Command.Declaration x); + + public T visitCommandExpression(Command.Expression x); + + public T visitCommandImport(Command.Import x); + + public T visitCommandShell(Command.Shell x); + + public T visitCommandStatement(Command.Statement x); + + public T visitCommandsCommandlist(Commands.Commandlist x); + + public T visitCommonKeywordParametersAbsent(CommonKeywordParameters.Absent x); + + public T visitCommonKeywordParametersPresent(CommonKeywordParameters.Present x); + + public T visitComprehensionList(Comprehension.List x); + + public T visitComprehensionMap(Comprehension.Map x); + + public T visitComprehensionSet(Comprehension.Set x); + + public T visitConcreteHoleOne(ConcreteHole.One x); + + public T visitDataTargetEmpty(DataTarget.Empty x); + + public T visitDataTargetLabeled(DataTarget.Labeled x); + + public T visitDataTypeSelectorSelector(DataTypeSelector.Selector x); + + public T visitDateTimeLiteralDateAndTimeLiteral(DateTimeLiteral.DateAndTimeLiteral x); + + public T visitDateTimeLiteralDateLiteral(DateTimeLiteral.DateLiteral x); + + public T visitDateTimeLiteralTimeLiteral(DateTimeLiteral.TimeLiteral x); + + public T visitDeclarationAlias(Declaration.Alias x); + + public T visitDeclarationAnnotation(Declaration.Annotation x); + + public T visitDeclarationData(Declaration.Data x); + + public T visitDeclarationDataAbstract(Declaration.DataAbstract x); + + public T visitDeclarationFunction(Declaration.Function x); + + public T visitDeclarationTag(Declaration.Tag x); + + public T visitDeclarationVariable(Declaration.Variable x); + + public T visitDeclaratorDefault(Declarator.Default x); + + public T visitEvalCommandDeclaration(EvalCommand.Declaration x); + + public T visitEvalCommandImport(EvalCommand.Import x); + + public T visitEvalCommandOutput(EvalCommand.Output x); + + public T visitEvalCommandStatement(EvalCommand.Statement x); + + public T visitExpressionAddition(Expression.Addition x); + + public T visitExpressionAll(Expression.All x); + + public T visitExpressionAnd(Expression.And x); + + public T visitExpressionAnti(Expression.Anti x); + + public T visitExpressionAny(Expression.Any x); + + public T visitExpressionAppendAfter(Expression.AppendAfter x); + + public T visitExpressionAsType(Expression.AsType x); + + public T visitExpressionBracket(Expression.Bracket x); + + public T visitExpressionCallOrTree(Expression.CallOrTree x); + + public T visitExpressionClosure(Expression.Closure x); + + public T visitExpressionComposition(Expression.Composition x); + + public T visitExpressionComprehension(Expression.Comprehension x); + + public T visitExpressionConcrete(Expression.Concrete x); + + public T visitExpressionDescendant(Expression.Descendant x); + + public T visitExpressionDivision(Expression.Division x); + + public T visitExpressionEnumerator(Expression.Enumerator x); + + public T visitExpressionEquals(Expression.Equals x); + + public T visitExpressionEquivalence(Expression.Equivalence x); + + public T visitExpressionFieldAccess(Expression.FieldAccess x); + + public T visitExpressionFieldProject(Expression.FieldProject x); + + public T visitExpressionFieldUpdate(Expression.FieldUpdate x); + + public T visitExpressionGetAnnotation(Expression.GetAnnotation x); + + public T visitExpressionGreaterThan(Expression.GreaterThan x); + + public T visitExpressionGreaterThanOrEq(Expression.GreaterThanOrEq x); + + public T visitExpressionHas(Expression.Has x); + + public T visitExpressionIfDefinedOtherwise(Expression.IfDefinedOtherwise x); + + public T visitExpressionIfThenElse(Expression.IfThenElse x); + + public T visitExpressionImplication(Expression.Implication x); + + public T visitExpressionIn(Expression.In x); + + public T visitExpressionInsertBefore(Expression.InsertBefore x); + + public T visitExpressionIntersection(Expression.Intersection x); + + public T visitExpressionIs(Expression.Is x); + + public T visitExpressionIsDefined(Expression.IsDefined x); + + public T visitExpressionIt(Expression.It x); + + public T visitExpressionJoin(Expression.Join x); + + public T visitExpressionLessThan(Expression.LessThan x); + + public T visitExpressionLessThanOrEq(Expression.LessThanOrEq x); + + public T visitExpressionList(Expression.List x); + + public T visitExpressionLiteral(Expression.Literal x); + + public T visitExpressionMap(Expression.Map x); + + public T visitExpressionMatch(Expression.Match x); + + public T visitExpressionModulo(Expression.Modulo x); + + public T visitExpressionMultiVariable(Expression.MultiVariable x); + + public T visitExpressionNegation(Expression.Negation x); + + public T visitExpressionNegative(Expression.Negative x); + + public T visitExpressionNoMatch(Expression.NoMatch x); + + public T visitExpressionNonEmptyBlock(Expression.NonEmptyBlock x); + + public T visitExpressionNonEquals(Expression.NonEquals x); + + public T visitExpressionNotIn(Expression.NotIn x); + + public T visitExpressionOr(Expression.Or x); + + public T visitExpressionProduct(Expression.Product x); + + public T visitExpressionQualifiedName(Expression.QualifiedName x); + + public T visitExpressionRange(Expression.Range x); + + public T visitExpressionReducer(Expression.Reducer x); + + public T visitExpressionReifiedType(Expression.ReifiedType x); + + public T visitExpressionReifyType(Expression.ReifyType x); + + public T visitExpressionRemainder(Expression.Remainder x); + + public T visitExpressionSet(Expression.Set x); + + public T visitExpressionSetAnnotation(Expression.SetAnnotation x); + + public T visitExpressionSlice(Expression.Slice x); + + public T visitExpressionSliceStep(Expression.SliceStep x); + + public T visitExpressionSplice(Expression.Splice x); + + public T visitExpressionSplicePlus(Expression.SplicePlus x); + + public T visitExpressionStepRange(Expression.StepRange x); + + public T visitExpressionSubscript(Expression.Subscript x); + + public T visitExpressionSubtraction(Expression.Subtraction x); + + public T visitExpressionTransitiveClosure(Expression.TransitiveClosure x); + + public T visitExpressionTransitiveReflexiveClosure(Expression.TransitiveReflexiveClosure x); + + public T visitExpressionTuple(Expression.Tuple x); + + public T visitExpressionTypedVariable(Expression.TypedVariable x); + + public T visitExpressionTypedVariableBecomes(Expression.TypedVariableBecomes x); + + public T visitExpressionVariableBecomes(Expression.VariableBecomes x); + + public T visitExpressionVisit(Expression.Visit x); + + public T visitExpressionVoidClosure(Expression.VoidClosure x); + + public T visitFieldIndex(Field.Index x); + + public T visitFieldName(Field.Name x); + + public T visitFormalsDefault(Formals.Default x); + + public T visitFunctionBodyDefault(FunctionBody.Default x); + + public T visitFunctionDeclarationAbstract(FunctionDeclaration.Abstract x); + + public T visitFunctionDeclarationConditional(FunctionDeclaration.Conditional x); + + public T visitFunctionDeclarationDefault(FunctionDeclaration.Default x); + + public T visitFunctionDeclarationExpression(FunctionDeclaration.Expression x); + + public T visitFunctionModifierDefault(FunctionModifier.Default x); + + public T visitFunctionModifierJava(FunctionModifier.Java x); + + public T visitFunctionModifierTest(FunctionModifier.Test x); + + public T visitFunctionModifiersModifierlist(FunctionModifiers.Modifierlist x); + + public T visitFunctionTypeTypeArguments(FunctionType.TypeArguments x); + + public T visitHeaderDefault(Header.Default x); + + public T visitHeaderParameters(Header.Parameters x); + + public T visitImportDefault(Import.Default x); + + public T visitImportExtend(Import.Extend x); + + public T visitImportExternal(Import.External x); + + public T visitImportSyntax(Import.Syntax x); + + public T visitImportedModuleActuals(ImportedModule.Actuals x); + + public T visitImportedModuleActualsRenaming(ImportedModule.ActualsRenaming x); + + public T visitImportedModuleDefault(ImportedModule.Default x); + + public T visitImportedModuleRenamings(ImportedModule.Renamings x); + + public T visitIntegerLiteralDecimalIntegerLiteral(IntegerLiteral.DecimalIntegerLiteral x); + + public T visitIntegerLiteralHexIntegerLiteral(IntegerLiteral.HexIntegerLiteral x); + + public T visitIntegerLiteralOctalIntegerLiteral(IntegerLiteral.OctalIntegerLiteral x); + + public T visitKeywordArgument_ExpressionDefault(KeywordArgument_Expression.Default x); + + public T visitKeywordArguments_ExpressionDefault(KeywordArguments_Expression.Default x); + + public T visitKeywordArguments_ExpressionNone(KeywordArguments_Expression.None x); + + public T visitKeywordFormalDefault(KeywordFormal.Default x); + + public T visitKeywordFormalsDefault(KeywordFormals.Default x); + + public T visitKeywordFormalsNone(KeywordFormals.None x); + + public T visitKindAlias(Kind.Alias x); + + public T visitKindAll(Kind.All x); + + public T visitKindAnno(Kind.Anno x); + + public T visitKindData(Kind.Data x); + + public T visitKindFunction(Kind.Function x); + + public T visitKindModule(Kind.Module x); + + public T visitKindTag(Kind.Tag x); + + public T visitKindVariable(Kind.Variable x); + + public T visitKindView(Kind.View x); + + public T visitLabelDefault(Label.Default x); + + public T visitLabelEmpty(Label.Empty x); + + public T visitLiteralBoolean(Literal.Boolean x); + + public T visitLiteralDateTime(Literal.DateTime x); + + public T visitLiteralInteger(Literal.Integer x); + + public T visitLiteralLocation(Literal.Location x); + + public T visitLiteralRational(Literal.Rational x); + + public T visitLiteralReal(Literal.Real x); + + public T visitLiteralRegExp(Literal.RegExp x); + + public T visitLiteralString(Literal.String x); + + public T visitLocalVariableDeclarationDefault(LocalVariableDeclaration.Default x); + + public T visitLocalVariableDeclarationDynamic(LocalVariableDeclaration.Dynamic x); + + public T visitLocationLiteralDefault(LocationLiteral.Default x); + + public T visitMapping_ExpressionDefault(Mapping_Expression.Default x); + + public T visitModuleDefault(Module.Default x); + + public T visitModuleActualsDefault(ModuleActuals.Default x); + + public T visitModuleParametersDefault(ModuleParameters.Default x); + + public T visitOptionalExpressionExpression(OptionalExpression.Expression x); + + public T visitOptionalExpressionNoExpression(OptionalExpression.NoExpression x); + + public T visitParametersDefault(Parameters.Default x); + + public T visitParametersVarArgs(Parameters.VarArgs x); + + public T visitPathPartInterpolated(PathPart.Interpolated x); + + public T visitPathPartNonInterpolated(PathPart.NonInterpolated x); + + public T visitPathTailMid(PathTail.Mid x); + + public T visitPathTailPost(PathTail.Post x); + + public T visitPatternWithActionArbitrary(PatternWithAction.Arbitrary x); + + public T visitPatternWithActionReplacing(PatternWithAction.Replacing x); + + public T visitProdAll(Prod.All x); + + public T visitProdAssociativityGroup(Prod.AssociativityGroup x); + + public T visitProdFirst(Prod.First x); + + public T visitProdLabeled(Prod.Labeled x); + + public T visitProdReference(Prod.Reference x); + + public T visitProdUnlabeled(Prod.Unlabeled x); + + public T visitProdModifierAssociativity(ProdModifier.Associativity x); + + public T visitProdModifierBracket(ProdModifier.Bracket x); + + public T visitProdModifierTag(ProdModifier.Tag x); + + public T visitProtocolPartInterpolated(ProtocolPart.Interpolated x); + + public T visitProtocolPartNonInterpolated(ProtocolPart.NonInterpolated x); + + public T visitProtocolTailMid(ProtocolTail.Mid x); + + public T visitProtocolTailPost(ProtocolTail.Post x); + + public T visitQualifiedNameDefault(QualifiedName.Default x); + + public T visitRangeCharacter(Range.Character x); + + public T visitRangeFromTo(Range.FromTo x); + + public T visitRenamingDefault(Renaming.Default x); + + public T visitRenamingsDefault(Renamings.Default x); + + public T visitReplacementConditional(Replacement.Conditional x); + + public T visitReplacementUnconditional(Replacement.Unconditional x); + + public T visitShellCommandClear(ShellCommand.Clear x); + + public T visitShellCommandEdit(ShellCommand.Edit x); + + public T visitShellCommandHelp(ShellCommand.Help x); + + public T visitShellCommandHistory(ShellCommand.History x); + + public T visitShellCommandListDeclarations(ShellCommand.ListDeclarations x); + + public T visitShellCommandListModules(ShellCommand.ListModules x); + + public T visitShellCommandQuit(ShellCommand.Quit x); + + public T visitShellCommandSetOption(ShellCommand.SetOption x); + + public T visitShellCommandSetOptionTrue(ShellCommand.SetOptionTrue x); + + public T visitShellCommandTest(ShellCommand.Test x); + + public T visitShellCommandUndeclare(ShellCommand.Undeclare x); + + public T visitShellCommandUnextend(ShellCommand.Unextend x); + + public T visitShellCommandUnimport(ShellCommand.Unimport x); + + public T visitShellCommandUnsetOption(ShellCommand.UnsetOption x); + + public T visitSignatureNoThrows(Signature.NoThrows x); + + public T visitSignatureWithThrows(Signature.WithThrows x); + + public T visitStartAbsent(Start.Absent x); + + public T visitStartPresent(Start.Present x); + + public T visitStatementAppend(Statement.Append x); + + public T visitStatementAssert(Statement.Assert x); + + public T visitStatementAssertWithMessage(Statement.AssertWithMessage x); + + public T visitStatementAssignment(Statement.Assignment x); + + public T visitStatementBreak(Statement.Break x); + + public T visitStatementContinue(Statement.Continue x); + + public T visitStatementDoWhile(Statement.DoWhile x); + + public T visitStatementEmptyStatement(Statement.EmptyStatement x); + + public T visitStatementExpression(Statement.Expression x); + + public T visitStatementFail(Statement.Fail x); + + public T visitStatementFilter(Statement.Filter x); + + public T visitStatementFor(Statement.For x); + + public T visitStatementFunctionDeclaration(Statement.FunctionDeclaration x); + + public T visitStatementGlobalDirective(Statement.GlobalDirective x); + + public T visitStatementIfThen(Statement.IfThen x); + + public T visitStatementIfThenElse(Statement.IfThenElse x); + + public T visitStatementInsert(Statement.Insert x); + + public T visitStatementNonEmptyBlock(Statement.NonEmptyBlock x); + + public T visitStatementReturn(Statement.Return x); + + public T visitStatementSolve(Statement.Solve x); + + public T visitStatementSwitch(Statement.Switch x); + + public T visitStatementThrow(Statement.Throw x); + + public T visitStatementTry(Statement.Try x); + + public T visitStatementTryFinally(Statement.TryFinally x); + + public T visitStatementVariableDeclaration(Statement.VariableDeclaration x); + + public T visitStatementVisit(Statement.Visit x); + + public T visitStatementWhile(Statement.While x); + + public T visitStrategyBottomUp(Strategy.BottomUp x); + + public T visitStrategyBottomUpBreak(Strategy.BottomUpBreak x); + + public T visitStrategyInnermost(Strategy.Innermost x); + + public T visitStrategyOutermost(Strategy.Outermost x); + + public T visitStrategyTopDown(Strategy.TopDown x); + + public T visitStrategyTopDownBreak(Strategy.TopDownBreak x); + + public T visitStringLiteralInterpolated(StringLiteral.Interpolated x); + + public T visitStringLiteralNonInterpolated(StringLiteral.NonInterpolated x); + + public T visitStringLiteralTemplate(StringLiteral.Template x); + + public T visitStringMiddleInterpolated(StringMiddle.Interpolated x); + + public T visitStringMiddleMid(StringMiddle.Mid x); + + public T visitStringMiddleTemplate(StringMiddle.Template x); + + public T visitStringTailMidInterpolated(StringTail.MidInterpolated x); + + public T visitStringTailMidTemplate(StringTail.MidTemplate x); + + public T visitStringTailPost(StringTail.Post x); + + public T visitStringTemplateDoWhile(StringTemplate.DoWhile x); + + public T visitStringTemplateFor(StringTemplate.For x); + + public T visitStringTemplateIfThen(StringTemplate.IfThen x); + + public T visitStringTemplateIfThenElse(StringTemplate.IfThenElse x); + + public T visitStringTemplateWhile(StringTemplate.While x); + + public T visitStructuredTypeDefault(StructuredType.Default x); + + public T visitSymAlternative(Sym.Alternative x); + + public T visitSymCaseInsensitiveLiteral(Sym.CaseInsensitiveLiteral x); + + public T visitSymCharacterClass(Sym.CharacterClass x); + + public T visitSymColumn(Sym.Column x); + + public T visitSymEmpty(Sym.Empty x); + + public T visitSymEndOfLine(Sym.EndOfLine x); + + public T visitSymExcept(Sym.Except x); + + public T visitSymFollow(Sym.Follow x); + + public T visitSymIter(Sym.Iter x); + + public T visitSymIterSep(Sym.IterSep x); + + public T visitSymIterStar(Sym.IterStar x); + + public T visitSymIterStarSep(Sym.IterStarSep x); + + public T visitSymLabeled(Sym.Labeled x); + + public T visitSymLiteral(Sym.Literal x); + + public T visitSymNonterminal(Sym.Nonterminal x); + + public T visitSymNotFollow(Sym.NotFollow x); + + public T visitSymNotPrecede(Sym.NotPrecede x); + + public T visitSymOptional(Sym.Optional x); + + public T visitSymParameter(Sym.Parameter x); + + public T visitSymParametrized(Sym.Parametrized x); + + public T visitSymPrecede(Sym.Precede x); + + public T visitSymSequence(Sym.Sequence x); + + public T visitSymStart(Sym.Start x); + + public T visitSymStartOfLine(Sym.StartOfLine x); + + public T visitSymUnequal(Sym.Unequal x); + + public T visitSyntaxDefinitionKeyword(SyntaxDefinition.Keyword x); + + public T visitSyntaxDefinitionLanguage(SyntaxDefinition.Language x); + + public T visitSyntaxDefinitionLayout(SyntaxDefinition.Layout x); + + public T visitSyntaxDefinitionLexical(SyntaxDefinition.Lexical x); + + public T visitTagDefault(Tag.Default x); + + public T visitTagEmpty(Tag.Empty x); + + public T visitTagExpression(Tag.Expression x); + + public T visitTagsDefault(Tags.Default x); + + public T visitTargetEmpty(Target.Empty x); + + public T visitTargetLabeled(Target.Labeled x); + + public T visitToplevelGivenVisibility(Toplevel.GivenVisibility x); + + public T visitTypeBasic(Type.Basic x); + + public T visitTypeBracket(Type.Bracket x); + + public T visitTypeFunction(Type.Function x); + + public T visitTypeSelector(Type.Selector x); + + public T visitTypeStructured(Type.Structured x); + + public T visitTypeSymbol(Type.Symbol x); + + public T visitTypeUser(Type.User x); + + public T visitTypeVariable(Type.Variable x); + + public T visitTypeArgDefault(TypeArg.Default x); + + public T visitTypeArgNamed(TypeArg.Named x); + + public T visitTypeVarBounded(TypeVar.Bounded x); + + public T visitTypeVarFree(TypeVar.Free x); + + public T visitUserTypeName(UserType.Name x); + + public T visitUserTypeParametric(UserType.Parametric x); + + public T visitVariableInitialized(Variable.Initialized x); + + public T visitVariableUnInitialized(Variable.UnInitialized x); + + public T visitVariantNAryConstructor(Variant.NAryConstructor x); + + public T visitVisibilityDefault(Visibility.Default x); + + public T visitVisibilityPrivate(Visibility.Private x); + + public T visitVisibilityPublic(Visibility.Public x); + + public T visitVisitDefaultStrategy(Visit.DefaultStrategy x); + + public T visitVisitGivenStrategy(Visit.GivenStrategy x); + + + public T visitBackslashLexical(Backslash.Lexical x); + + public T visitBooleanLiteralLexical(BooleanLiteral.Lexical x); + + public T visitCaseInsensitiveStringConstantLexical(CaseInsensitiveStringConstant.Lexical x); + + public T visitCharLexical(Char.Lexical x); + + public T visitCommentLexical(Comment.Lexical x); + + public T visitConcreteLexical(Concrete.Lexical x); + + public T visitConcretePartLexical(ConcretePart.Lexical x); + + public T visitDateAndTimeLexical(DateAndTime.Lexical x); + + public T visitDatePartLexical(DatePart.Lexical x); + + public T visitDecimalIntegerLiteralLexical(DecimalIntegerLiteral.Lexical x); + + public T visitHexIntegerLiteralLexical(HexIntegerLiteral.Lexical x); + + public T visitJustDateLexical(JustDate.Lexical x); + + public T visitJustTimeLexical(JustTime.Lexical x); + + public T visitLAYOUTLexical(LAYOUT.Lexical x); + + public T visitMidPathCharsLexical(MidPathChars.Lexical x); + + public T visitMidProtocolCharsLexical(MidProtocolChars.Lexical x); + + public T visitMidStringCharsLexical(MidStringChars.Lexical x); + + public T visitNameLexical(Name.Lexical x); + + public T visitNamedBackslashLexical(NamedBackslash.Lexical x); + + public T visitNamedRegExpLexical(NamedRegExp.Lexical x); + + public T visitNonterminalLexical(Nonterminal.Lexical x); + + public T visitNonterminalLabelLexical(NonterminalLabel.Lexical x); + + public T visitOctalIntegerLiteralLexical(OctalIntegerLiteral.Lexical x); + + public T visitOptionalCommaLexical(OptionalComma.Lexical x); + + public T visitOptionalEqualSignLexical(OptionalEqualSign.Lexical x); + + public T visitOptionalTerminatorLexical(OptionalTerminator.Lexical x); + + public T visitOutputLexical(Output.Lexical x); + + public T visitPathCharsLexical(PathChars.Lexical x); + + public T visitPostPathCharsLexical(PostPathChars.Lexical x); + + public T visitPostProtocolCharsLexical(PostProtocolChars.Lexical x); + + public T visitPostStringCharsLexical(PostStringChars.Lexical x); + + public T visitPrePathCharsLexical(PrePathChars.Lexical x); + + public T visitPreProtocolCharsLexical(PreProtocolChars.Lexical x); + + public T visitPreStringCharsLexical(PreStringChars.Lexical x); + + public T visitProtocolCharsLexical(ProtocolChars.Lexical x); + + public T visitRationalLiteralLexical(RationalLiteral.Lexical x); + + public T visitRealLiteralLexical(RealLiteral.Lexical x); + + public T visitRegExpLexical(RegExp.Lexical x); + + public T visitRegExpLiteralLexical(RegExpLiteral.Lexical x); + + public T visitRegExpModifierLexical(RegExpModifier.Lexical x); + + public T visitStringCharacterLexical(StringCharacter.Lexical x); + + public T visitStringConstantLexical(StringConstant.Lexical x); + + public T visitTagStringLexical(TagString.Lexical x); + + public T visitTimePartNoTZLexical(TimePartNoTZ.Lexical x); + + public T visitTimeZonePartLexical(TimeZonePart.Lexical x); + + public T visitURLCharsLexical(URLChars.Lexical x); + + public T visitUnicodeEscapeLexical(UnicodeEscape.Lexical x); + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/IVisitable.java b/src/org/rascalmpl/ast/IVisitable.java new file mode 100644 index 00000000000..4ea18ecc1ea --- /dev/null +++ b/src/org/rascalmpl/ast/IVisitable.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2009-2013 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl +*******************************************************************************/ +package org.rascalmpl.ast; + +public interface IVisitable { + +} diff --git a/src/org/rascalmpl/ast/Import.java b/src/org/rascalmpl/ast/Import.java new file mode 100644 index 00000000000..83a46cf551b --- /dev/null +++ b/src/org/rascalmpl/ast/Import.java @@ -0,0 +1,376 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Import extends AbstractAST { + public Import(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasModule() { + return false; + } + + public org.rascalmpl.ast.ImportedModule getModule() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasAt() { + return false; + } + + public org.rascalmpl.ast.LocationLiteral getAt() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSyntax() { + return false; + } + + public org.rascalmpl.ast.SyntaxDefinition getSyntax() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Import { + // Production: sig("Default",[arg("org.rascalmpl.ast.ImportedModule","module")],breakable=false) + + + private final org.rascalmpl.ast.ImportedModule module; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ImportedModule module) { + super(src, node); + + this.module = module; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = module.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + module.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.module.equals(this.module) ; + } + + @Override + public int hashCode() { + return 401 + 139 * module.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.ImportedModule getModule() { + return this.module; + } + + @Override + public boolean hasModule() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(module)); + } + + } + public boolean isExtend() { + return false; + } + + static public class Extend extends Import { + // Production: sig("Extend",[arg("org.rascalmpl.ast.ImportedModule","module")],breakable=false) + + + private final org.rascalmpl.ast.ImportedModule module; + + public Extend(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ImportedModule module) { + super(src, node); + + this.module = module; + } + + @Override + public boolean isExtend() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportExtend(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = module.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + module.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Extend)) { + return false; + } + Extend tmp = (Extend) o; + return true && tmp.module.equals(this.module) ; + } + + @Override + public int hashCode() { + return 937 + 521 * module.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.ImportedModule getModule() { + return this.module; + } + + @Override + public boolean hasModule() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(module)); + } + + } + public boolean isExternal() { + return false; + } + + static public class External extends Import { + // Production: sig("External",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.LocationLiteral","at")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.LocationLiteral at; + + public External(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.LocationLiteral at) { + super(src, node); + + this.name = name; + this.at = at; + } + + @Override + public boolean isExternal() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportExternal(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = at.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + at.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof External)) { + return false; + } + External tmp = (External) o; + return true && tmp.name.equals(this.name) && tmp.at.equals(this.at) ; + } + + @Override + public int hashCode() { + return 719 + 773 * name.hashCode() + 277 * at.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.LocationLiteral getAt() { + return this.at; + } + + @Override + public boolean hasAt() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(at)); + } + + } + public boolean isSyntax() { + return false; + } + + static public class Syntax extends Import { + // Production: sig("Syntax",[arg("org.rascalmpl.ast.SyntaxDefinition","syntax")],breakable=false) + + + private final org.rascalmpl.ast.SyntaxDefinition syntax; + + public Syntax(ISourceLocation src, IConstructor node , org.rascalmpl.ast.SyntaxDefinition syntax) { + super(src, node); + + this.syntax = syntax; + } + + @Override + public boolean isSyntax() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportSyntax(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = syntax.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + syntax.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Syntax)) { + return false; + } + Syntax tmp = (Syntax) o; + return true && tmp.syntax.equals(this.syntax) ; + } + + @Override + public int hashCode() { + return 239 + 151 * syntax.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.SyntaxDefinition getSyntax() { + return this.syntax; + } + + @Override + public boolean hasSyntax() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(syntax)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ImportedModule.java b/src/org/rascalmpl/ast/ImportedModule.java new file mode 100644 index 00000000000..1f6849398b7 --- /dev/null +++ b/src/org/rascalmpl/ast/ImportedModule.java @@ -0,0 +1,426 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ImportedModule extends AbstractAST { + public ImportedModule(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasActuals() { + return false; + } + + public org.rascalmpl.ast.ModuleActuals getActuals() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRenamings() { + return false; + } + + public org.rascalmpl.ast.Renamings getRenamings() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isActuals() { + return false; + } + + static public class Actuals extends ImportedModule { + // Production: sig("Actuals",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.ModuleActuals","actuals")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.ModuleActuals actuals; + + public Actuals(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.ModuleActuals actuals) { + super(src, node); + + this.name = name; + this.actuals = actuals; + } + + @Override + public boolean isActuals() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportedModuleActuals(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = actuals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + actuals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Actuals)) { + return false; + } + Actuals tmp = (Actuals) o; + return true && tmp.name.equals(this.name) && tmp.actuals.equals(this.actuals) ; + } + + @Override + public int hashCode() { + return 397 + 137 * name.hashCode() + 811 * actuals.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.ModuleActuals getActuals() { + return this.actuals; + } + + @Override + public boolean hasActuals() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(actuals)); + } + + } + public boolean isActualsRenaming() { + return false; + } + + static public class ActualsRenaming extends ImportedModule { + // Production: sig("ActualsRenaming",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.ModuleActuals","actuals"),arg("org.rascalmpl.ast.Renamings","renamings")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.ModuleActuals actuals; + private final org.rascalmpl.ast.Renamings renamings; + + public ActualsRenaming(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.ModuleActuals actuals, org.rascalmpl.ast.Renamings renamings) { + super(src, node); + + this.name = name; + this.actuals = actuals; + this.renamings = renamings; + } + + @Override + public boolean isActualsRenaming() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportedModuleActualsRenaming(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = actuals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + actuals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = renamings.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + renamings.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ActualsRenaming)) { + return false; + } + ActualsRenaming tmp = (ActualsRenaming) o; + return true && tmp.name.equals(this.name) && tmp.actuals.equals(this.actuals) && tmp.renamings.equals(this.renamings) ; + } + + @Override + public int hashCode() { + return 709 + 167 * name.hashCode() + 53 * actuals.hashCode() + 463 * renamings.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.ModuleActuals getActuals() { + return this.actuals; + } + + @Override + public boolean hasActuals() { + return true; + } + @Override + public org.rascalmpl.ast.Renamings getRenamings() { + return this.renamings; + } + + @Override + public boolean hasRenamings() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(actuals), clone(renamings)); + } + + } + public boolean isDefault() { + return false; + } + + static public class Default extends ImportedModule { + // Production: sig("Default",[arg("org.rascalmpl.ast.QualifiedName","name")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportedModuleDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 127 + 67 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } + public boolean isRenamings() { + return false; + } + + static public class Renamings extends ImportedModule { + // Production: sig("Renamings",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.Renamings","renamings")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.Renamings renamings; + + public Renamings(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.Renamings renamings) { + super(src, node); + + this.name = name; + this.renamings = renamings; + } + + @Override + public boolean isRenamings() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitImportedModuleRenamings(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = renamings.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + renamings.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Renamings)) { + return false; + } + Renamings tmp = (Renamings) o; + return true && tmp.name.equals(this.name) && tmp.renamings.equals(this.renamings) ; + } + + @Override + public int hashCode() { + return 643 + 229 * name.hashCode() + 271 * renamings.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Renamings getRenamings() { + return this.renamings; + } + + @Override + public boolean hasRenamings() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(renamings)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/IntegerLiteral.java b/src/org/rascalmpl/ast/IntegerLiteral.java new file mode 100644 index 00000000000..6d62374dee4 --- /dev/null +++ b/src/org/rascalmpl/ast/IntegerLiteral.java @@ -0,0 +1,276 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class IntegerLiteral extends AbstractAST { + public IntegerLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDecimal() { + return false; + } + + public org.rascalmpl.ast.DecimalIntegerLiteral getDecimal() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasHex() { + return false; + } + + public org.rascalmpl.ast.HexIntegerLiteral getHex() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOctal() { + return false; + } + + public org.rascalmpl.ast.OctalIntegerLiteral getOctal() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDecimalIntegerLiteral() { + return false; + } + + static public class DecimalIntegerLiteral extends IntegerLiteral { + // Production: sig("DecimalIntegerLiteral",[arg("org.rascalmpl.ast.DecimalIntegerLiteral","decimal")],breakable=false) + + + private final org.rascalmpl.ast.DecimalIntegerLiteral decimal; + + public DecimalIntegerLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DecimalIntegerLiteral decimal) { + super(src, node); + + this.decimal = decimal; + } + + @Override + public boolean isDecimalIntegerLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitIntegerLiteralDecimalIntegerLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = decimal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + decimal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DecimalIntegerLiteral)) { + return false; + } + DecimalIntegerLiteral tmp = (DecimalIntegerLiteral) o; + return true && tmp.decimal.equals(this.decimal) ; + } + + @Override + public int hashCode() { + return 331 + 17 * decimal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DecimalIntegerLiteral getDecimal() { + return this.decimal; + } + + @Override + public boolean hasDecimal() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(decimal)); + } + + } + public boolean isHexIntegerLiteral() { + return false; + } + + static public class HexIntegerLiteral extends IntegerLiteral { + // Production: sig("HexIntegerLiteral",[arg("org.rascalmpl.ast.HexIntegerLiteral","hex")],breakable=false) + + + private final org.rascalmpl.ast.HexIntegerLiteral hex; + + public HexIntegerLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.HexIntegerLiteral hex) { + super(src, node); + + this.hex = hex; + } + + @Override + public boolean isHexIntegerLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitIntegerLiteralHexIntegerLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = hex.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + hex.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof HexIntegerLiteral)) { + return false; + } + HexIntegerLiteral tmp = (HexIntegerLiteral) o; + return true && tmp.hex.equals(this.hex) ; + } + + @Override + public int hashCode() { + return 401 + 313 * hex.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.HexIntegerLiteral getHex() { + return this.hex; + } + + @Override + public boolean hasHex() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(hex)); + } + + } + public boolean isOctalIntegerLiteral() { + return false; + } + + static public class OctalIntegerLiteral extends IntegerLiteral { + // Production: sig("OctalIntegerLiteral",[arg("org.rascalmpl.ast.OctalIntegerLiteral","octal")],breakable=false) + + + private final org.rascalmpl.ast.OctalIntegerLiteral octal; + + public OctalIntegerLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OctalIntegerLiteral octal) { + super(src, node); + + this.octal = octal; + } + + @Override + public boolean isOctalIntegerLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitIntegerLiteralOctalIntegerLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = octal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + octal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof OctalIntegerLiteral)) { + return false; + } + OctalIntegerLiteral tmp = (OctalIntegerLiteral) o; + return true && tmp.octal.equals(this.octal) ; + } + + @Override + public int hashCode() { + return 449 + 463 * octal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OctalIntegerLiteral getOctal() { + return this.octal; + } + + @Override + public boolean hasOctal() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(octal)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/JustDate.java b/src/org/rascalmpl/ast/JustDate.java new file mode 100644 index 00000000000..fda759a189b --- /dev/null +++ b/src/org/rascalmpl/ast/JustDate.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class JustDate extends AbstractAST { + public JustDate(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends JustDate { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitJustDateLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/JustTime.java b/src/org/rascalmpl/ast/JustTime.java new file mode 100644 index 00000000000..1f8d3d9510d --- /dev/null +++ b/src/org/rascalmpl/ast/JustTime.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class JustTime extends AbstractAST { + public JustTime(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends JustTime { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitJustTimeLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/KeywordArgument_Expression.java b/src/org/rascalmpl/ast/KeywordArgument_Expression.java new file mode 100644 index 00000000000..a3d36aa445a --- /dev/null +++ b/src/org/rascalmpl/ast/KeywordArgument_Expression.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class KeywordArgument_Expression extends AbstractAST { + public KeywordArgument_Expression(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends KeywordArgument_Expression { + // Production: sig("Default",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression expression; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.name = name; + this.expression = expression; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordArgument_ExpressionDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.name.equals(this.name) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 971 + 179 * name.hashCode() + 229 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(expression)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/KeywordArguments_Expression.java b/src/org/rascalmpl/ast/KeywordArguments_Expression.java new file mode 100644 index 00000000000..7a19baa2a8b --- /dev/null +++ b/src/org/rascalmpl/ast/KeywordArguments_Expression.java @@ -0,0 +1,197 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class KeywordArguments_Expression extends AbstractAST { + public KeywordArguments_Expression(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasKeywordArgumentList() { + return false; + } + + public java.util.List getKeywordArgumentList() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptionalComma() { + return false; + } + + public org.rascalmpl.ast.OptionalComma getOptionalComma() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends KeywordArguments_Expression { + // Production: sig("Default",[arg("org.rascalmpl.ast.OptionalComma","optionalComma"),arg("java.util.List\","keywordArgumentList")],breakable=false) + + + private final org.rascalmpl.ast.OptionalComma optionalComma; + private final java.util.List keywordArgumentList; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalComma optionalComma, java.util.List keywordArgumentList) { + super(src, node); + + this.optionalComma = optionalComma; + this.keywordArgumentList = keywordArgumentList; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordArguments_ExpressionDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = optionalComma.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optionalComma.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : keywordArgumentList) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.optionalComma.equals(this.optionalComma) && tmp.keywordArgumentList.equals(this.keywordArgumentList) ; + } + + @Override + public int hashCode() { + return 823 + 43 * optionalComma.hashCode() + 733 * keywordArgumentList.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalComma getOptionalComma() { + return this.optionalComma; + } + + @Override + public boolean hasOptionalComma() { + return true; + } + @Override + public java.util.List getKeywordArgumentList() { + return this.keywordArgumentList; + } + + @Override + public boolean hasKeywordArgumentList() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(optionalComma), clone(keywordArgumentList)); + } + + } + public boolean isNone() { + return false; + } + + static public class None extends KeywordArguments_Expression { + // Production: sig("None",[],breakable=false) + + + + public None(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNone() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordArguments_ExpressionNone(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof None)) { + return false; + } + None tmp = (None) o; + return true ; + } + + @Override + public int hashCode() { + return 239 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/KeywordFormal.java b/src/org/rascalmpl/ast/KeywordFormal.java new file mode 100644 index 00000000000..5f62914613f --- /dev/null +++ b/src/org/rascalmpl/ast/KeywordFormal.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class KeywordFormal extends AbstractAST { + public KeywordFormal(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends KeywordFormal { + // Production: sig("Default",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression expression; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.type = type; + this.name = name; + this.expression = expression; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordFormalDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.type.equals(this.type) && tmp.name.equals(this.name) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 941 + 941 * type.hashCode() + 2 * name.hashCode() + 421 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(name), clone(expression)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/KeywordFormals.java b/src/org/rascalmpl/ast/KeywordFormals.java new file mode 100644 index 00000000000..39da173f4d0 --- /dev/null +++ b/src/org/rascalmpl/ast/KeywordFormals.java @@ -0,0 +1,197 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class KeywordFormals extends AbstractAST { + public KeywordFormals(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasKeywordFormalList() { + return false; + } + + public java.util.List getKeywordFormalList() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOptionalComma() { + return false; + } + + public org.rascalmpl.ast.OptionalComma getOptionalComma() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends KeywordFormals { + // Production: sig("Default",[arg("org.rascalmpl.ast.OptionalComma","optionalComma"),arg("java.util.List\","keywordFormalList")],breakable=false) + + + private final org.rascalmpl.ast.OptionalComma optionalComma; + private final java.util.List keywordFormalList; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalComma optionalComma, java.util.List keywordFormalList) { + super(src, node); + + this.optionalComma = optionalComma; + this.keywordFormalList = keywordFormalList; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordFormalsDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = optionalComma.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optionalComma.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : keywordFormalList) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.optionalComma.equals(this.optionalComma) && tmp.keywordFormalList.equals(this.keywordFormalList) ; + } + + @Override + public int hashCode() { + return 941 + 307 * optionalComma.hashCode() + 941 * keywordFormalList.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalComma getOptionalComma() { + return this.optionalComma; + } + + @Override + public boolean hasOptionalComma() { + return true; + } + @Override + public java.util.List getKeywordFormalList() { + return this.keywordFormalList; + } + + @Override + public boolean hasKeywordFormalList() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(optionalComma), clone(keywordFormalList)); + } + + } + public boolean isNone() { + return false; + } + + static public class None extends KeywordFormals { + // Production: sig("None",[],breakable=false) + + + + public None(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNone() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKeywordFormalsNone(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof None)) { + return false; + } + None tmp = (None) o; + return true ; + } + + @Override + public int hashCode() { + return 631 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Kind.java b/src/org/rascalmpl/ast/Kind.java new file mode 100644 index 00000000000..07e5f1f9550 --- /dev/null +++ b/src/org/rascalmpl/ast/Kind.java @@ -0,0 +1,528 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Kind extends AbstractAST { + public Kind(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isAlias() { + return false; + } + + static public class Alias extends Kind { + // Production: sig("Alias",[],breakable=false) + + + + public Alias(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAlias() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindAlias(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Alias)) { + return false; + } + Alias tmp = (Alias) o; + return true ; + } + + @Override + public int hashCode() { + return 269 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isAll() { + return false; + } + + static public class All extends Kind { + // Production: sig("All",[],breakable=false) + + + + public All(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAll() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindAll(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof All)) { + return false; + } + All tmp = (All) o; + return true ; + } + + @Override + public int hashCode() { + return 293 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isAnno() { + return false; + } + + static public class Anno extends Kind { + // Production: sig("Anno",[],breakable=false) + + + + public Anno(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAnno() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindAnno(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Anno)) { + return false; + } + Anno tmp = (Anno) o; + return true ; + } + + @Override + public int hashCode() { + return 757 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isData() { + return false; + } + + static public class Data extends Kind { + // Production: sig("Data",[],breakable=false) + + + + public Data(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isData() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindData(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Data)) { + return false; + } + Data tmp = (Data) o; + return true ; + } + + @Override + public int hashCode() { + return 829 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isFunction() { + return false; + } + + static public class Function extends Kind { + // Production: sig("Function",[],breakable=false) + + + + public Function(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isFunction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindFunction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Function)) { + return false; + } + Function tmp = (Function) o; + return true ; + } + + @Override + public int hashCode() { + return 47 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isModule() { + return false; + } + + static public class Module extends Kind { + // Production: sig("Module",[],breakable=false) + + + + public Module(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isModule() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindModule(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Module)) { + return false; + } + Module tmp = (Module) o; + return true ; + } + + @Override + public int hashCode() { + return 257 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTag() { + return false; + } + + static public class Tag extends Kind { + // Production: sig("Tag",[],breakable=false) + + + + public Tag(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isTag() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindTag(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tag)) { + return false; + } + Tag tmp = (Tag) o; + return true ; + } + + @Override + public int hashCode() { + return 367 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isVariable() { + return false; + } + + static public class Variable extends Kind { + // Production: sig("Variable",[],breakable=false) + + + + public Variable(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Variable)) { + return false; + } + Variable tmp = (Variable) o; + return true ; + } + + @Override + public int hashCode() { + return 421 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isView() { + return false; + } + + static public class View extends Kind { + // Production: sig("View",[],breakable=false) + + + + public View(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isView() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitKindView(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof View)) { + return false; + } + View tmp = (View) o; + return true ; + } + + @Override + public int hashCode() { + return 577 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/LAYOUT.java b/src/org/rascalmpl/ast/LAYOUT.java new file mode 100644 index 00000000000..8b17a784034 --- /dev/null +++ b/src/org/rascalmpl/ast/LAYOUT.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class LAYOUT extends AbstractAST { + public LAYOUT(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends LAYOUT { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitLAYOUTLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Label.java b/src/org/rascalmpl/ast/Label.java new file mode 100644 index 00000000000..af148f82145 --- /dev/null +++ b/src/org/rascalmpl/ast/Label.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Label extends AbstractAST { + public Label(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Label { + // Production: sig("Default",[arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLabelDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 653 + 701 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } + public boolean isEmpty() { + return false; + } + + static public class Empty extends Label { + // Production: sig("Empty",[],breakable=false) + + + + public Empty(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLabelEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true ; + } + + @Override + public int hashCode() { + return 233 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Literal.java b/src/org/rascalmpl/ast/Literal.java new file mode 100644 index 00000000000..5d716036b07 --- /dev/null +++ b/src/org/rascalmpl/ast/Literal.java @@ -0,0 +1,681 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Literal extends AbstractAST { + public Literal(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasBooleanLiteral() { + return false; + } + + public org.rascalmpl.ast.BooleanLiteral getBooleanLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDateTimeLiteral() { + return false; + } + + public org.rascalmpl.ast.DateTimeLiteral getDateTimeLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasIntegerLiteral() { + return false; + } + + public org.rascalmpl.ast.IntegerLiteral getIntegerLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLocationLiteral() { + return false; + } + + public org.rascalmpl.ast.LocationLiteral getLocationLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRationalLiteral() { + return false; + } + + public org.rascalmpl.ast.RationalLiteral getRationalLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRealLiteral() { + return false; + } + + public org.rascalmpl.ast.RealLiteral getRealLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRegExpLiteral() { + return false; + } + + public org.rascalmpl.ast.RegExpLiteral getRegExpLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStringLiteral() { + return false; + } + + public org.rascalmpl.ast.StringLiteral getStringLiteral() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isBoolean() { + return false; + } + + static public class Boolean extends Literal { + // Production: sig("Boolean",[arg("org.rascalmpl.ast.BooleanLiteral","booleanLiteral")],breakable=false) + + + private final org.rascalmpl.ast.BooleanLiteral booleanLiteral; + + public Boolean(ISourceLocation src, IConstructor node , org.rascalmpl.ast.BooleanLiteral booleanLiteral) { + super(src, node); + + this.booleanLiteral = booleanLiteral; + } + + @Override + public boolean isBoolean() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralBoolean(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = booleanLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + booleanLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Boolean)) { + return false; + } + Boolean tmp = (Boolean) o; + return true && tmp.booleanLiteral.equals(this.booleanLiteral) ; + } + + @Override + public int hashCode() { + return 577 + 643 * booleanLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.BooleanLiteral getBooleanLiteral() { + return this.booleanLiteral; + } + + @Override + public boolean hasBooleanLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(booleanLiteral)); + } + + } + public boolean isDateTime() { + return false; + } + + static public class DateTime extends Literal { + // Production: sig("DateTime",[arg("org.rascalmpl.ast.DateTimeLiteral","dateTimeLiteral")],breakable=false) + + + private final org.rascalmpl.ast.DateTimeLiteral dateTimeLiteral; + + public DateTime(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DateTimeLiteral dateTimeLiteral) { + super(src, node); + + this.dateTimeLiteral = dateTimeLiteral; + } + + @Override + public boolean isDateTime() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralDateTime(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = dateTimeLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + dateTimeLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DateTime)) { + return false; + } + DateTime tmp = (DateTime) o; + return true && tmp.dateTimeLiteral.equals(this.dateTimeLiteral) ; + } + + @Override + public int hashCode() { + return 631 + 173 * dateTimeLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DateTimeLiteral getDateTimeLiteral() { + return this.dateTimeLiteral; + } + + @Override + public boolean hasDateTimeLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(dateTimeLiteral)); + } + + } + public boolean isInteger() { + return false; + } + + static public class Integer extends Literal { + // Production: sig("Integer",[arg("org.rascalmpl.ast.IntegerLiteral","integerLiteral")],breakable=false) + + + private final org.rascalmpl.ast.IntegerLiteral integerLiteral; + + public Integer(ISourceLocation src, IConstructor node , org.rascalmpl.ast.IntegerLiteral integerLiteral) { + super(src, node); + + this.integerLiteral = integerLiteral; + } + + @Override + public boolean isInteger() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralInteger(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = integerLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + integerLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Integer)) { + return false; + } + Integer tmp = (Integer) o; + return true && tmp.integerLiteral.equals(this.integerLiteral) ; + } + + @Override + public int hashCode() { + return 103 + 257 * integerLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.IntegerLiteral getIntegerLiteral() { + return this.integerLiteral; + } + + @Override + public boolean hasIntegerLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(integerLiteral)); + } + + } + public boolean isLocation() { + return false; + } + + static public class Location extends Literal { + // Production: sig("Location",[arg("org.rascalmpl.ast.LocationLiteral","locationLiteral")],breakable=false) + + + private final org.rascalmpl.ast.LocationLiteral locationLiteral; + + public Location(ISourceLocation src, IConstructor node , org.rascalmpl.ast.LocationLiteral locationLiteral) { + super(src, node); + + this.locationLiteral = locationLiteral; + } + + @Override + public boolean isLocation() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralLocation(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = locationLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + locationLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Location)) { + return false; + } + Location tmp = (Location) o; + return true && tmp.locationLiteral.equals(this.locationLiteral) ; + } + + @Override + public int hashCode() { + return 283 + 521 * locationLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.LocationLiteral getLocationLiteral() { + return this.locationLiteral; + } + + @Override + public boolean hasLocationLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(locationLiteral)); + } + + } + public boolean isRational() { + return false; + } + + static public class Rational extends Literal { + // Production: sig("Rational",[arg("org.rascalmpl.ast.RationalLiteral","rationalLiteral")],breakable=false) + + + private final org.rascalmpl.ast.RationalLiteral rationalLiteral; + + public Rational(ISourceLocation src, IConstructor node , org.rascalmpl.ast.RationalLiteral rationalLiteral) { + super(src, node); + + this.rationalLiteral = rationalLiteral; + } + + @Override + public boolean isRational() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralRational(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = rationalLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rationalLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Rational)) { + return false; + } + Rational tmp = (Rational) o; + return true && tmp.rationalLiteral.equals(this.rationalLiteral) ; + } + + @Override + public int hashCode() { + return 127 + 89 * rationalLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.RationalLiteral getRationalLiteral() { + return this.rationalLiteral; + } + + @Override + public boolean hasRationalLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(rationalLiteral)); + } + + } + public boolean isReal() { + return false; + } + + static public class Real extends Literal { + // Production: sig("Real",[arg("org.rascalmpl.ast.RealLiteral","realLiteral")],breakable=false) + + + private final org.rascalmpl.ast.RealLiteral realLiteral; + + public Real(ISourceLocation src, IConstructor node , org.rascalmpl.ast.RealLiteral realLiteral) { + super(src, node); + + this.realLiteral = realLiteral; + } + + @Override + public boolean isReal() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralReal(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = realLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + realLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Real)) { + return false; + } + Real tmp = (Real) o; + return true && tmp.realLiteral.equals(this.realLiteral) ; + } + + @Override + public int hashCode() { + return 739 + 547 * realLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.RealLiteral getRealLiteral() { + return this.realLiteral; + } + + @Override + public boolean hasRealLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(realLiteral)); + } + + } + public boolean isRegExp() { + return false; + } + + static public class RegExp extends Literal { + // Production: sig("RegExp",[arg("org.rascalmpl.ast.RegExpLiteral","regExpLiteral")],breakable=false) + + + private final org.rascalmpl.ast.RegExpLiteral regExpLiteral; + + public RegExp(ISourceLocation src, IConstructor node , org.rascalmpl.ast.RegExpLiteral regExpLiteral) { + super(src, node); + + this.regExpLiteral = regExpLiteral; + } + + @Override + public boolean isRegExp() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralRegExp(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = regExpLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + regExpLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof RegExp)) { + return false; + } + RegExp tmp = (RegExp) o; + return true && tmp.regExpLiteral.equals(this.regExpLiteral) ; + } + + @Override + public int hashCode() { + return 3 + 373 * regExpLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.RegExpLiteral getRegExpLiteral() { + return this.regExpLiteral; + } + + @Override + public boolean hasRegExpLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(regExpLiteral)); + } + + } + public boolean isString() { + return false; + } + + static public class String extends Literal { + // Production: sig("String",[arg("org.rascalmpl.ast.StringLiteral","stringLiteral")],breakable=false) + + + private final org.rascalmpl.ast.StringLiteral stringLiteral; + + public String(ISourceLocation src, IConstructor node , org.rascalmpl.ast.StringLiteral stringLiteral) { + super(src, node); + + this.stringLiteral = stringLiteral; + } + + @Override + public boolean isString() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLiteralString(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = stringLiteral.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + stringLiteral.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof String)) { + return false; + } + String tmp = (String) o; + return true && tmp.stringLiteral.equals(this.stringLiteral) ; + } + + @Override + public int hashCode() { + return 31 + 283 * stringLiteral.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.StringLiteral getStringLiteral() { + return this.stringLiteral; + } + + @Override + public boolean hasStringLiteral() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(stringLiteral)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/LocalVariableDeclaration.java b/src/org/rascalmpl/ast/LocalVariableDeclaration.java new file mode 100644 index 00000000000..8c6a80c9af7 --- /dev/null +++ b/src/org/rascalmpl/ast/LocalVariableDeclaration.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class LocalVariableDeclaration extends AbstractAST { + public LocalVariableDeclaration(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDeclarator() { + return false; + } + + public org.rascalmpl.ast.Declarator getDeclarator() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends LocalVariableDeclaration { + // Production: sig("Default",[arg("org.rascalmpl.ast.Declarator","declarator")],breakable=false) + + + private final org.rascalmpl.ast.Declarator declarator; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declarator declarator) { + super(src, node); + + this.declarator = declarator; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLocalVariableDeclarationDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declarator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declarator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.declarator.equals(this.declarator) ; + } + + @Override + public int hashCode() { + return 461 + 7 * declarator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Declarator getDeclarator() { + return this.declarator; + } + + @Override + public boolean hasDeclarator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declarator)); + } + + } + public boolean isDynamic() { + return false; + } + + static public class Dynamic extends LocalVariableDeclaration { + // Production: sig("Dynamic",[arg("org.rascalmpl.ast.Declarator","declarator")],breakable=false) + + + private final org.rascalmpl.ast.Declarator declarator; + + public Dynamic(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declarator declarator) { + super(src, node); + + this.declarator = declarator; + } + + @Override + public boolean isDynamic() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLocalVariableDeclarationDynamic(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declarator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declarator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Dynamic)) { + return false; + } + Dynamic tmp = (Dynamic) o; + return true && tmp.declarator.equals(this.declarator) ; + } + + @Override + public int hashCode() { + return 463 + 691 * declarator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Declarator getDeclarator() { + return this.declarator; + } + + @Override + public boolean hasDeclarator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declarator)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/LocationLiteral.java b/src/org/rascalmpl/ast/LocationLiteral.java new file mode 100644 index 00000000000..b45792e0f24 --- /dev/null +++ b/src/org/rascalmpl/ast/LocationLiteral.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class LocationLiteral extends AbstractAST { + public LocationLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasPathPart() { + return false; + } + + public org.rascalmpl.ast.PathPart getPathPart() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasProtocolPart() { + return false; + } + + public org.rascalmpl.ast.ProtocolPart getProtocolPart() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends LocationLiteral { + // Production: sig("Default",[arg("org.rascalmpl.ast.ProtocolPart","protocolPart"),arg("org.rascalmpl.ast.PathPart","pathPart")],breakable=false) + + + private final org.rascalmpl.ast.ProtocolPart protocolPart; + private final org.rascalmpl.ast.PathPart pathPart; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ProtocolPart protocolPart, org.rascalmpl.ast.PathPart pathPart) { + super(src, node); + + this.protocolPart = protocolPart; + this.pathPart = pathPart; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitLocationLiteralDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = protocolPart.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + protocolPart.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = pathPart.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pathPart.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.protocolPart.equals(this.protocolPart) && tmp.pathPart.equals(this.pathPart) ; + } + + @Override + public int hashCode() { + return 479 + 89 * protocolPart.hashCode() + 937 * pathPart.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.ProtocolPart getProtocolPart() { + return this.protocolPart; + } + + @Override + public boolean hasProtocolPart() { + return true; + } + @Override + public org.rascalmpl.ast.PathPart getPathPart() { + return this.pathPart; + } + + @Override + public boolean hasPathPart() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(protocolPart), clone(pathPart)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Mapping_Expression.java b/src/org/rascalmpl/ast/Mapping_Expression.java new file mode 100644 index 00000000000..2a7f8a9e4ef --- /dev/null +++ b/src/org/rascalmpl/ast/Mapping_Expression.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Mapping_Expression extends AbstractAST { + public Mapping_Expression(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasFrom() { + return false; + } + + public org.rascalmpl.ast.Expression getFrom() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTo() { + return false; + } + + public org.rascalmpl.ast.Expression getTo() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Mapping_Expression { + // Production: sig("Default",[arg("org.rascalmpl.ast.Expression","from"),arg("org.rascalmpl.ast.Expression","to")],breakable=false) + + + private final org.rascalmpl.ast.Expression from; + private final org.rascalmpl.ast.Expression to; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression from, org.rascalmpl.ast.Expression to) { + super(src, node); + + this.from = from; + this.to = to; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitMapping_ExpressionDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = from.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + from.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = to.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + to.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.from.equals(this.from) && tmp.to.equals(this.to) ; + } + + @Override + public int hashCode() { + return 631 + 797 * from.hashCode() + 239 * to.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getFrom() { + return this.from; + } + + @Override + public boolean hasFrom() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getTo() { + return this.to; + } + + @Override + public boolean hasTo() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(from), clone(to)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/MidPathChars.java b/src/org/rascalmpl/ast/MidPathChars.java new file mode 100644 index 00000000000..4145eac9a3f --- /dev/null +++ b/src/org/rascalmpl/ast/MidPathChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class MidPathChars extends AbstractAST { + public MidPathChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends MidPathChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitMidPathCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/MidProtocolChars.java b/src/org/rascalmpl/ast/MidProtocolChars.java new file mode 100644 index 00000000000..a3180b84691 --- /dev/null +++ b/src/org/rascalmpl/ast/MidProtocolChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class MidProtocolChars extends AbstractAST { + public MidProtocolChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends MidProtocolChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitMidProtocolCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/MidStringChars.java b/src/org/rascalmpl/ast/MidStringChars.java new file mode 100644 index 00000000000..74c3f6c55be --- /dev/null +++ b/src/org/rascalmpl/ast/MidStringChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class MidStringChars extends AbstractAST { + public MidStringChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends MidStringChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitMidStringCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Module.java b/src/org/rascalmpl/ast/Module.java new file mode 100644 index 00000000000..8a52876d2cd --- /dev/null +++ b/src/org/rascalmpl/ast/Module.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Module extends AbstractAST { + public Module(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasBody() { + return false; + } + + public org.rascalmpl.ast.Body getBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasHeader() { + return false; + } + + public org.rascalmpl.ast.Header getHeader() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Module { + // Production: sig("Default",[arg("org.rascalmpl.ast.Header","header"),arg("org.rascalmpl.ast.Body","body")],breakable=false) + + + private final org.rascalmpl.ast.Header header; + private final org.rascalmpl.ast.Body body; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Header header, org.rascalmpl.ast.Body body) { + super(src, node); + + this.header = header; + this.body = body; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitModuleDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = header.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + header.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.header.equals(this.header) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 137 + 277 * header.hashCode() + 281 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Header getHeader() { + return this.header; + } + + @Override + public boolean hasHeader() { + return true; + } + @Override + public org.rascalmpl.ast.Body getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(header), clone(body)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ModuleActuals.java b/src/org/rascalmpl/ast/ModuleActuals.java new file mode 100644 index 00000000000..3307eccd1a6 --- /dev/null +++ b/src/org/rascalmpl/ast/ModuleActuals.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ModuleActuals extends AbstractAST { + public ModuleActuals(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasTypes() { + return false; + } + + public java.util.List getTypes() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends ModuleActuals { + // Production: sig("Default",[arg("java.util.List\","types")],breakable=false) + + + private final java.util.List types; + + public Default(ISourceLocation src, IConstructor node , java.util.List types) { + super(src, node); + + this.types = types; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitModuleActualsDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : types) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.types.equals(this.types) ; + } + + @Override + public int hashCode() { + return 229 + 211 * types.hashCode() ; + } + + + @Override + public java.util.List getTypes() { + return this.types; + } + + @Override + public boolean hasTypes() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(types)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ModuleParameters.java b/src/org/rascalmpl/ast/ModuleParameters.java new file mode 100644 index 00000000000..49377290241 --- /dev/null +++ b/src/org/rascalmpl/ast/ModuleParameters.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ModuleParameters extends AbstractAST { + public ModuleParameters(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasParameters() { + return false; + } + + public java.util.List getParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends ModuleParameters { + // Production: sig("Default",[arg("java.util.List\","parameters")],breakable=false) + + + private final java.util.List parameters; + + public Default(ISourceLocation src, IConstructor node , java.util.List parameters) { + super(src, node); + + this.parameters = parameters; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitModuleParametersDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : parameters) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.parameters.equals(this.parameters) ; + } + + @Override + public int hashCode() { + return 83 + 673 * parameters.hashCode() ; + } + + + @Override + public java.util.List getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(parameters)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Name.java b/src/org/rascalmpl/ast/Name.java new file mode 100644 index 00000000000..0a4afd5622e --- /dev/null +++ b/src/org/rascalmpl/ast/Name.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Name extends AbstractAST { + public Name(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Name { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitNameLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/NamedBackslash.java b/src/org/rascalmpl/ast/NamedBackslash.java new file mode 100644 index 00000000000..2c7c8486b2c --- /dev/null +++ b/src/org/rascalmpl/ast/NamedBackslash.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class NamedBackslash extends AbstractAST { + public NamedBackslash(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends NamedBackslash { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitNamedBackslashLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/NamedRegExp.java b/src/org/rascalmpl/ast/NamedRegExp.java new file mode 100644 index 00000000000..8a881ec2f37 --- /dev/null +++ b/src/org/rascalmpl/ast/NamedRegExp.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class NamedRegExp extends AbstractAST { + public NamedRegExp(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends NamedRegExp { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitNamedRegExpLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Nonterminal.java b/src/org/rascalmpl/ast/Nonterminal.java new file mode 100644 index 00000000000..a11370447bc --- /dev/null +++ b/src/org/rascalmpl/ast/Nonterminal.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Nonterminal extends AbstractAST { + public Nonterminal(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Nonterminal { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitNonterminalLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/NonterminalLabel.java b/src/org/rascalmpl/ast/NonterminalLabel.java new file mode 100644 index 00000000000..e5ebcd267f8 --- /dev/null +++ b/src/org/rascalmpl/ast/NonterminalLabel.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class NonterminalLabel extends AbstractAST { + public NonterminalLabel(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends NonterminalLabel { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitNonterminalLabelLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/NullASTVisitor.java b/src/org/rascalmpl/ast/NullASTVisitor.java new file mode 100644 index 00000000000..aca2b779cb3 --- /dev/null +++ b/src/org/rascalmpl/ast/NullASTVisitor.java @@ -0,0 +1,1689 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + +public class NullASTVisitor implements IASTVisitor { + + public T visitAssignableAnnotation(Assignable.Annotation x) { + return null; + } + + public T visitAssignableBracket(Assignable.Bracket x) { + return null; + } + + public T visitAssignableConstructor(Assignable.Constructor x) { + return null; + } + + public T visitAssignableFieldAccess(Assignable.FieldAccess x) { + return null; + } + + public T visitAssignableIfDefinedOrDefault(Assignable.IfDefinedOrDefault x) { + return null; + } + + public T visitAssignableSlice(Assignable.Slice x) { + return null; + } + + public T visitAssignableSliceStep(Assignable.SliceStep x) { + return null; + } + + public T visitAssignableSubscript(Assignable.Subscript x) { + return null; + } + + public T visitAssignableTuple(Assignable.Tuple x) { + return null; + } + + public T visitAssignableVariable(Assignable.Variable x) { + return null; + } + + public T visitAssignmentAddition(Assignment.Addition x) { + return null; + } + + public T visitAssignmentAppend(Assignment.Append x) { + return null; + } + + public T visitAssignmentDefault(Assignment.Default x) { + return null; + } + + public T visitAssignmentDivision(Assignment.Division x) { + return null; + } + + public T visitAssignmentIfDefined(Assignment.IfDefined x) { + return null; + } + + public T visitAssignmentIntersection(Assignment.Intersection x) { + return null; + } + + public T visitAssignmentProduct(Assignment.Product x) { + return null; + } + + public T visitAssignmentSubtraction(Assignment.Subtraction x) { + return null; + } + + public T visitAssocAssociative(Assoc.Associative x) { + return null; + } + + public T visitAssocLeft(Assoc.Left x) { + return null; + } + + public T visitAssocNonAssociative(Assoc.NonAssociative x) { + return null; + } + + public T visitAssocRight(Assoc.Right x) { + return null; + } + + public T visitBasicTypeBag(BasicType.Bag x) { + return null; + } + + public T visitBasicTypeBool(BasicType.Bool x) { + return null; + } + + public T visitBasicTypeDateTime(BasicType.DateTime x) { + return null; + } + + public T visitBasicTypeInt(BasicType.Int x) { + return null; + } + + public T visitBasicTypeList(BasicType.List x) { + return null; + } + + public T visitBasicTypeListRelation(BasicType.ListRelation x) { + return null; + } + + public T visitBasicTypeLoc(BasicType.Loc x) { + return null; + } + + public T visitBasicTypeMap(BasicType.Map x) { + return null; + } + + public T visitBasicTypeNode(BasicType.Node x) { + return null; + } + + public T visitBasicTypeNum(BasicType.Num x) { + return null; + } + + public T visitBasicTypeRational(BasicType.Rational x) { + return null; + } + + public T visitBasicTypeReal(BasicType.Real x) { + return null; + } + + public T visitBasicTypeRelation(BasicType.Relation x) { + return null; + } + + public T visitBasicTypeSet(BasicType.Set x) { + return null; + } + + public T visitBasicTypeString(BasicType.String x) { + return null; + } + + public T visitBasicTypeTuple(BasicType.Tuple x) { + return null; + } + + public T visitBasicTypeType(BasicType.Type x) { + return null; + } + + public T visitBasicTypeValue(BasicType.Value x) { + return null; + } + + public T visitBasicTypeVoid(BasicType.Void x) { + return null; + } + + public T visitBodyToplevels(Body.Toplevels x) { + return null; + } + + public T visitBoundDefault(Bound.Default x) { + return null; + } + + public T visitBoundEmpty(Bound.Empty x) { + return null; + } + + public T visitCaseDefault(Case.Default x) { + return null; + } + + public T visitCasePatternWithAction(Case.PatternWithAction x) { + return null; + } + + public T visitCatchBinding(Catch.Binding x) { + return null; + } + + public T visitCatchDefault(Catch.Default x) { + return null; + } + + public T visitClassBracket(Class.Bracket x) { + return null; + } + + public T visitClassComplement(Class.Complement x) { + return null; + } + + public T visitClassDifference(Class.Difference x) { + return null; + } + + public T visitClassIntersection(Class.Intersection x) { + return null; + } + + public T visitClassSimpleCharclass(Class.SimpleCharclass x) { + return null; + } + + public T visitClassUnion(Class.Union x) { + return null; + } + + public T visitCommandDeclaration(Command.Declaration x) { + return null; + } + + public T visitCommandExpression(Command.Expression x) { + return null; + } + + public T visitCommandImport(Command.Import x) { + return null; + } + + public T visitCommandShell(Command.Shell x) { + return null; + } + + public T visitCommandStatement(Command.Statement x) { + return null; + } + + public T visitCommandsCommandlist(Commands.Commandlist x) { + return null; + } + + public T visitCommonKeywordParametersAbsent(CommonKeywordParameters.Absent x) { + return null; + } + + public T visitCommonKeywordParametersPresent(CommonKeywordParameters.Present x) { + return null; + } + + public T visitComprehensionList(Comprehension.List x) { + return null; + } + + public T visitComprehensionMap(Comprehension.Map x) { + return null; + } + + public T visitComprehensionSet(Comprehension.Set x) { + return null; + } + + public T visitConcreteHoleOne(ConcreteHole.One x) { + return null; + } + + public T visitDataTargetEmpty(DataTarget.Empty x) { + return null; + } + + public T visitDataTargetLabeled(DataTarget.Labeled x) { + return null; + } + + public T visitDataTypeSelectorSelector(DataTypeSelector.Selector x) { + return null; + } + + public T visitDateTimeLiteralDateAndTimeLiteral(DateTimeLiteral.DateAndTimeLiteral x) { + return null; + } + + public T visitDateTimeLiteralDateLiteral(DateTimeLiteral.DateLiteral x) { + return null; + } + + public T visitDateTimeLiteralTimeLiteral(DateTimeLiteral.TimeLiteral x) { + return null; + } + + public T visitDeclarationAlias(Declaration.Alias x) { + return null; + } + + public T visitDeclarationAnnotation(Declaration.Annotation x) { + return null; + } + + public T visitDeclarationData(Declaration.Data x) { + return null; + } + + public T visitDeclarationDataAbstract(Declaration.DataAbstract x) { + return null; + } + + public T visitDeclarationFunction(Declaration.Function x) { + return null; + } + + public T visitDeclarationTag(Declaration.Tag x) { + return null; + } + + public T visitDeclarationVariable(Declaration.Variable x) { + return null; + } + + public T visitDeclaratorDefault(Declarator.Default x) { + return null; + } + + public T visitEvalCommandDeclaration(EvalCommand.Declaration x) { + return null; + } + + public T visitEvalCommandImport(EvalCommand.Import x) { + return null; + } + + public T visitEvalCommandOutput(EvalCommand.Output x) { + return null; + } + + public T visitEvalCommandStatement(EvalCommand.Statement x) { + return null; + } + + public T visitExpressionAddition(Expression.Addition x) { + return null; + } + + public T visitExpressionAll(Expression.All x) { + return null; + } + + public T visitExpressionAnd(Expression.And x) { + return null; + } + + public T visitExpressionAnti(Expression.Anti x) { + return null; + } + + public T visitExpressionAny(Expression.Any x) { + return null; + } + + public T visitExpressionAppendAfter(Expression.AppendAfter x) { + return null; + } + + public T visitExpressionAsType(Expression.AsType x) { + return null; + } + + public T visitExpressionBracket(Expression.Bracket x) { + return null; + } + + public T visitExpressionCallOrTree(Expression.CallOrTree x) { + return null; + } + + public T visitExpressionClosure(Expression.Closure x) { + return null; + } + + public T visitExpressionComposition(Expression.Composition x) { + return null; + } + + public T visitExpressionComprehension(Expression.Comprehension x) { + return null; + } + + public T visitExpressionConcrete(Expression.Concrete x) { + return null; + } + + public T visitExpressionDescendant(Expression.Descendant x) { + return null; + } + + public T visitExpressionDivision(Expression.Division x) { + return null; + } + + public T visitExpressionEnumerator(Expression.Enumerator x) { + return null; + } + + public T visitExpressionEquals(Expression.Equals x) { + return null; + } + + public T visitExpressionEquivalence(Expression.Equivalence x) { + return null; + } + + public T visitExpressionFieldAccess(Expression.FieldAccess x) { + return null; + } + + public T visitExpressionFieldProject(Expression.FieldProject x) { + return null; + } + + public T visitExpressionFieldUpdate(Expression.FieldUpdate x) { + return null; + } + + public T visitExpressionGetAnnotation(Expression.GetAnnotation x) { + return null; + } + + public T visitExpressionGreaterThan(Expression.GreaterThan x) { + return null; + } + + public T visitExpressionGreaterThanOrEq(Expression.GreaterThanOrEq x) { + return null; + } + + public T visitExpressionHas(Expression.Has x) { + return null; + } + + public T visitExpressionIfDefinedOtherwise(Expression.IfDefinedOtherwise x) { + return null; + } + + public T visitExpressionIfThenElse(Expression.IfThenElse x) { + return null; + } + + public T visitExpressionImplication(Expression.Implication x) { + return null; + } + + public T visitExpressionIn(Expression.In x) { + return null; + } + + public T visitExpressionInsertBefore(Expression.InsertBefore x) { + return null; + } + + public T visitExpressionIntersection(Expression.Intersection x) { + return null; + } + + public T visitExpressionIs(Expression.Is x) { + return null; + } + + public T visitExpressionIsDefined(Expression.IsDefined x) { + return null; + } + + public T visitExpressionIt(Expression.It x) { + return null; + } + + public T visitExpressionJoin(Expression.Join x) { + return null; + } + + public T visitExpressionLessThan(Expression.LessThan x) { + return null; + } + + public T visitExpressionLessThanOrEq(Expression.LessThanOrEq x) { + return null; + } + + public T visitExpressionList(Expression.List x) { + return null; + } + + public T visitExpressionLiteral(Expression.Literal x) { + return null; + } + + public T visitExpressionMap(Expression.Map x) { + return null; + } + + public T visitExpressionMatch(Expression.Match x) { + return null; + } + + public T visitExpressionModulo(Expression.Modulo x) { + return null; + } + + public T visitExpressionMultiVariable(Expression.MultiVariable x) { + return null; + } + + public T visitExpressionNegation(Expression.Negation x) { + return null; + } + + public T visitExpressionNegative(Expression.Negative x) { + return null; + } + + public T visitExpressionNoMatch(Expression.NoMatch x) { + return null; + } + + public T visitExpressionNonEmptyBlock(Expression.NonEmptyBlock x) { + return null; + } + + public T visitExpressionNonEquals(Expression.NonEquals x) { + return null; + } + + public T visitExpressionNotIn(Expression.NotIn x) { + return null; + } + + public T visitExpressionOr(Expression.Or x) { + return null; + } + + public T visitExpressionProduct(Expression.Product x) { + return null; + } + + public T visitExpressionQualifiedName(Expression.QualifiedName x) { + return null; + } + + public T visitExpressionRange(Expression.Range x) { + return null; + } + + public T visitExpressionReducer(Expression.Reducer x) { + return null; + } + + public T visitExpressionReifiedType(Expression.ReifiedType x) { + return null; + } + + public T visitExpressionReifyType(Expression.ReifyType x) { + return null; + } + + public T visitExpressionRemainder(Expression.Remainder x) { + return null; + } + + public T visitExpressionSet(Expression.Set x) { + return null; + } + + public T visitExpressionSetAnnotation(Expression.SetAnnotation x) { + return null; + } + + public T visitExpressionSlice(Expression.Slice x) { + return null; + } + + public T visitExpressionSliceStep(Expression.SliceStep x) { + return null; + } + + public T visitExpressionSplice(Expression.Splice x) { + return null; + } + + public T visitExpressionSplicePlus(Expression.SplicePlus x) { + return null; + } + + public T visitExpressionStepRange(Expression.StepRange x) { + return null; + } + + public T visitExpressionSubscript(Expression.Subscript x) { + return null; + } + + public T visitExpressionSubtraction(Expression.Subtraction x) { + return null; + } + + public T visitExpressionTransitiveClosure(Expression.TransitiveClosure x) { + return null; + } + + public T visitExpressionTransitiveReflexiveClosure(Expression.TransitiveReflexiveClosure x) { + return null; + } + + public T visitExpressionTuple(Expression.Tuple x) { + return null; + } + + public T visitExpressionTypedVariable(Expression.TypedVariable x) { + return null; + } + + public T visitExpressionTypedVariableBecomes(Expression.TypedVariableBecomes x) { + return null; + } + + public T visitExpressionVariableBecomes(Expression.VariableBecomes x) { + return null; + } + + public T visitExpressionVisit(Expression.Visit x) { + return null; + } + + public T visitExpressionVoidClosure(Expression.VoidClosure x) { + return null; + } + + public T visitFieldIndex(Field.Index x) { + return null; + } + + public T visitFieldName(Field.Name x) { + return null; + } + + public T visitFormalsDefault(Formals.Default x) { + return null; + } + + public T visitFunctionBodyDefault(FunctionBody.Default x) { + return null; + } + + public T visitFunctionDeclarationAbstract(FunctionDeclaration.Abstract x) { + return null; + } + + public T visitFunctionDeclarationConditional(FunctionDeclaration.Conditional x) { + return null; + } + + public T visitFunctionDeclarationDefault(FunctionDeclaration.Default x) { + return null; + } + + public T visitFunctionDeclarationExpression(FunctionDeclaration.Expression x) { + return null; + } + + public T visitFunctionModifierDefault(FunctionModifier.Default x) { + return null; + } + + public T visitFunctionModifierJava(FunctionModifier.Java x) { + return null; + } + + public T visitFunctionModifierTest(FunctionModifier.Test x) { + return null; + } + + public T visitFunctionModifiersModifierlist(FunctionModifiers.Modifierlist x) { + return null; + } + + public T visitFunctionTypeTypeArguments(FunctionType.TypeArguments x) { + return null; + } + + public T visitHeaderDefault(Header.Default x) { + return null; + } + + public T visitHeaderParameters(Header.Parameters x) { + return null; + } + + public T visitImportDefault(Import.Default x) { + return null; + } + + public T visitImportExtend(Import.Extend x) { + return null; + } + + public T visitImportExternal(Import.External x) { + return null; + } + + public T visitImportSyntax(Import.Syntax x) { + return null; + } + + public T visitImportedModuleActuals(ImportedModule.Actuals x) { + return null; + } + + public T visitImportedModuleActualsRenaming(ImportedModule.ActualsRenaming x) { + return null; + } + + public T visitImportedModuleDefault(ImportedModule.Default x) { + return null; + } + + public T visitImportedModuleRenamings(ImportedModule.Renamings x) { + return null; + } + + public T visitIntegerLiteralDecimalIntegerLiteral(IntegerLiteral.DecimalIntegerLiteral x) { + return null; + } + + public T visitIntegerLiteralHexIntegerLiteral(IntegerLiteral.HexIntegerLiteral x) { + return null; + } + + public T visitIntegerLiteralOctalIntegerLiteral(IntegerLiteral.OctalIntegerLiteral x) { + return null; + } + + public T visitKeywordArgument_ExpressionDefault(KeywordArgument_Expression.Default x) { + return null; + } + + public T visitKeywordArguments_ExpressionDefault(KeywordArguments_Expression.Default x) { + return null; + } + + public T visitKeywordArguments_ExpressionNone(KeywordArguments_Expression.None x) { + return null; + } + + public T visitKeywordFormalDefault(KeywordFormal.Default x) { + return null; + } + + public T visitKeywordFormalsDefault(KeywordFormals.Default x) { + return null; + } + + public T visitKeywordFormalsNone(KeywordFormals.None x) { + return null; + } + + public T visitKindAlias(Kind.Alias x) { + return null; + } + + public T visitKindAll(Kind.All x) { + return null; + } + + public T visitKindAnno(Kind.Anno x) { + return null; + } + + public T visitKindData(Kind.Data x) { + return null; + } + + public T visitKindFunction(Kind.Function x) { + return null; + } + + public T visitKindModule(Kind.Module x) { + return null; + } + + public T visitKindTag(Kind.Tag x) { + return null; + } + + public T visitKindVariable(Kind.Variable x) { + return null; + } + + public T visitKindView(Kind.View x) { + return null; + } + + public T visitLabelDefault(Label.Default x) { + return null; + } + + public T visitLabelEmpty(Label.Empty x) { + return null; + } + + public T visitLiteralBoolean(Literal.Boolean x) { + return null; + } + + public T visitLiteralDateTime(Literal.DateTime x) { + return null; + } + + public T visitLiteralInteger(Literal.Integer x) { + return null; + } + + public T visitLiteralLocation(Literal.Location x) { + return null; + } + + public T visitLiteralRational(Literal.Rational x) { + return null; + } + + public T visitLiteralReal(Literal.Real x) { + return null; + } + + public T visitLiteralRegExp(Literal.RegExp x) { + return null; + } + + public T visitLiteralString(Literal.String x) { + return null; + } + + public T visitLocalVariableDeclarationDefault(LocalVariableDeclaration.Default x) { + return null; + } + + public T visitLocalVariableDeclarationDynamic(LocalVariableDeclaration.Dynamic x) { + return null; + } + + public T visitLocationLiteralDefault(LocationLiteral.Default x) { + return null; + } + + public T visitMapping_ExpressionDefault(Mapping_Expression.Default x) { + return null; + } + + public T visitModuleDefault(Module.Default x) { + return null; + } + + public T visitModuleActualsDefault(ModuleActuals.Default x) { + return null; + } + + public T visitModuleParametersDefault(ModuleParameters.Default x) { + return null; + } + + public T visitOptionalExpressionExpression(OptionalExpression.Expression x) { + return null; + } + + public T visitOptionalExpressionNoExpression(OptionalExpression.NoExpression x) { + return null; + } + + public T visitParametersDefault(Parameters.Default x) { + return null; + } + + public T visitParametersVarArgs(Parameters.VarArgs x) { + return null; + } + + public T visitPathPartInterpolated(PathPart.Interpolated x) { + return null; + } + + public T visitPathPartNonInterpolated(PathPart.NonInterpolated x) { + return null; + } + + public T visitPathTailMid(PathTail.Mid x) { + return null; + } + + public T visitPathTailPost(PathTail.Post x) { + return null; + } + + public T visitPatternWithActionArbitrary(PatternWithAction.Arbitrary x) { + return null; + } + + public T visitPatternWithActionReplacing(PatternWithAction.Replacing x) { + return null; + } + + public T visitProdAll(Prod.All x) { + return null; + } + + public T visitProdAssociativityGroup(Prod.AssociativityGroup x) { + return null; + } + + public T visitProdFirst(Prod.First x) { + return null; + } + + public T visitProdLabeled(Prod.Labeled x) { + return null; + } + + public T visitProdReference(Prod.Reference x) { + return null; + } + + public T visitProdUnlabeled(Prod.Unlabeled x) { + return null; + } + + public T visitProdModifierAssociativity(ProdModifier.Associativity x) { + return null; + } + + public T visitProdModifierBracket(ProdModifier.Bracket x) { + return null; + } + + public T visitProdModifierTag(ProdModifier.Tag x) { + return null; + } + + public T visitProtocolPartInterpolated(ProtocolPart.Interpolated x) { + return null; + } + + public T visitProtocolPartNonInterpolated(ProtocolPart.NonInterpolated x) { + return null; + } + + public T visitProtocolTailMid(ProtocolTail.Mid x) { + return null; + } + + public T visitProtocolTailPost(ProtocolTail.Post x) { + return null; + } + + public T visitQualifiedNameDefault(QualifiedName.Default x) { + return null; + } + + public T visitRangeCharacter(Range.Character x) { + return null; + } + + public T visitRangeFromTo(Range.FromTo x) { + return null; + } + + public T visitRenamingDefault(Renaming.Default x) { + return null; + } + + public T visitRenamingsDefault(Renamings.Default x) { + return null; + } + + public T visitReplacementConditional(Replacement.Conditional x) { + return null; + } + + public T visitReplacementUnconditional(Replacement.Unconditional x) { + return null; + } + + public T visitShellCommandClear(ShellCommand.Clear x) { + return null; + } + + public T visitShellCommandEdit(ShellCommand.Edit x) { + return null; + } + + public T visitShellCommandHelp(ShellCommand.Help x) { + return null; + } + + public T visitShellCommandHistory(ShellCommand.History x) { + return null; + } + + public T visitShellCommandListDeclarations(ShellCommand.ListDeclarations x) { + return null; + } + + public T visitShellCommandListModules(ShellCommand.ListModules x) { + return null; + } + + public T visitShellCommandQuit(ShellCommand.Quit x) { + return null; + } + + public T visitShellCommandSetOption(ShellCommand.SetOption x) { + return null; + } + + public T visitShellCommandSetOptionTrue(ShellCommand.SetOptionTrue x) { + return null; + } + + public T visitShellCommandTest(ShellCommand.Test x) { + return null; + } + + public T visitShellCommandUndeclare(ShellCommand.Undeclare x) { + return null; + } + + public T visitShellCommandUnextend(ShellCommand.Unextend x) { + return null; + } + + public T visitShellCommandUnimport(ShellCommand.Unimport x) { + return null; + } + + public T visitShellCommandUnsetOption(ShellCommand.UnsetOption x) { + return null; + } + + public T visitSignatureNoThrows(Signature.NoThrows x) { + return null; + } + + public T visitSignatureWithThrows(Signature.WithThrows x) { + return null; + } + + public T visitStartAbsent(Start.Absent x) { + return null; + } + + public T visitStartPresent(Start.Present x) { + return null; + } + + public T visitStatementAppend(Statement.Append x) { + return null; + } + + public T visitStatementAssert(Statement.Assert x) { + return null; + } + + public T visitStatementAssertWithMessage(Statement.AssertWithMessage x) { + return null; + } + + public T visitStatementAssignment(Statement.Assignment x) { + return null; + } + + public T visitStatementBreak(Statement.Break x) { + return null; + } + + public T visitStatementContinue(Statement.Continue x) { + return null; + } + + public T visitStatementDoWhile(Statement.DoWhile x) { + return null; + } + + public T visitStatementEmptyStatement(Statement.EmptyStatement x) { + return null; + } + + public T visitStatementExpression(Statement.Expression x) { + return null; + } + + public T visitStatementFail(Statement.Fail x) { + return null; + } + + public T visitStatementFilter(Statement.Filter x) { + return null; + } + + public T visitStatementFor(Statement.For x) { + return null; + } + + public T visitStatementFunctionDeclaration(Statement.FunctionDeclaration x) { + return null; + } + + public T visitStatementGlobalDirective(Statement.GlobalDirective x) { + return null; + } + + public T visitStatementIfThen(Statement.IfThen x) { + return null; + } + + public T visitStatementIfThenElse(Statement.IfThenElse x) { + return null; + } + + public T visitStatementInsert(Statement.Insert x) { + return null; + } + + public T visitStatementNonEmptyBlock(Statement.NonEmptyBlock x) { + return null; + } + + public T visitStatementReturn(Statement.Return x) { + return null; + } + + public T visitStatementSolve(Statement.Solve x) { + return null; + } + + public T visitStatementSwitch(Statement.Switch x) { + return null; + } + + public T visitStatementThrow(Statement.Throw x) { + return null; + } + + public T visitStatementTry(Statement.Try x) { + return null; + } + + public T visitStatementTryFinally(Statement.TryFinally x) { + return null; + } + + public T visitStatementVariableDeclaration(Statement.VariableDeclaration x) { + return null; + } + + public T visitStatementVisit(Statement.Visit x) { + return null; + } + + public T visitStatementWhile(Statement.While x) { + return null; + } + + public T visitStrategyBottomUp(Strategy.BottomUp x) { + return null; + } + + public T visitStrategyBottomUpBreak(Strategy.BottomUpBreak x) { + return null; + } + + public T visitStrategyInnermost(Strategy.Innermost x) { + return null; + } + + public T visitStrategyOutermost(Strategy.Outermost x) { + return null; + } + + public T visitStrategyTopDown(Strategy.TopDown x) { + return null; + } + + public T visitStrategyTopDownBreak(Strategy.TopDownBreak x) { + return null; + } + + public T visitStringLiteralInterpolated(StringLiteral.Interpolated x) { + return null; + } + + public T visitStringLiteralNonInterpolated(StringLiteral.NonInterpolated x) { + return null; + } + + public T visitStringLiteralTemplate(StringLiteral.Template x) { + return null; + } + + public T visitStringMiddleInterpolated(StringMiddle.Interpolated x) { + return null; + } + + public T visitStringMiddleMid(StringMiddle.Mid x) { + return null; + } + + public T visitStringMiddleTemplate(StringMiddle.Template x) { + return null; + } + + public T visitStringTailMidInterpolated(StringTail.MidInterpolated x) { + return null; + } + + public T visitStringTailMidTemplate(StringTail.MidTemplate x) { + return null; + } + + public T visitStringTailPost(StringTail.Post x) { + return null; + } + + public T visitStringTemplateDoWhile(StringTemplate.DoWhile x) { + return null; + } + + public T visitStringTemplateFor(StringTemplate.For x) { + return null; + } + + public T visitStringTemplateIfThen(StringTemplate.IfThen x) { + return null; + } + + public T visitStringTemplateIfThenElse(StringTemplate.IfThenElse x) { + return null; + } + + public T visitStringTemplateWhile(StringTemplate.While x) { + return null; + } + + public T visitStructuredTypeDefault(StructuredType.Default x) { + return null; + } + + public T visitSymAlternative(Sym.Alternative x) { + return null; + } + + public T visitSymCaseInsensitiveLiteral(Sym.CaseInsensitiveLiteral x) { + return null; + } + + public T visitSymCharacterClass(Sym.CharacterClass x) { + return null; + } + + public T visitSymColumn(Sym.Column x) { + return null; + } + + public T visitSymEmpty(Sym.Empty x) { + return null; + } + + public T visitSymEndOfLine(Sym.EndOfLine x) { + return null; + } + + public T visitSymExcept(Sym.Except x) { + return null; + } + + public T visitSymFollow(Sym.Follow x) { + return null; + } + + public T visitSymIter(Sym.Iter x) { + return null; + } + + public T visitSymIterSep(Sym.IterSep x) { + return null; + } + + public T visitSymIterStar(Sym.IterStar x) { + return null; + } + + public T visitSymIterStarSep(Sym.IterStarSep x) { + return null; + } + + public T visitSymLabeled(Sym.Labeled x) { + return null; + } + + public T visitSymLiteral(Sym.Literal x) { + return null; + } + + public T visitSymNonterminal(Sym.Nonterminal x) { + return null; + } + + public T visitSymNotFollow(Sym.NotFollow x) { + return null; + } + + public T visitSymNotPrecede(Sym.NotPrecede x) { + return null; + } + + public T visitSymOptional(Sym.Optional x) { + return null; + } + + public T visitSymParameter(Sym.Parameter x) { + return null; + } + + public T visitSymParametrized(Sym.Parametrized x) { + return null; + } + + public T visitSymPrecede(Sym.Precede x) { + return null; + } + + public T visitSymSequence(Sym.Sequence x) { + return null; + } + + public T visitSymStart(Sym.Start x) { + return null; + } + + public T visitSymStartOfLine(Sym.StartOfLine x) { + return null; + } + + public T visitSymUnequal(Sym.Unequal x) { + return null; + } + + public T visitSyntaxDefinitionKeyword(SyntaxDefinition.Keyword x) { + return null; + } + + public T visitSyntaxDefinitionLanguage(SyntaxDefinition.Language x) { + return null; + } + + public T visitSyntaxDefinitionLayout(SyntaxDefinition.Layout x) { + return null; + } + + public T visitSyntaxDefinitionLexical(SyntaxDefinition.Lexical x) { + return null; + } + + public T visitTagDefault(Tag.Default x) { + return null; + } + + public T visitTagEmpty(Tag.Empty x) { + return null; + } + + public T visitTagExpression(Tag.Expression x) { + return null; + } + + public T visitTagsDefault(Tags.Default x) { + return null; + } + + public T visitTargetEmpty(Target.Empty x) { + return null; + } + + public T visitTargetLabeled(Target.Labeled x) { + return null; + } + + public T visitToplevelGivenVisibility(Toplevel.GivenVisibility x) { + return null; + } + + public T visitTypeBasic(Type.Basic x) { + return null; + } + + public T visitTypeBracket(Type.Bracket x) { + return null; + } + + public T visitTypeFunction(Type.Function x) { + return null; + } + + public T visitTypeSelector(Type.Selector x) { + return null; + } + + public T visitTypeStructured(Type.Structured x) { + return null; + } + + public T visitTypeSymbol(Type.Symbol x) { + return null; + } + + public T visitTypeUser(Type.User x) { + return null; + } + + public T visitTypeVariable(Type.Variable x) { + return null; + } + + public T visitTypeArgDefault(TypeArg.Default x) { + return null; + } + + public T visitTypeArgNamed(TypeArg.Named x) { + return null; + } + + public T visitTypeVarBounded(TypeVar.Bounded x) { + return null; + } + + public T visitTypeVarFree(TypeVar.Free x) { + return null; + } + + public T visitUserTypeName(UserType.Name x) { + return null; + } + + public T visitUserTypeParametric(UserType.Parametric x) { + return null; + } + + public T visitVariableInitialized(Variable.Initialized x) { + return null; + } + + public T visitVariableUnInitialized(Variable.UnInitialized x) { + return null; + } + + public T visitVariantNAryConstructor(Variant.NAryConstructor x) { + return null; + } + + public T visitVisibilityDefault(Visibility.Default x) { + return null; + } + + public T visitVisibilityPrivate(Visibility.Private x) { + return null; + } + + public T visitVisibilityPublic(Visibility.Public x) { + return null; + } + + public T visitVisitDefaultStrategy(Visit.DefaultStrategy x) { + return null; + } + + public T visitVisitGivenStrategy(Visit.GivenStrategy x) { + return null; + } + + + public T visitBackslashLexical(Backslash.Lexical x) { + return null; + } + + public T visitBooleanLiteralLexical(BooleanLiteral.Lexical x) { + return null; + } + + public T visitCaseInsensitiveStringConstantLexical(CaseInsensitiveStringConstant.Lexical x) { + return null; + } + + public T visitCharLexical(Char.Lexical x) { + return null; + } + + public T visitCommentLexical(Comment.Lexical x) { + return null; + } + + public T visitConcreteLexical(Concrete.Lexical x) { + return null; + } + + public T visitConcretePartLexical(ConcretePart.Lexical x) { + return null; + } + + public T visitDateAndTimeLexical(DateAndTime.Lexical x) { + return null; + } + + public T visitDatePartLexical(DatePart.Lexical x) { + return null; + } + + public T visitDecimalIntegerLiteralLexical(DecimalIntegerLiteral.Lexical x) { + return null; + } + + public T visitHexIntegerLiteralLexical(HexIntegerLiteral.Lexical x) { + return null; + } + + public T visitJustDateLexical(JustDate.Lexical x) { + return null; + } + + public T visitJustTimeLexical(JustTime.Lexical x) { + return null; + } + + public T visitLAYOUTLexical(LAYOUT.Lexical x) { + return null; + } + + public T visitMidPathCharsLexical(MidPathChars.Lexical x) { + return null; + } + + public T visitMidProtocolCharsLexical(MidProtocolChars.Lexical x) { + return null; + } + + public T visitMidStringCharsLexical(MidStringChars.Lexical x) { + return null; + } + + public T visitNameLexical(Name.Lexical x) { + return null; + } + + public T visitNamedBackslashLexical(NamedBackslash.Lexical x) { + return null; + } + + public T visitNamedRegExpLexical(NamedRegExp.Lexical x) { + return null; + } + + public T visitNonterminalLexical(Nonterminal.Lexical x) { + return null; + } + + public T visitNonterminalLabelLexical(NonterminalLabel.Lexical x) { + return null; + } + + public T visitOctalIntegerLiteralLexical(OctalIntegerLiteral.Lexical x) { + return null; + } + + public T visitOptionalCommaLexical(OptionalComma.Lexical x) { + return null; + } + + public T visitOptionalEqualSignLexical(OptionalEqualSign.Lexical x) { + return null; + } + + public T visitOptionalTerminatorLexical(OptionalTerminator.Lexical x) { + return null; + } + + public T visitOutputLexical(Output.Lexical x) { + return null; + } + + public T visitPathCharsLexical(PathChars.Lexical x) { + return null; + } + + public T visitPostPathCharsLexical(PostPathChars.Lexical x) { + return null; + } + + public T visitPostProtocolCharsLexical(PostProtocolChars.Lexical x) { + return null; + } + + public T visitPostStringCharsLexical(PostStringChars.Lexical x) { + return null; + } + + public T visitPrePathCharsLexical(PrePathChars.Lexical x) { + return null; + } + + public T visitPreProtocolCharsLexical(PreProtocolChars.Lexical x) { + return null; + } + + public T visitPreStringCharsLexical(PreStringChars.Lexical x) { + return null; + } + + public T visitProtocolCharsLexical(ProtocolChars.Lexical x) { + return null; + } + + public T visitRationalLiteralLexical(RationalLiteral.Lexical x) { + return null; + } + + public T visitRealLiteralLexical(RealLiteral.Lexical x) { + return null; + } + + public T visitRegExpLexical(RegExp.Lexical x) { + return null; + } + + public T visitRegExpLiteralLexical(RegExpLiteral.Lexical x) { + return null; + } + + public T visitRegExpModifierLexical(RegExpModifier.Lexical x) { + return null; + } + + public T visitStringCharacterLexical(StringCharacter.Lexical x) { + return null; + } + + public T visitStringConstantLexical(StringConstant.Lexical x) { + return null; + } + + public T visitTagStringLexical(TagString.Lexical x) { + return null; + } + + public T visitTimePartNoTZLexical(TimePartNoTZ.Lexical x) { + return null; + } + + public T visitTimeZonePartLexical(TimeZonePart.Lexical x) { + return null; + } + + public T visitURLCharsLexical(URLChars.Lexical x) { + return null; + } + + public T visitUnicodeEscapeLexical(UnicodeEscape.Lexical x) { + return null; + } + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/OctalIntegerLiteral.java b/src/org/rascalmpl/ast/OctalIntegerLiteral.java new file mode 100644 index 00000000000..a7051419a85 --- /dev/null +++ b/src/org/rascalmpl/ast/OctalIntegerLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class OctalIntegerLiteral extends AbstractAST { + public OctalIntegerLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends OctalIntegerLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitOctalIntegerLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/OptionalComma.java b/src/org/rascalmpl/ast/OptionalComma.java new file mode 100644 index 00000000000..46e968d4f88 --- /dev/null +++ b/src/org/rascalmpl/ast/OptionalComma.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class OptionalComma extends AbstractAST { + public OptionalComma(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends OptionalComma { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitOptionalCommaLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/OptionalEqualSign.java b/src/org/rascalmpl/ast/OptionalEqualSign.java new file mode 100644 index 00000000000..b7175286826 --- /dev/null +++ b/src/org/rascalmpl/ast/OptionalEqualSign.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class OptionalEqualSign extends AbstractAST { + public OptionalEqualSign(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends OptionalEqualSign { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitOptionalEqualSignLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/OptionalExpression.java b/src/org/rascalmpl/ast/OptionalExpression.java new file mode 100644 index 00000000000..56334aac335 --- /dev/null +++ b/src/org/rascalmpl/ast/OptionalExpression.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class OptionalExpression extends AbstractAST { + public OptionalExpression(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isExpression() { + return false; + } + + static public class Expression extends OptionalExpression { + // Production: sig("Expression",[arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Expression expression; + + public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitOptionalExpressionExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Expression)) { + return false; + } + Expression tmp = (Expression) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 557 + 601 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + + } + public boolean isNoExpression() { + return false; + } + + static public class NoExpression extends OptionalExpression { + // Production: sig("NoExpression",[],breakable=false) + + + + public NoExpression(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isNoExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitOptionalExpressionNoExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NoExpression)) { + return false; + } + NoExpression tmp = (NoExpression) o; + return true ; + } + + @Override + public int hashCode() { + return 19 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/OptionalTerminator.java b/src/org/rascalmpl/ast/OptionalTerminator.java new file mode 100644 index 00000000000..1090bd1ecd6 --- /dev/null +++ b/src/org/rascalmpl/ast/OptionalTerminator.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class OptionalTerminator extends AbstractAST { + public OptionalTerminator(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends OptionalTerminator { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitOptionalTerminatorLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Output.java b/src/org/rascalmpl/ast/Output.java new file mode 100644 index 00000000000..201c007470c --- /dev/null +++ b/src/org/rascalmpl/ast/Output.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Output extends AbstractAST { + public Output(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends Output { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitOutputLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Parameters.java b/src/org/rascalmpl/ast/Parameters.java new file mode 100644 index 00000000000..6b8eee10372 --- /dev/null +++ b/src/org/rascalmpl/ast/Parameters.java @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Parameters extends AbstractAST { + public Parameters(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasFormals() { + return false; + } + + public org.rascalmpl.ast.Formals getFormals() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasKeywordFormals() { + return false; + } + + public org.rascalmpl.ast.KeywordFormals getKeywordFormals() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Parameters { + // Production: sig("Default",[arg("org.rascalmpl.ast.Formals","formals"),arg("org.rascalmpl.ast.KeywordFormals","keywordFormals")],breakable=false) + + + private final org.rascalmpl.ast.Formals formals; + private final org.rascalmpl.ast.KeywordFormals keywordFormals; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Formals formals, org.rascalmpl.ast.KeywordFormals keywordFormals) { + super(src, node); + + this.formals = formals; + this.keywordFormals = keywordFormals; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitParametersDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = formals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + formals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = keywordFormals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + keywordFormals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.formals.equals(this.formals) && tmp.keywordFormals.equals(this.keywordFormals) ; + } + + @Override + public int hashCode() { + return 829 + 809 * formals.hashCode() + 157 * keywordFormals.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Formals getFormals() { + return this.formals; + } + + @Override + public boolean hasFormals() { + return true; + } + @Override + public org.rascalmpl.ast.KeywordFormals getKeywordFormals() { + return this.keywordFormals; + } + + @Override + public boolean hasKeywordFormals() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(formals), clone(keywordFormals)); + } + + } + public boolean isVarArgs() { + return false; + } + + static public class VarArgs extends Parameters { + // Production: sig("VarArgs",[arg("org.rascalmpl.ast.Formals","formals"),arg("org.rascalmpl.ast.KeywordFormals","keywordFormals")],breakable=false) + + + private final org.rascalmpl.ast.Formals formals; + private final org.rascalmpl.ast.KeywordFormals keywordFormals; + + public VarArgs(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Formals formals, org.rascalmpl.ast.KeywordFormals keywordFormals) { + super(src, node); + + this.formals = formals; + this.keywordFormals = keywordFormals; + } + + @Override + public boolean isVarArgs() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitParametersVarArgs(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = formals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + formals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = keywordFormals.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + keywordFormals.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof VarArgs)) { + return false; + } + VarArgs tmp = (VarArgs) o; + return true && tmp.formals.equals(this.formals) && tmp.keywordFormals.equals(this.keywordFormals) ; + } + + @Override + public int hashCode() { + return 31 + 13 * formals.hashCode() + 857 * keywordFormals.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Formals getFormals() { + return this.formals; + } + + @Override + public boolean hasFormals() { + return true; + } + @Override + public org.rascalmpl.ast.KeywordFormals getKeywordFormals() { + return this.keywordFormals; + } + + @Override + public boolean hasKeywordFormals() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(formals), clone(keywordFormals)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PathChars.java b/src/org/rascalmpl/ast/PathChars.java new file mode 100644 index 00000000000..7326fa172a5 --- /dev/null +++ b/src/org/rascalmpl/ast/PathChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PathChars extends AbstractAST { + public PathChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PathChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPathCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PathPart.java b/src/org/rascalmpl/ast/PathPart.java new file mode 100644 index 00000000000..8e4fb96bcf4 --- /dev/null +++ b/src/org/rascalmpl/ast/PathPart.java @@ -0,0 +1,247 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PathPart extends AbstractAST { + public PathPart(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPathChars() { + return false; + } + + public org.rascalmpl.ast.PathChars getPathChars() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.PathTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPre() { + return false; + } + + public org.rascalmpl.ast.PrePathChars getPre() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isInterpolated() { + return false; + } + + static public class Interpolated extends PathPart { + // Production: sig("Interpolated",[arg("org.rascalmpl.ast.PrePathChars","pre"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.PathTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.PrePathChars pre; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.PathTail tail; + + public Interpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PrePathChars pre, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.PathTail tail) { + super(src, node); + + this.pre = pre; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPathPartInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pre.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pre.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Interpolated)) { + return false; + } + Interpolated tmp = (Interpolated) o; + return true && tmp.pre.equals(this.pre) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 383 + 853 * pre.hashCode() + 743 * expression.hashCode() + 331 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PrePathChars getPre() { + return this.pre; + } + + @Override + public boolean hasPre() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.PathTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pre), clone(expression), clone(tail)); + } + + } + public boolean isNonInterpolated() { + return false; + } + + static public class NonInterpolated extends PathPart { + // Production: sig("NonInterpolated",[arg("org.rascalmpl.ast.PathChars","pathChars")],breakable=false) + + + private final org.rascalmpl.ast.PathChars pathChars; + + public NonInterpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PathChars pathChars) { + super(src, node); + + this.pathChars = pathChars; + } + + @Override + public boolean isNonInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPathPartNonInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pathChars.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pathChars.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonInterpolated)) { + return false; + } + NonInterpolated tmp = (NonInterpolated) o; + return true && tmp.pathChars.equals(this.pathChars) ; + } + + @Override + public int hashCode() { + return 967 + 257 * pathChars.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PathChars getPathChars() { + return this.pathChars; + } + + @Override + public boolean hasPathChars() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pathChars)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PathTail.java b/src/org/rascalmpl/ast/PathTail.java new file mode 100644 index 00000000000..9c16cd565ba --- /dev/null +++ b/src/org/rascalmpl/ast/PathTail.java @@ -0,0 +1,247 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PathTail extends AbstractAST { + public PathTail(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMid() { + return false; + } + + public org.rascalmpl.ast.MidPathChars getMid() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.PathTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPost() { + return false; + } + + public org.rascalmpl.ast.PostPathChars getPost() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isMid() { + return false; + } + + static public class Mid extends PathTail { + // Production: sig("Mid",[arg("org.rascalmpl.ast.MidPathChars","mid"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.PathTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidPathChars mid; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.PathTail tail; + + public Mid(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidPathChars mid, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.PathTail tail) { + super(src, node); + + this.mid = mid; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isMid() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPathTailMid(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Mid)) { + return false; + } + Mid tmp = (Mid) o; + return true && tmp.mid.equals(this.mid) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 2 + 709 * mid.hashCode() + 499 * expression.hashCode() + 991 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidPathChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.PathTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(expression), clone(tail)); + } + + } + public boolean isPost() { + return false; + } + + static public class Post extends PathTail { + // Production: sig("Post",[arg("org.rascalmpl.ast.PostPathChars","post")],breakable=false) + + + private final org.rascalmpl.ast.PostPathChars post; + + public Post(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PostPathChars post) { + super(src, node); + + this.post = post; + } + + @Override + public boolean isPost() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPathTailPost(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = post.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + post.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Post)) { + return false; + } + Post tmp = (Post) o; + return true && tmp.post.equals(this.post) ; + } + + @Override + public int hashCode() { + return 653 + 557 * post.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PostPathChars getPost() { + return this.post; + } + + @Override + public boolean hasPost() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(post)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PatternWithAction.java b/src/org/rascalmpl/ast/PatternWithAction.java new file mode 100644 index 00000000000..3d5d2b4b3de --- /dev/null +++ b/src/org/rascalmpl/ast/PatternWithAction.java @@ -0,0 +1,240 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PatternWithAction extends AbstractAST { + public PatternWithAction(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasPattern() { + return false; + } + + public org.rascalmpl.ast.Expression getPattern() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasReplacement() { + return false; + } + + public org.rascalmpl.ast.Replacement getReplacement() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isArbitrary() { + return false; + } + + static public class Arbitrary extends PatternWithAction { + // Production: sig("Arbitrary",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Statement","statement")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Statement statement; + + public Arbitrary(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.pattern = pattern; + this.statement = statement; + } + + @Override + public boolean isArbitrary() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPatternWithActionArbitrary(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Arbitrary)) { + return false; + } + Arbitrary tmp = (Arbitrary) o; + return true && tmp.pattern.equals(this.pattern) && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 257 + 941 * pattern.hashCode() + 601 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(statement)); + } + + } + public boolean isReplacing() { + return false; + } + + static public class Replacing extends PatternWithAction { + // Production: sig("Replacing",[arg("org.rascalmpl.ast.Expression","pattern"),arg("org.rascalmpl.ast.Replacement","replacement")],breakable=false) + + + private final org.rascalmpl.ast.Expression pattern; + private final org.rascalmpl.ast.Replacement replacement; + + public Replacing(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression pattern, org.rascalmpl.ast.Replacement replacement) { + super(src, node); + + this.pattern = pattern; + this.replacement = replacement; + } + + @Override + public boolean isReplacing() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitPatternWithActionReplacing(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pattern.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pattern.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = replacement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + replacement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Replacing)) { + return false; + } + Replacing tmp = (Replacing) o; + return true && tmp.pattern.equals(this.pattern) && tmp.replacement.equals(this.replacement) ; + } + + @Override + public int hashCode() { + return 239 + 241 * pattern.hashCode() + 673 * replacement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getPattern() { + return this.pattern; + } + + @Override + public boolean hasPattern() { + return true; + } + @Override + public org.rascalmpl.ast.Replacement getReplacement() { + return this.replacement; + } + + @Override + public boolean hasReplacement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pattern), clone(replacement)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PostPathChars.java b/src/org/rascalmpl/ast/PostPathChars.java new file mode 100644 index 00000000000..31f23639b5e --- /dev/null +++ b/src/org/rascalmpl/ast/PostPathChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PostPathChars extends AbstractAST { + public PostPathChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PostPathChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPostPathCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PostProtocolChars.java b/src/org/rascalmpl/ast/PostProtocolChars.java new file mode 100644 index 00000000000..ce3bf9d31e0 --- /dev/null +++ b/src/org/rascalmpl/ast/PostProtocolChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PostProtocolChars extends AbstractAST { + public PostProtocolChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PostProtocolChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPostProtocolCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PostStringChars.java b/src/org/rascalmpl/ast/PostStringChars.java new file mode 100644 index 00000000000..6301a7d4d4d --- /dev/null +++ b/src/org/rascalmpl/ast/PostStringChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PostStringChars extends AbstractAST { + public PostStringChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PostStringChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPostStringCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PrePathChars.java b/src/org/rascalmpl/ast/PrePathChars.java new file mode 100644 index 00000000000..6cf11cc5c64 --- /dev/null +++ b/src/org/rascalmpl/ast/PrePathChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PrePathChars extends AbstractAST { + public PrePathChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PrePathChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPrePathCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PreProtocolChars.java b/src/org/rascalmpl/ast/PreProtocolChars.java new file mode 100644 index 00000000000..f9843b4daf5 --- /dev/null +++ b/src/org/rascalmpl/ast/PreProtocolChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PreProtocolChars extends AbstractAST { + public PreProtocolChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PreProtocolChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPreProtocolCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/PreStringChars.java b/src/org/rascalmpl/ast/PreStringChars.java new file mode 100644 index 00000000000..830c72df34c --- /dev/null +++ b/src/org/rascalmpl/ast/PreStringChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class PreStringChars extends AbstractAST { + public PreStringChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends PreStringChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitPreStringCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Prod.java b/src/org/rascalmpl/ast/Prod.java new file mode 100644 index 00000000000..ee5ca4c90db --- /dev/null +++ b/src/org/rascalmpl/ast/Prod.java @@ -0,0 +1,655 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Prod extends AbstractAST { + public Prod(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasModifiers() { + return false; + } + + public java.util.List getModifiers() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSyms() { + return false; + } + + public java.util.List getSyms() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasAssociativity() { + return false; + } + + public org.rascalmpl.ast.Assoc getAssociativity() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasReferenced() { + return false; + } + + public org.rascalmpl.ast.Name getReferenced() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasGroup() { + return false; + } + + public org.rascalmpl.ast.Prod getGroup() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLhs() { + return false; + } + + public org.rascalmpl.ast.Prod getLhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasRhs() { + return false; + } + + public org.rascalmpl.ast.Prod getRhs() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAll() { + return false; + } + + static public class All extends Prod { + // Production: sig("All",[arg("org.rascalmpl.ast.Prod","lhs"),arg("org.rascalmpl.ast.Prod","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Prod lhs; + private final org.rascalmpl.ast.Prod rhs; + + public All(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Prod lhs, org.rascalmpl.ast.Prod rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isAll() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdAll(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof All)) { + return false; + } + All tmp = (All) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 757 + 449 * lhs.hashCode() + 167 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Prod getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isAssociativityGroup() { + return false; + } + + static public class AssociativityGroup extends Prod { + // Production: sig("AssociativityGroup",[arg("org.rascalmpl.ast.Assoc","associativity"),arg("org.rascalmpl.ast.Prod","group")],breakable=false) + + + private final org.rascalmpl.ast.Assoc associativity; + private final org.rascalmpl.ast.Prod group; + + public AssociativityGroup(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assoc associativity, org.rascalmpl.ast.Prod group) { + super(src, node); + + this.associativity = associativity; + this.group = group; + } + + @Override + public boolean isAssociativityGroup() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdAssociativityGroup(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = associativity.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + associativity.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = group.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + group.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof AssociativityGroup)) { + return false; + } + AssociativityGroup tmp = (AssociativityGroup) o; + return true && tmp.associativity.equals(this.associativity) && tmp.group.equals(this.group) ; + } + + @Override + public int hashCode() { + return 191 + 191 * associativity.hashCode() + 409 * group.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assoc getAssociativity() { + return this.associativity; + } + + @Override + public boolean hasAssociativity() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getGroup() { + return this.group; + } + + @Override + public boolean hasGroup() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(associativity), clone(group)); + } + + } + public boolean isFirst() { + return false; + } + + static public class First extends Prod { + // Production: sig("First",[arg("org.rascalmpl.ast.Prod","lhs"),arg("org.rascalmpl.ast.Prod","rhs")],breakable=false) + + + private final org.rascalmpl.ast.Prod lhs; + private final org.rascalmpl.ast.Prod rhs; + + public First(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Prod lhs, org.rascalmpl.ast.Prod rhs) { + super(src, node); + + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public boolean isFirst() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdFirst(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = lhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + lhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = rhs.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + rhs.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof First)) { + return false; + } + First tmp = (First) o; + return true && tmp.lhs.equals(this.lhs) && tmp.rhs.equals(this.rhs) ; + } + + @Override + public int hashCode() { + return 487 + 29 * lhs.hashCode() + 23 * rhs.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Prod getLhs() { + return this.lhs; + } + + @Override + public boolean hasLhs() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getRhs() { + return this.rhs; + } + + @Override + public boolean hasRhs() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(lhs), clone(rhs)); + } + + } + public boolean isLabeled() { + return false; + } + + static public class Labeled extends Prod { + // Production: sig("Labeled",[arg("java.util.List\","modifiers"),arg("org.rascalmpl.ast.Name","name"),arg("java.util.List\","syms")],breakable=false) + + + private final java.util.List modifiers; + private final org.rascalmpl.ast.Name name; + private final java.util.List syms; + + public Labeled(ISourceLocation src, IConstructor node , java.util.List modifiers, org.rascalmpl.ast.Name name, java.util.List syms) { + super(src, node); + + this.modifiers = modifiers; + this.name = name; + this.syms = syms; + } + + @Override + public boolean isLabeled() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdLabeled(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : modifiers) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : syms) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Labeled)) { + return false; + } + Labeled tmp = (Labeled) o; + return true && tmp.modifiers.equals(this.modifiers) && tmp.name.equals(this.name) && tmp.syms.equals(this.syms) ; + } + + @Override + public int hashCode() { + return 23 + 491 * modifiers.hashCode() + 617 * name.hashCode() + 761 * syms.hashCode() ; + } + + + @Override + public java.util.List getModifiers() { + return this.modifiers; + } + + @Override + public boolean hasModifiers() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getSyms() { + return this.syms; + } + + @Override + public boolean hasSyms() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(modifiers), clone(name), clone(syms)); + } + + } + public boolean isReference() { + return false; + } + + static public class Reference extends Prod { + // Production: sig("Reference",[arg("org.rascalmpl.ast.Name","referenced")],breakable=false) + + + private final org.rascalmpl.ast.Name referenced; + + public Reference(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name referenced) { + super(src, node); + + this.referenced = referenced; + } + + @Override + public boolean isReference() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdReference(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = referenced.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + referenced.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Reference)) { + return false; + } + Reference tmp = (Reference) o; + return true && tmp.referenced.equals(this.referenced) ; + } + + @Override + public int hashCode() { + return 197 + 5 * referenced.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getReferenced() { + return this.referenced; + } + + @Override + public boolean hasReferenced() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(referenced)); + } + + } + public boolean isUnlabeled() { + return false; + } + + static public class Unlabeled extends Prod { + // Production: sig("Unlabeled",[arg("java.util.List\","modifiers"),arg("java.util.List\","syms")],breakable=false) + + + private final java.util.List modifiers; + private final java.util.List syms; + + public Unlabeled(ISourceLocation src, IConstructor node , java.util.List modifiers, java.util.List syms) { + super(src, node); + + this.modifiers = modifiers; + this.syms = syms; + } + + @Override + public boolean isUnlabeled() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdUnlabeled(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : modifiers) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : syms) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Unlabeled)) { + return false; + } + Unlabeled tmp = (Unlabeled) o; + return true && tmp.modifiers.equals(this.modifiers) && tmp.syms.equals(this.syms) ; + } + + @Override + public int hashCode() { + return 19 + 19 * modifiers.hashCode() + 19 * syms.hashCode() ; + } + + + @Override + public java.util.List getModifiers() { + return this.modifiers; + } + + @Override + public boolean hasModifiers() { + return true; + } + @Override + public java.util.List getSyms() { + return this.syms; + } + + @Override + public boolean hasSyms() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(modifiers), clone(syms)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ProdModifier.java b/src/org/rascalmpl/ast/ProdModifier.java new file mode 100644 index 00000000000..26d4fc9d296 --- /dev/null +++ b/src/org/rascalmpl/ast/ProdModifier.java @@ -0,0 +1,250 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ProdModifier extends AbstractAST { + public ProdModifier(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasAssociativity() { + return false; + } + + public org.rascalmpl.ast.Assoc getAssociativity() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTag() { + return false; + } + + public org.rascalmpl.ast.Tag getTag() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAssociativity() { + return false; + } + + static public class Associativity extends ProdModifier { + // Production: sig("Associativity",[arg("org.rascalmpl.ast.Assoc","associativity")],breakable=false) + + + private final org.rascalmpl.ast.Assoc associativity; + + public Associativity(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assoc associativity) { + super(src, node); + + this.associativity = associativity; + } + + @Override + public boolean isAssociativity() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdModifierAssociativity(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = associativity.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + associativity.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Associativity)) { + return false; + } + Associativity tmp = (Associativity) o; + return true && tmp.associativity.equals(this.associativity) ; + } + + @Override + public int hashCode() { + return 157 + 139 * associativity.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assoc getAssociativity() { + return this.associativity; + } + + @Override + public boolean hasAssociativity() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(associativity)); + } + + } + public boolean isBracket() { + return false; + } + + static public class Bracket extends ProdModifier { + // Production: sig("Bracket",[],breakable=false) + + + + public Bracket(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isBracket() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdModifierBracket(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bracket)) { + return false; + } + Bracket tmp = (Bracket) o; + return true ; + } + + @Override + public int hashCode() { + return 193 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTag() { + return false; + } + + static public class Tag extends ProdModifier { + // Production: sig("Tag",[arg("org.rascalmpl.ast.Tag","tag")],breakable=false) + + + private final org.rascalmpl.ast.Tag tag; + + public Tag(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Tag tag) { + super(src, node); + + this.tag = tag; + } + + @Override + public boolean isTag() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProdModifierTag(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = tag.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tag.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Tag)) { + return false; + } + Tag tmp = (Tag) o; + return true && tmp.tag.equals(this.tag) ; + } + + @Override + public int hashCode() { + return 859 + 3 * tag.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Tag getTag() { + return this.tag; + } + + @Override + public boolean hasTag() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tag)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ProtocolChars.java b/src/org/rascalmpl/ast/ProtocolChars.java new file mode 100644 index 00000000000..07f05a1da01 --- /dev/null +++ b/src/org/rascalmpl/ast/ProtocolChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ProtocolChars extends AbstractAST { + public ProtocolChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends ProtocolChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitProtocolCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ProtocolPart.java b/src/org/rascalmpl/ast/ProtocolPart.java new file mode 100644 index 00000000000..da59e66c377 --- /dev/null +++ b/src/org/rascalmpl/ast/ProtocolPart.java @@ -0,0 +1,247 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ProtocolPart extends AbstractAST { + public ProtocolPart(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPre() { + return false; + } + + public org.rascalmpl.ast.PreProtocolChars getPre() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasProtocolChars() { + return false; + } + + public org.rascalmpl.ast.ProtocolChars getProtocolChars() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.ProtocolTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isInterpolated() { + return false; + } + + static public class Interpolated extends ProtocolPart { + // Production: sig("Interpolated",[arg("org.rascalmpl.ast.PreProtocolChars","pre"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.ProtocolTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.PreProtocolChars pre; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.ProtocolTail tail; + + public Interpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PreProtocolChars pre, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.ProtocolTail tail) { + super(src, node); + + this.pre = pre; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProtocolPartInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pre.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pre.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Interpolated)) { + return false; + } + Interpolated tmp = (Interpolated) o; + return true && tmp.pre.equals(this.pre) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 701 + 283 * pre.hashCode() + 349 * expression.hashCode() + 139 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PreProtocolChars getPre() { + return this.pre; + } + + @Override + public boolean hasPre() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.ProtocolTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pre), clone(expression), clone(tail)); + } + + } + public boolean isNonInterpolated() { + return false; + } + + static public class NonInterpolated extends ProtocolPart { + // Production: sig("NonInterpolated",[arg("org.rascalmpl.ast.ProtocolChars","protocolChars")],breakable=false) + + + private final org.rascalmpl.ast.ProtocolChars protocolChars; + + public NonInterpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ProtocolChars protocolChars) { + super(src, node); + + this.protocolChars = protocolChars; + } + + @Override + public boolean isNonInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProtocolPartNonInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = protocolChars.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + protocolChars.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonInterpolated)) { + return false; + } + NonInterpolated tmp = (NonInterpolated) o; + return true && tmp.protocolChars.equals(this.protocolChars) ; + } + + @Override + public int hashCode() { + return 73 + 439 * protocolChars.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.ProtocolChars getProtocolChars() { + return this.protocolChars; + } + + @Override + public boolean hasProtocolChars() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(protocolChars)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ProtocolTail.java b/src/org/rascalmpl/ast/ProtocolTail.java new file mode 100644 index 00000000000..bd141b43e5a --- /dev/null +++ b/src/org/rascalmpl/ast/ProtocolTail.java @@ -0,0 +1,247 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ProtocolTail extends AbstractAST { + public ProtocolTail(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMid() { + return false; + } + + public org.rascalmpl.ast.MidProtocolChars getMid() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPost() { + return false; + } + + public org.rascalmpl.ast.PostProtocolChars getPost() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.ProtocolTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isMid() { + return false; + } + + static public class Mid extends ProtocolTail { + // Production: sig("Mid",[arg("org.rascalmpl.ast.MidProtocolChars","mid"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.ProtocolTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidProtocolChars mid; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.ProtocolTail tail; + + public Mid(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidProtocolChars mid, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.ProtocolTail tail) { + super(src, node); + + this.mid = mid; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isMid() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProtocolTailMid(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Mid)) { + return false; + } + Mid tmp = (Mid) o; + return true && tmp.mid.equals(this.mid) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 191 + 89 * mid.hashCode() + 787 * expression.hashCode() + 73 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidProtocolChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.ProtocolTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(expression), clone(tail)); + } + + } + public boolean isPost() { + return false; + } + + static public class Post extends ProtocolTail { + // Production: sig("Post",[arg("org.rascalmpl.ast.PostProtocolChars","post")],breakable=false) + + + private final org.rascalmpl.ast.PostProtocolChars post; + + public Post(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PostProtocolChars post) { + super(src, node); + + this.post = post; + } + + @Override + public boolean isPost() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitProtocolTailPost(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = post.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + post.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Post)) { + return false; + } + Post tmp = (Post) o; + return true && tmp.post.equals(this.post) ; + } + + @Override + public int hashCode() { + return 673 + 233 * post.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PostProtocolChars getPost() { + return this.post; + } + + @Override + public boolean hasPost() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(post)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/QualifiedName.java b/src/org/rascalmpl/ast/QualifiedName.java new file mode 100644 index 00000000000..f35e0825f1d --- /dev/null +++ b/src/org/rascalmpl/ast/QualifiedName.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class QualifiedName extends AbstractAST { + public QualifiedName(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasNames() { + return false; + } + + public java.util.List getNames() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends QualifiedName { + // Production: sig("Default",[arg("java.util.List\","names")],breakable=false) + + + private final java.util.List names; + + public Default(ISourceLocation src, IConstructor node , java.util.List names) { + super(src, node); + + this.names = names; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitQualifiedNameDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : names) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.names.equals(this.names) ; + } + + @Override + public int hashCode() { + return 331 + 223 * names.hashCode() ; + } + + + @Override + public java.util.List getNames() { + return this.names; + } + + @Override + public boolean hasNames() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(names)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Range.java b/src/org/rascalmpl/ast/Range.java new file mode 100644 index 00000000000..b84e406aa8c --- /dev/null +++ b/src/org/rascalmpl/ast/Range.java @@ -0,0 +1,221 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Range extends AbstractAST { + public Range(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasCharacter() { + return false; + } + + public org.rascalmpl.ast.Char getCharacter() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasEnd() { + return false; + } + + public org.rascalmpl.ast.Char getEnd() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStart() { + return false; + } + + public org.rascalmpl.ast.Char getStart() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isCharacter() { + return false; + } + + static public class Character extends Range { + // Production: sig("Character",[arg("org.rascalmpl.ast.Char","character")],breakable=false) + + + private final org.rascalmpl.ast.Char character; + + public Character(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Char character) { + super(src, node); + + this.character = character; + } + + @Override + public boolean isCharacter() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitRangeCharacter(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = character.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + character.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Character)) { + return false; + } + Character tmp = (Character) o; + return true && tmp.character.equals(this.character) ; + } + + @Override + public int hashCode() { + return 499 + 919 * character.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Char getCharacter() { + return this.character; + } + + @Override + public boolean hasCharacter() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(character)); + } + + } + public boolean isFromTo() { + return false; + } + + static public class FromTo extends Range { + // Production: sig("FromTo",[arg("org.rascalmpl.ast.Char","start"),arg("org.rascalmpl.ast.Char","end")],breakable=false) + + + private final org.rascalmpl.ast.Char start; + private final org.rascalmpl.ast.Char end; + + public FromTo(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Char start, org.rascalmpl.ast.Char end) { + super(src, node); + + this.start = start; + this.end = end; + } + + @Override + public boolean isFromTo() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitRangeFromTo(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = start.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + start.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = end.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + end.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FromTo)) { + return false; + } + FromTo tmp = (FromTo) o; + return true && tmp.start.equals(this.start) && tmp.end.equals(this.end) ; + } + + @Override + public int hashCode() { + return 233 + 709 * start.hashCode() + 503 * end.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Char getStart() { + return this.start; + } + + @Override + public boolean hasStart() { + return true; + } + @Override + public org.rascalmpl.ast.Char getEnd() { + return this.end; + } + + @Override + public boolean hasEnd() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(start), clone(end)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/RationalLiteral.java b/src/org/rascalmpl/ast/RationalLiteral.java new file mode 100644 index 00000000000..3a61a3f5f33 --- /dev/null +++ b/src/org/rascalmpl/ast/RationalLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class RationalLiteral extends AbstractAST { + public RationalLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends RationalLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitRationalLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/RealLiteral.java b/src/org/rascalmpl/ast/RealLiteral.java new file mode 100644 index 00000000000..45c66e80dfe --- /dev/null +++ b/src/org/rascalmpl/ast/RealLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class RealLiteral extends AbstractAST { + public RealLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends RealLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitRealLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/RegExp.java b/src/org/rascalmpl/ast/RegExp.java new file mode 100644 index 00000000000..eedd0e4f523 --- /dev/null +++ b/src/org/rascalmpl/ast/RegExp.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class RegExp extends AbstractAST { + public RegExp(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends RegExp { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitRegExpLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/RegExpLiteral.java b/src/org/rascalmpl/ast/RegExpLiteral.java new file mode 100644 index 00000000000..ba16b72ae1c --- /dev/null +++ b/src/org/rascalmpl/ast/RegExpLiteral.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class RegExpLiteral extends AbstractAST { + public RegExpLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends RegExpLiteral { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitRegExpLiteralLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/RegExpModifier.java b/src/org/rascalmpl/ast/RegExpModifier.java new file mode 100644 index 00000000000..99d86aa434e --- /dev/null +++ b/src/org/rascalmpl/ast/RegExpModifier.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class RegExpModifier extends AbstractAST { + public RegExpModifier(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends RegExpModifier { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitRegExpModifierLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Renaming.java b/src/org/rascalmpl/ast/Renaming.java new file mode 100644 index 00000000000..a2e6bbe8927 --- /dev/null +++ b/src/org/rascalmpl/ast/Renaming.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Renaming extends AbstractAST { + public Renaming(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasFrom() { + return false; + } + + public org.rascalmpl.ast.Name getFrom() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTo() { + return false; + } + + public org.rascalmpl.ast.Name getTo() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Renaming { + // Production: sig("Default",[arg("org.rascalmpl.ast.Name","from"),arg("org.rascalmpl.ast.Name","to")],breakable=false) + + + private final org.rascalmpl.ast.Name from; + private final org.rascalmpl.ast.Name to; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name from, org.rascalmpl.ast.Name to) { + super(src, node); + + this.from = from; + this.to = to; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitRenamingDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = from.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + from.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = to.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + to.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.from.equals(this.from) && tmp.to.equals(this.to) ; + } + + @Override + public int hashCode() { + return 233 + 419 * from.hashCode() + 599 * to.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getFrom() { + return this.from; + } + + @Override + public boolean hasFrom() { + return true; + } + @Override + public org.rascalmpl.ast.Name getTo() { + return this.to; + } + + @Override + public boolean hasTo() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(from), clone(to)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Renamings.java b/src/org/rascalmpl/ast/Renamings.java new file mode 100644 index 00000000000..52b87f250d1 --- /dev/null +++ b/src/org/rascalmpl/ast/Renamings.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Renamings extends AbstractAST { + public Renamings(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasRenamings() { + return false; + } + + public java.util.List getRenamings() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Renamings { + // Production: sig("Default",[arg("java.util.List\","renamings")],breakable=false) + + + private final java.util.List renamings; + + public Default(ISourceLocation src, IConstructor node , java.util.List renamings) { + super(src, node); + + this.renamings = renamings; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitRenamingsDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : renamings) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.renamings.equals(this.renamings) ; + } + + @Override + public int hashCode() { + return 881 + 739 * renamings.hashCode() ; + } + + + @Override + public java.util.List getRenamings() { + return this.renamings; + } + + @Override + public boolean hasRenamings() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(renamings)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Replacement.java b/src/org/rascalmpl/ast/Replacement.java new file mode 100644 index 00000000000..8c459d57785 --- /dev/null +++ b/src/org/rascalmpl/ast/Replacement.java @@ -0,0 +1,216 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Replacement extends AbstractAST { + public Replacement(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasConditions() { + return false; + } + + public java.util.List getConditions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasReplacementExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getReplacementExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isConditional() { + return false; + } + + static public class Conditional extends Replacement { + // Production: sig("Conditional",[arg("org.rascalmpl.ast.Expression","replacementExpression"),arg("java.util.List\","conditions")],breakable=false) + + + private final org.rascalmpl.ast.Expression replacementExpression; + private final java.util.List conditions; + + public Conditional(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression replacementExpression, java.util.List conditions) { + super(src, node); + + this.replacementExpression = replacementExpression; + this.conditions = conditions; + } + + @Override + public boolean isConditional() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitReplacementConditional(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = replacementExpression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + replacementExpression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Conditional)) { + return false; + } + Conditional tmp = (Conditional) o; + return true && tmp.replacementExpression.equals(this.replacementExpression) && tmp.conditions.equals(this.conditions) ; + } + + @Override + public int hashCode() { + return 881 + 3 * replacementExpression.hashCode() + 293 * conditions.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getReplacementExpression() { + return this.replacementExpression; + } + + @Override + public boolean hasReplacementExpression() { + return true; + } + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(replacementExpression), clone(conditions)); + } + + } + public boolean isUnconditional() { + return false; + } + + static public class Unconditional extends Replacement { + // Production: sig("Unconditional",[arg("org.rascalmpl.ast.Expression","replacementExpression")],breakable=false) + + + private final org.rascalmpl.ast.Expression replacementExpression; + + public Unconditional(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression replacementExpression) { + super(src, node); + + this.replacementExpression = replacementExpression; + } + + @Override + public boolean isUnconditional() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitReplacementUnconditional(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = replacementExpression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + replacementExpression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Unconditional)) { + return false; + } + Unconditional tmp = (Unconditional) o; + return true && tmp.replacementExpression.equals(this.replacementExpression) ; + } + + @Override + public int hashCode() { + return 281 + 433 * replacementExpression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getReplacementExpression() { + return this.replacementExpression; + } + + @Override + public boolean hasReplacementExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(replacementExpression)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/ShellCommand.java b/src/org/rascalmpl/ast/ShellCommand.java new file mode 100644 index 00000000000..4b54d0135d3 --- /dev/null +++ b/src/org/rascalmpl/ast/ShellCommand.java @@ -0,0 +1,1294 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class ShellCommand extends AbstractAST { + public ShellCommand(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasOptName() { + return false; + } + + public org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.MonotonicNonNull QualifiedName getOptName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSign() { + return false; + } + + public org.rascalmpl.ast.OptionalEqualSign getSign() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTerminator() { + return false; + } + + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isClear() { + return false; + } + + static public class Clear extends ShellCommand { + // Production: sig("Clear",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Clear(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isClear() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandClear(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Clear)) { + return false; + } + Clear tmp = (Clear) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 283 + 727 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isEdit() { + return false; + } + + static public class Edit extends ShellCommand { + // Production: sig("Edit",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Edit(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.terminator = terminator; + } + + @Override + public boolean isEdit() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandEdit(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Edit)) { + return false; + } + Edit tmp = (Edit) o; + return true && tmp.name.equals(this.name) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 449 + 983 * name.hashCode() + 523 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(terminator)); + } + + } + public boolean isHelp() { + return false; + } + + static public class Help extends ShellCommand { + // Production: sig("Help",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Help(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isHelp() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandHelp(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Help)) { + return false; + } + Help tmp = (Help) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 271 + 907 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isHistory() { + return false; + } + + static public class History extends ShellCommand { + // Production: sig("History",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public History(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isHistory() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandHistory(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof History)) { + return false; + } + History tmp = (History) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 479 + 383 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isListDeclarations() { + return false; + } + + static public class ListDeclarations extends ShellCommand { + // Production: sig("ListDeclarations",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public ListDeclarations(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isListDeclarations() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandListDeclarations(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ListDeclarations)) { + return false; + } + ListDeclarations tmp = (ListDeclarations) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 397 + 929 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isListModules() { + return false; + } + + static public class ListModules extends ShellCommand { + // Production: sig("ListModules",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public ListModules(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isListModules() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandListModules(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ListModules)) { + return false; + } + ListModules tmp = (ListModules) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 997 + 857 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isQuit() { + return false; + } + + static public class Quit extends ShellCommand { + // Production: sig("Quit",[arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Quit(ISourceLocation src, IConstructor node , org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.terminator = terminator; + } + + @Override + public boolean isQuit() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandQuit(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Quit)) { + return false; + } + Quit tmp = (Quit) o; + return true && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 127 + 607 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(terminator)); + } + + } + public boolean isSetOption() { + return false; + } + + static public class SetOption extends ShellCommand { + // Production: sig("SetOption",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalEqualSign","sign"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalEqualSign sign; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public SetOption(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalEqualSign sign, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.sign = sign; + this.expression = expression; + this.terminator = terminator; + } + + @Override + public boolean isSetOption() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandSetOption(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = sign.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + sign.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SetOption)) { + return false; + } + SetOption tmp = (SetOption) o; + return true && tmp.name.equals(this.name) && tmp.sign.equals(this.sign) && tmp.expression.equals(this.expression) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 631 + 449 * name.hashCode() + 113 * sign.hashCode() + 659 * expression.hashCode() + 113 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalEqualSign getSign() { + return this.sign; + } + + @Override + public boolean hasSign() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(sign), clone(expression), clone(terminator)); + } + + } + public boolean isSetOptionTrue() { + return false; + } + + static public class SetOptionTrue extends ShellCommand { + // Production: sig("SetOptionTrue",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public SetOptionTrue(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.terminator = terminator; + } + + @Override + public boolean isSetOptionTrue() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandSetOptionTrue(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SetOptionTrue)) { + return false; + } + SetOptionTrue tmp = (SetOptionTrue) o; + return true && tmp.name.equals(this.name) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 163 + 491 * name.hashCode() + 887 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(terminator)); + } + + } + public boolean isTest() { + return false; + } + + static public class Test extends ShellCommand { + // Production: sig("Test",[arg("org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName","optName",isOptional=true),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName optName; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Test(ISourceLocation src, IConstructor node , org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName optName, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.optName = optName; + this.terminator = terminator; + } + + @Override + public boolean isTest() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandTest(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = (optName == null) ? null : optName.getLocation(); + if ($l != null && $l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optName.addForLineNumber($line, $result); + } + if ($l != null && $l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Test)) { + return false; + } + Test tmp = (Test) o; + return true && java.util.Objects.equals(tmp.optName, this.optName) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 547 + 293 * java.util.Objects.hashCode(optName) + 997 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.MonotonicNonNull QualifiedName getOptName() { + return this.optName; + } + + @Override @org.checkerframework.checker.nullness.qual.EnsuresNonNullIf(expression="getOptName()", result=true) + public boolean hasOptName() { + return this.optName != null; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(optName), clone(terminator)); + } + + } + public boolean isUndeclare() { + return false; + } + + static public class Undeclare extends ShellCommand { + // Production: sig("Undeclare",[arg("org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName","optName",isOptional=true),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName optName; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Undeclare(ISourceLocation src, IConstructor node , org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.Nullable QualifiedName optName, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.optName = optName; + this.terminator = terminator; + } + + @Override + public boolean isUndeclare() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandUndeclare(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = (optName == null) ? null : optName.getLocation(); + if ($l != null && $l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + optName.addForLineNumber($line, $result); + } + if ($l != null && $l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Undeclare)) { + return false; + } + Undeclare tmp = (Undeclare) o; + return true && java.util.Objects.equals(tmp.optName, this.optName) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 881 + 313 * java.util.Objects.hashCode(optName) + 127 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.@org.checkerframework.checker.nullness.qual.MonotonicNonNull QualifiedName getOptName() { + return this.optName; + } + + @Override @org.checkerframework.checker.nullness.qual.EnsuresNonNullIf(expression="getOptName()", result=true) + public boolean hasOptName() { + return this.optName != null; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(optName), clone(terminator)); + } + + } + public boolean isUnextend() { + return false; + } + + static public class Unextend extends ShellCommand { + // Production: sig("Unextend",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Unextend(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.terminator = terminator; + } + + @Override + public boolean isUnextend() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandUnextend(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Unextend)) { + return false; + } + Unextend tmp = (Unextend) o; + return true && tmp.name.equals(this.name) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 823 + 757 * name.hashCode() + 89 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(terminator)); + } + + } + public boolean isUnimport() { + return false; + } + + static public class Unimport extends ShellCommand { + // Production: sig("Unimport",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public Unimport(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.terminator = terminator; + } + + @Override + public boolean isUnimport() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandUnimport(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Unimport)) { + return false; + } + Unimport tmp = (Unimport) o; + return true && tmp.name.equals(this.name) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 619 + 401 * name.hashCode() + 463 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(terminator)); + } + + } + public boolean isUnsetOption() { + return false; + } + + static public class UnsetOption extends ShellCommand { + // Production: sig("UnsetOption",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("org.rascalmpl.ast.OptionalTerminator","terminator")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final org.rascalmpl.ast.OptionalTerminator terminator; + + public UnsetOption(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, org.rascalmpl.ast.OptionalTerminator terminator) { + super(src, node); + + this.name = name; + this.terminator = terminator; + } + + @Override + public boolean isUnsetOption() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitShellCommandUnsetOption(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = terminator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + terminator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof UnsetOption)) { + return false; + } + UnsetOption tmp = (UnsetOption) o; + return true && tmp.name.equals(this.name) && tmp.terminator.equals(this.terminator) ; + } + + @Override + public int hashCode() { + return 317 + 857 * name.hashCode() + 353 * terminator.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.OptionalTerminator getTerminator() { + return this.terminator; + } + + @Override + public boolean hasTerminator() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(terminator)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Signature.java b/src/org/rascalmpl/ast/Signature.java new file mode 100644 index 00000000000..b1b05dc0b70 --- /dev/null +++ b/src/org/rascalmpl/ast/Signature.java @@ -0,0 +1,351 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Signature extends AbstractAST { + public Signature(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExceptions() { + return false; + } + + public java.util.List getExceptions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasModifiers() { + return false; + } + + public org.rascalmpl.ast.FunctionModifiers getModifiers() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasParameters() { + return false; + } + + public org.rascalmpl.ast.Parameters getParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isNoThrows() { + return false; + } + + static public class NoThrows extends Signature { + // Production: sig("NoThrows",[arg("org.rascalmpl.ast.FunctionModifiers","modifiers"),arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Parameters","parameters")],breakable=false) + + + private final org.rascalmpl.ast.FunctionModifiers modifiers; + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Parameters parameters; + + public NoThrows(ISourceLocation src, IConstructor node , org.rascalmpl.ast.FunctionModifiers modifiers, org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name, org.rascalmpl.ast.Parameters parameters) { + super(src, node); + + this.modifiers = modifiers; + this.type = type; + this.name = name; + this.parameters = parameters; + } + + @Override + public boolean isNoThrows() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSignatureNoThrows(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = modifiers.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + modifiers.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = parameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + parameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NoThrows)) { + return false; + } + NoThrows tmp = (NoThrows) o; + return true && tmp.modifiers.equals(this.modifiers) && tmp.type.equals(this.type) && tmp.name.equals(this.name) && tmp.parameters.equals(this.parameters) ; + } + + @Override + public int hashCode() { + return 53 + 149 * modifiers.hashCode() + 127 * type.hashCode() + 827 * name.hashCode() + 431 * parameters.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.FunctionModifiers getModifiers() { + return this.modifiers; + } + + @Override + public boolean hasModifiers() { + return true; + } + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Parameters getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(modifiers), clone(type), clone(name), clone(parameters)); + } + + } + public boolean isWithThrows() { + return false; + } + + static public class WithThrows extends Signature { + // Production: sig("WithThrows",[arg("org.rascalmpl.ast.FunctionModifiers","modifiers"),arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Parameters","parameters"),arg("java.util.List\","exceptions")],breakable=false) + + + private final org.rascalmpl.ast.FunctionModifiers modifiers; + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Parameters parameters; + private final java.util.List exceptions; + + public WithThrows(ISourceLocation src, IConstructor node , org.rascalmpl.ast.FunctionModifiers modifiers, org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name, org.rascalmpl.ast.Parameters parameters, java.util.List exceptions) { + super(src, node); + + this.modifiers = modifiers; + this.type = type; + this.name = name; + this.parameters = parameters; + this.exceptions = exceptions; + } + + @Override + public boolean isWithThrows() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSignatureWithThrows(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = modifiers.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + modifiers.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = parameters.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + parameters.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : exceptions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof WithThrows)) { + return false; + } + WithThrows tmp = (WithThrows) o; + return true && tmp.modifiers.equals(this.modifiers) && tmp.type.equals(this.type) && tmp.name.equals(this.name) && tmp.parameters.equals(this.parameters) && tmp.exceptions.equals(this.exceptions) ; + } + + @Override + public int hashCode() { + return 131 + 827 * modifiers.hashCode() + 2 * type.hashCode() + 449 * name.hashCode() + 89 * parameters.hashCode() + 233 * exceptions.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.FunctionModifiers getModifiers() { + return this.modifiers; + } + + @Override + public boolean hasModifiers() { + return true; + } + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Parameters getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + @Override + public java.util.List getExceptions() { + return this.exceptions; + } + + @Override + public boolean hasExceptions() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(modifiers), clone(type), clone(name), clone(parameters), clone(exceptions)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Start.java b/src/org/rascalmpl/ast/Start.java new file mode 100644 index 00000000000..936b0286f55 --- /dev/null +++ b/src/org/rascalmpl/ast/Start.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Start extends AbstractAST { + public Start(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isAbsent() { + return false; + } + + static public class Absent extends Start { + // Production: sig("Absent",[],breakable=false) + + + + public Absent(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isAbsent() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStartAbsent(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Absent)) { + return false; + } + Absent tmp = (Absent) o; + return true ; + } + + @Override + public int hashCode() { + return 617 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isPresent() { + return false; + } + + static public class Present extends Start { + // Production: sig("Present",[],breakable=false) + + + + public Present(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isPresent() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStartPresent(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Present)) { + return false; + } + Present tmp = (Present) o; + return true ; + } + + @Override + public int hashCode() { + return 151 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Statement.java b/src/org/rascalmpl/ast/Statement.java new file mode 100644 index 00000000000..d1237779c18 --- /dev/null +++ b/src/org/rascalmpl/ast/Statement.java @@ -0,0 +1,2757 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Statement extends AbstractAST { + public Statement(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasCases() { + return false; + } + + public java.util.List getCases() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasHandlers() { + return false; + } + + public java.util.List getHandlers() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasConditions() { + return false; + } + + public java.util.List getConditions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasGenerators() { + return false; + } + + public java.util.List getGenerators() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasNames() { + return false; + } + + public java.util.List getNames() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVariables() { + return false; + } + + public java.util.List getVariables() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatements() { + return false; + } + + public java.util.List getStatements() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasAssignable() { + return false; + } + + public org.rascalmpl.ast.Assignable getAssignable() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasOperator() { + return false; + } + + public org.rascalmpl.ast.Assignment getOperator() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBound() { + return false; + } + + public org.rascalmpl.ast.Bound getBound() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDataTarget() { + return false; + } + + public org.rascalmpl.ast.DataTarget getDataTarget() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCondition() { + return false; + } + + public org.rascalmpl.ast.Expression getCondition() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMessage() { + return false; + } + + public org.rascalmpl.ast.Expression getMessage() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFunctionDeclaration() { + return false; + } + + public org.rascalmpl.ast.FunctionDeclaration getFunctionDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLabel() { + return false; + } + + public org.rascalmpl.ast.Label getLabel() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDeclaration() { + return false; + } + + public org.rascalmpl.ast.LocalVariableDeclaration getDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBody() { + return false; + } + + public org.rascalmpl.ast.Statement getBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElseStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getElseStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFinallyBody() { + return false; + } + + public org.rascalmpl.ast.Statement getFinallyBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasThenStatement() { + return false; + } + + public org.rascalmpl.ast.Statement getThenStatement() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTarget() { + return false; + } + + public org.rascalmpl.ast.Target getTarget() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVisit() { + return false; + } + + public org.rascalmpl.ast.Visit getVisit() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAppend() { + return false; + } + + static public class Append extends Statement { + // Production: sig("Append",[arg("org.rascalmpl.ast.DataTarget","dataTarget"),arg("org.rascalmpl.ast.Statement","statement")],breakable=true) + + + private final org.rascalmpl.ast.DataTarget dataTarget; + private final org.rascalmpl.ast.Statement statement; + + public Append(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DataTarget dataTarget, org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.dataTarget = dataTarget; + this.statement = statement; + } + + @Override + public boolean isAppend() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementAppend(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = dataTarget.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + dataTarget.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Append)) { + return false; + } + Append tmp = (Append) o; + return true && tmp.dataTarget.equals(this.dataTarget) && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 19 + 787 * dataTarget.hashCode() + 457 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DataTarget getDataTarget() { + return this.dataTarget; + } + + @Override + public boolean hasDataTarget() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(dataTarget), clone(statement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isAssert() { + return false; + } + + static public class Assert extends Statement { + // Production: sig("Assert",[arg("org.rascalmpl.ast.Expression","expression")],breakable=true) + + + private final org.rascalmpl.ast.Expression expression; + + public Assert(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isAssert() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementAssert(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Assert)) { + return false; + } + Assert tmp = (Assert) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 283 + 739 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isAssertWithMessage() { + return false; + } + + static public class AssertWithMessage extends Statement { + // Production: sig("AssertWithMessage",[arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.Expression","message")],breakable=true) + + + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.Expression message; + + public AssertWithMessage(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.Expression message) { + super(src, node); + + this.expression = expression; + this.message = message; + } + + @Override + public boolean isAssertWithMessage() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementAssertWithMessage(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = message.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + message.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof AssertWithMessage)) { + return false; + } + AssertWithMessage tmp = (AssertWithMessage) o; + return true && tmp.expression.equals(this.expression) && tmp.message.equals(this.message) ; + } + + @Override + public int hashCode() { + return 547 + 97 * expression.hashCode() + 607 * message.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getMessage() { + return this.message; + } + + @Override + public boolean hasMessage() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression), clone(message)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isAssignment() { + return false; + } + + static public class Assignment extends Statement { + // Production: sig("Assignment",[arg("org.rascalmpl.ast.Assignable","assignable"),arg("org.rascalmpl.ast.Assignment","operator"),arg("org.rascalmpl.ast.Statement","statement")],breakable=true) + + + private final org.rascalmpl.ast.Assignable assignable; + private final org.rascalmpl.ast.Assignment operator; + private final org.rascalmpl.ast.Statement statement; + + public Assignment(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Assignable assignable, org.rascalmpl.ast.Assignment operator, org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.assignable = assignable; + this.operator = operator; + this.statement = statement; + } + + @Override + public boolean isAssignment() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementAssignment(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = assignable.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + assignable.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = operator.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + operator.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Assignment)) { + return false; + } + Assignment tmp = (Assignment) o; + return true && tmp.assignable.equals(this.assignable) && tmp.operator.equals(this.operator) && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 73 + 677 * assignable.hashCode() + 89 * operator.hashCode() + 599 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Assignable getAssignable() { + return this.assignable; + } + + @Override + public boolean hasAssignable() { + return true; + } + @Override + public org.rascalmpl.ast.Assignment getOperator() { + return this.operator; + } + + @Override + public boolean hasOperator() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(assignable), clone(operator), clone(statement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isBreak() { + return false; + } + + static public class Break extends Statement { + // Production: sig("Break",[arg("org.rascalmpl.ast.Target","target")],breakable=true) + + + private final org.rascalmpl.ast.Target target; + + public Break(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Target target) { + super(src, node); + + this.target = target; + } + + @Override + public boolean isBreak() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementBreak(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = target.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + target.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Break)) { + return false; + } + Break tmp = (Break) o; + return true && tmp.target.equals(this.target) ; + } + + @Override + public int hashCode() { + return 3 + 757 * target.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Target getTarget() { + return this.target; + } + + @Override + public boolean hasTarget() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(target)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isContinue() { + return false; + } + + static public class Continue extends Statement { + // Production: sig("Continue",[arg("org.rascalmpl.ast.Target","target")],breakable=true) + + + private final org.rascalmpl.ast.Target target; + + public Continue(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Target target) { + super(src, node); + + this.target = target; + } + + @Override + public boolean isContinue() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementContinue(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = target.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + target.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Continue)) { + return false; + } + Continue tmp = (Continue) o; + return true && tmp.target.equals(this.target) ; + } + + @Override + public int hashCode() { + return 193 + 881 * target.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Target getTarget() { + return this.target; + } + + @Override + public boolean hasTarget() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(target)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isDoWhile() { + return false; + } + + static public class DoWhile extends Statement { + // Production: sig("DoWhile",[arg("org.rascalmpl.ast.Label","label"),arg("org.rascalmpl.ast.Statement","body"),arg("org.rascalmpl.ast.Expression","condition")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final org.rascalmpl.ast.Statement body; + private final org.rascalmpl.ast.Expression condition; + + public DoWhile(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, org.rascalmpl.ast.Statement body, org.rascalmpl.ast.Expression condition) { + super(src, node); + + this.label = label; + this.body = body; + this.condition = condition; + } + + @Override + public boolean isDoWhile() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementDoWhile(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = condition.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + condition.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DoWhile)) { + return false; + } + DoWhile tmp = (DoWhile) o; + return true && tmp.label.equals(this.label) && tmp.body.equals(this.body) && tmp.condition.equals(this.condition) ; + } + + @Override + public int hashCode() { + return 823 + 859 * label.hashCode() + 181 * body.hashCode() + 677 * condition.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getCondition() { + return this.condition; + } + + @Override + public boolean hasCondition() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(body), clone(condition)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isEmptyStatement() { + return false; + } + + static public class EmptyStatement extends Statement { + // Production: sig("EmptyStatement",[],breakable=false) + + + + public EmptyStatement(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmptyStatement() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementEmptyStatement(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof EmptyStatement)) { + return false; + } + EmptyStatement tmp = (EmptyStatement) o; + return true ; + } + + @Override + public int hashCode() { + return 433 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isExpression() { + return false; + } + + static public class Expression extends Statement { + // Production: sig("Expression",[arg("org.rascalmpl.ast.Expression","expression")],breakable=true) + + + private final org.rascalmpl.ast.Expression expression; + + public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.expression = expression; + } + + @Override + public boolean isExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Expression)) { + return false; + } + Expression tmp = (Expression) o; + return true && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 67 + 757 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(expression)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isFail() { + return false; + } + + static public class Fail extends Statement { + // Production: sig("Fail",[arg("org.rascalmpl.ast.Target","target")],breakable=true) + + + private final org.rascalmpl.ast.Target target; + + public Fail(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Target target) { + super(src, node); + + this.target = target; + } + + @Override + public boolean isFail() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementFail(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = target.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + target.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Fail)) { + return false; + } + Fail tmp = (Fail) o; + return true && tmp.target.equals(this.target) ; + } + + @Override + public int hashCode() { + return 479 + 691 * target.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Target getTarget() { + return this.target; + } + + @Override + public boolean hasTarget() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(target)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isFilter() { + return false; + } + + static public class Filter extends Statement { + // Production: sig("Filter",[],breakable=true) + + + + public Filter(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isFilter() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementFilter(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Filter)) { + return false; + } + Filter tmp = (Filter) o; + return true ; + } + + @Override + public int hashCode() { + return 193 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isFor() { + return false; + } + + static public class For extends Statement { + // Production: sig("For",[arg("org.rascalmpl.ast.Label","label"),arg("java.util.List\","generators"),arg("org.rascalmpl.ast.Statement","body")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final java.util.List generators; + private final org.rascalmpl.ast.Statement body; + + public For(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, java.util.List generators, org.rascalmpl.ast.Statement body) { + super(src, node); + + this.label = label; + this.generators = generators; + this.body = body; + } + + @Override + public boolean isFor() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementFor(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof For)) { + return false; + } + For tmp = (For) o; + return true && tmp.label.equals(this.label) && tmp.generators.equals(this.generators) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 113 + 607 * label.hashCode() + 151 * generators.hashCode() + 409 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(generators), clone(body)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isFunctionDeclaration() { + return false; + } + + static public class FunctionDeclaration extends Statement { + // Production: sig("FunctionDeclaration",[arg("org.rascalmpl.ast.FunctionDeclaration","functionDeclaration")],breakable=true) + + + private final org.rascalmpl.ast.FunctionDeclaration functionDeclaration; + + public FunctionDeclaration(ISourceLocation src, IConstructor node , org.rascalmpl.ast.FunctionDeclaration functionDeclaration) { + super(src, node); + + this.functionDeclaration = functionDeclaration; + } + + @Override + public boolean isFunctionDeclaration() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementFunctionDeclaration(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = functionDeclaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + functionDeclaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof FunctionDeclaration)) { + return false; + } + FunctionDeclaration tmp = (FunctionDeclaration) o; + return true && tmp.functionDeclaration.equals(this.functionDeclaration) ; + } + + @Override + public int hashCode() { + return 691 + 691 * functionDeclaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.FunctionDeclaration getFunctionDeclaration() { + return this.functionDeclaration; + } + + @Override + public boolean hasFunctionDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(functionDeclaration)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isGlobalDirective() { + return false; + } + + static public class GlobalDirective extends Statement { + // Production: sig("GlobalDirective",[arg("org.rascalmpl.ast.Type","type"),arg("java.util.List\","names")],breakable=true) + + + private final org.rascalmpl.ast.Type type; + private final java.util.List names; + + public GlobalDirective(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, java.util.List names) { + super(src, node); + + this.type = type; + this.names = names; + } + + @Override + public boolean isGlobalDirective() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementGlobalDirective(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : names) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GlobalDirective)) { + return false; + } + GlobalDirective tmp = (GlobalDirective) o; + return true && tmp.type.equals(this.type) && tmp.names.equals(this.names) ; + } + + @Override + public int hashCode() { + return 73 + 457 * type.hashCode() + 719 * names.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public java.util.List getNames() { + return this.names; + } + + @Override + public boolean hasNames() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(names)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isIfThen() { + return false; + } + + static public class IfThen extends Statement { + // Production: sig("IfThen",[arg("org.rascalmpl.ast.Label","label"),arg("java.util.List\","conditions"),arg("org.rascalmpl.ast.Statement","thenStatement")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final java.util.List conditions; + private final org.rascalmpl.ast.Statement thenStatement; + + public IfThen(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, java.util.List conditions, org.rascalmpl.ast.Statement thenStatement) { + super(src, node); + + this.label = label; + this.conditions = conditions; + this.thenStatement = thenStatement; + } + + @Override + public boolean isIfThen() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementIfThen(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = thenStatement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + thenStatement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfThen)) { + return false; + } + IfThen tmp = (IfThen) o; + return true && tmp.label.equals(this.label) && tmp.conditions.equals(this.conditions) && tmp.thenStatement.equals(this.thenStatement) ; + } + + @Override + public int hashCode() { + return 461 + 929 * label.hashCode() + 199 * conditions.hashCode() + 569 * thenStatement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getThenStatement() { + return this.thenStatement; + } + + @Override + public boolean hasThenStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(conditions), clone(thenStatement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isIfThenElse() { + return false; + } + + static public class IfThenElse extends Statement { + // Production: sig("IfThenElse",[arg("org.rascalmpl.ast.Label","label"),arg("java.util.List\","conditions"),arg("org.rascalmpl.ast.Statement","thenStatement"),arg("org.rascalmpl.ast.Statement","elseStatement")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final java.util.List conditions; + private final org.rascalmpl.ast.Statement thenStatement; + private final org.rascalmpl.ast.Statement elseStatement; + + public IfThenElse(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, java.util.List conditions, org.rascalmpl.ast.Statement thenStatement, org.rascalmpl.ast.Statement elseStatement) { + super(src, node); + + this.label = label; + this.conditions = conditions; + this.thenStatement = thenStatement; + this.elseStatement = elseStatement; + } + + @Override + public boolean isIfThenElse() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementIfThenElse(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = thenStatement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + thenStatement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = elseStatement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + elseStatement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfThenElse)) { + return false; + } + IfThenElse tmp = (IfThenElse) o; + return true && tmp.label.equals(this.label) && tmp.conditions.equals(this.conditions) && tmp.thenStatement.equals(this.thenStatement) && tmp.elseStatement.equals(this.elseStatement) ; + } + + @Override + public int hashCode() { + return 149 + 569 * label.hashCode() + 617 * conditions.hashCode() + 389 * thenStatement.hashCode() + 757 * elseStatement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getThenStatement() { + return this.thenStatement; + } + + @Override + public boolean hasThenStatement() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getElseStatement() { + return this.elseStatement; + } + + @Override + public boolean hasElseStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(conditions), clone(thenStatement), clone(elseStatement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isInsert() { + return false; + } + + static public class Insert extends Statement { + // Production: sig("Insert",[arg("org.rascalmpl.ast.DataTarget","dataTarget"),arg("org.rascalmpl.ast.Statement","statement")],breakable=true) + + + private final org.rascalmpl.ast.DataTarget dataTarget; + private final org.rascalmpl.ast.Statement statement; + + public Insert(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DataTarget dataTarget, org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.dataTarget = dataTarget; + this.statement = statement; + } + + @Override + public boolean isInsert() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementInsert(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = dataTarget.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + dataTarget.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Insert)) { + return false; + } + Insert tmp = (Insert) o; + return true && tmp.dataTarget.equals(this.dataTarget) && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 757 + 439 * dataTarget.hashCode() + 239 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DataTarget getDataTarget() { + return this.dataTarget; + } + + @Override + public boolean hasDataTarget() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(dataTarget), clone(statement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isNonEmptyBlock() { + return false; + } + + static public class NonEmptyBlock extends Statement { + // Production: sig("NonEmptyBlock",[arg("org.rascalmpl.ast.Label","label"),arg("java.util.List\","statements")],breakable=false) + + + private final org.rascalmpl.ast.Label label; + private final java.util.List statements; + + public NonEmptyBlock(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, java.util.List statements) { + super(src, node); + + this.label = label; + this.statements = statements; + } + + @Override + public boolean isNonEmptyBlock() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementNonEmptyBlock(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : statements) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonEmptyBlock)) { + return false; + } + NonEmptyBlock tmp = (NonEmptyBlock) o; + return true && tmp.label.equals(this.label) && tmp.statements.equals(this.statements) ; + } + + @Override + public int hashCode() { + return 641 + 227 * label.hashCode() + 269 * statements.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public java.util.List getStatements() { + return this.statements; + } + + @Override + public boolean hasStatements() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(statements)); + } + + } + public boolean isReturn() { + return false; + } + + static public class Return extends Statement { + // Production: sig("Return",[arg("org.rascalmpl.ast.Statement","statement")],breakable=true) + + + private final org.rascalmpl.ast.Statement statement; + + public Return(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.statement = statement; + } + + @Override + public boolean isReturn() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementReturn(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Return)) { + return false; + } + Return tmp = (Return) o; + return true && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 389 + 367 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isSolve() { + return false; + } + + static public class Solve extends Statement { + // Production: sig("Solve",[arg("java.util.List\","variables"),arg("org.rascalmpl.ast.Bound","bound"),arg("org.rascalmpl.ast.Statement","body")],breakable=true) + + + private final java.util.List variables; + private final org.rascalmpl.ast.Bound bound; + private final org.rascalmpl.ast.Statement body; + + public Solve(ISourceLocation src, IConstructor node , java.util.List variables, org.rascalmpl.ast.Bound bound, org.rascalmpl.ast.Statement body) { + super(src, node); + + this.variables = variables; + this.bound = bound; + this.body = body; + } + + @Override + public boolean isSolve() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementSolve(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : variables) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = bound.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + bound.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Solve)) { + return false; + } + Solve tmp = (Solve) o; + return true && tmp.variables.equals(this.variables) && tmp.bound.equals(this.bound) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 643 + 619 * variables.hashCode() + 631 * bound.hashCode() + 151 * body.hashCode() ; + } + + + @Override + public java.util.List getVariables() { + return this.variables; + } + + @Override + public boolean hasVariables() { + return true; + } + @Override + public org.rascalmpl.ast.Bound getBound() { + return this.bound; + } + + @Override + public boolean hasBound() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(variables), clone(bound), clone(body)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isSwitch() { + return false; + } + + static public class Switch extends Statement { + // Production: sig("Switch",[arg("org.rascalmpl.ast.Label","label"),arg("org.rascalmpl.ast.Expression","expression"),arg("java.util.List\","cases")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final org.rascalmpl.ast.Expression expression; + private final java.util.List cases; + + public Switch(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, org.rascalmpl.ast.Expression expression, java.util.List cases) { + super(src, node); + + this.label = label; + this.expression = expression; + this.cases = cases; + } + + @Override + public boolean isSwitch() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementSwitch(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : cases) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Switch)) { + return false; + } + Switch tmp = (Switch) o; + return true && tmp.label.equals(this.label) && tmp.expression.equals(this.expression) && tmp.cases.equals(this.cases) ; + } + + @Override + public int hashCode() { + return 593 + 109 * label.hashCode() + 53 * expression.hashCode() + 839 * cases.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public java.util.List getCases() { + return this.cases; + } + + @Override + public boolean hasCases() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(expression), clone(cases)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isThrow() { + return false; + } + + static public class Throw extends Statement { + // Production: sig("Throw",[arg("org.rascalmpl.ast.Statement","statement")],breakable=true) + + + private final org.rascalmpl.ast.Statement statement; + + public Throw(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { + super(src, node); + + this.statement = statement; + } + + @Override + public boolean isThrow() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementThrow(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = statement.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + statement.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Throw)) { + return false; + } + Throw tmp = (Throw) o; + return true && tmp.statement.equals(this.statement) ; + } + + @Override + public int hashCode() { + return 389 + 229 * statement.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getStatement() { + return this.statement; + } + + @Override + public boolean hasStatement() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(statement)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isTry() { + return false; + } + + static public class Try extends Statement { + // Production: sig("Try",[arg("org.rascalmpl.ast.Statement","body"),arg("java.util.List\","handlers")],breakable=true) + + + private final org.rascalmpl.ast.Statement body; + private final java.util.List handlers; + + public Try(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement body, java.util.List handlers) { + super(src, node); + + this.body = body; + this.handlers = handlers; + } + + @Override + public boolean isTry() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementTry(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : handlers) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Try)) { + return false; + } + Try tmp = (Try) o; + return true && tmp.body.equals(this.body) && tmp.handlers.equals(this.handlers) ; + } + + @Override + public int hashCode() { + return 157 + 283 * body.hashCode() + 947 * handlers.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getHandlers() { + return this.handlers; + } + + @Override + public boolean hasHandlers() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(body), clone(handlers)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isTryFinally() { + return false; + } + + static public class TryFinally extends Statement { + // Production: sig("TryFinally",[arg("org.rascalmpl.ast.Statement","body"),arg("java.util.List\","handlers"),arg("org.rascalmpl.ast.Statement","finallyBody")],breakable=true) + + + private final org.rascalmpl.ast.Statement body; + private final java.util.List handlers; + private final org.rascalmpl.ast.Statement finallyBody; + + public TryFinally(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement body, java.util.List handlers, org.rascalmpl.ast.Statement finallyBody) { + super(src, node); + + this.body = body; + this.handlers = handlers; + this.finallyBody = finallyBody; + } + + @Override + public boolean isTryFinally() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementTryFinally(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : handlers) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = finallyBody.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + finallyBody.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TryFinally)) { + return false; + } + TryFinally tmp = (TryFinally) o; + return true && tmp.body.equals(this.body) && tmp.handlers.equals(this.handlers) && tmp.finallyBody.equals(this.finallyBody) ; + } + + @Override + public int hashCode() { + return 541 + 103 * body.hashCode() + 619 * handlers.hashCode() + 421 * finallyBody.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getHandlers() { + return this.handlers; + } + + @Override + public boolean hasHandlers() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getFinallyBody() { + return this.finallyBody; + } + + @Override + public boolean hasFinallyBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(body), clone(handlers), clone(finallyBody)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isVariableDeclaration() { + return false; + } + + static public class VariableDeclaration extends Statement { + // Production: sig("VariableDeclaration",[arg("org.rascalmpl.ast.LocalVariableDeclaration","declaration")],breakable=true) + + + private final org.rascalmpl.ast.LocalVariableDeclaration declaration; + + public VariableDeclaration(ISourceLocation src, IConstructor node , org.rascalmpl.ast.LocalVariableDeclaration declaration) { + super(src, node); + + this.declaration = declaration; + } + + @Override + public boolean isVariableDeclaration() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementVariableDeclaration(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof VariableDeclaration)) { + return false; + } + VariableDeclaration tmp = (VariableDeclaration) o; + return true && tmp.declaration.equals(this.declaration) ; + } + + @Override + public int hashCode() { + return 541 + 509 * declaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.LocalVariableDeclaration getDeclaration() { + return this.declaration; + } + + @Override + public boolean hasDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declaration)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isVisit() { + return false; + } + + static public class Visit extends Statement { + // Production: sig("Visit",[arg("org.rascalmpl.ast.Label","label"),arg("org.rascalmpl.ast.Visit","visit")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final org.rascalmpl.ast.Visit visit; + + public Visit(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, org.rascalmpl.ast.Visit visit) { + super(src, node); + + this.label = label; + this.visit = visit; + } + + @Override + public boolean isVisit() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementVisit(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = visit.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + visit.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Visit)) { + return false; + } + Visit tmp = (Visit) o; + return true && tmp.label.equals(this.label) && tmp.visit.equals(this.visit) ; + } + + @Override + public int hashCode() { + return 941 + 653 * label.hashCode() + 13 * visit.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public org.rascalmpl.ast.Visit getVisit() { + return this.visit; + } + + @Override + public boolean hasVisit() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(visit)); + } + @Override + public boolean isBreakable() { + return true; + } + } + public boolean isWhile() { + return false; + } + + static public class While extends Statement { + // Production: sig("While",[arg("org.rascalmpl.ast.Label","label"),arg("java.util.List\","conditions"),arg("org.rascalmpl.ast.Statement","body")],breakable=true) + + + private final org.rascalmpl.ast.Label label; + private final java.util.List conditions; + private final org.rascalmpl.ast.Statement body; + + public While(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Label label, java.util.List conditions, org.rascalmpl.ast.Statement body) { + super(src, node); + + this.label = label; + this.conditions = conditions; + this.body = body; + } + + @Override + public boolean isWhile() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStatementWhile(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof While)) { + return false; + } + While tmp = (While) o; + return true && tmp.label.equals(this.label) && tmp.conditions.equals(this.conditions) && tmp.body.equals(this.body) ; + } + + @Override + public int hashCode() { + return 787 + 37 * label.hashCode() + 131 * conditions.hashCode() + 331 * body.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Label getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + @Override + public org.rascalmpl.ast.Statement getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(label), clone(conditions), clone(body)); + } + @Override + public boolean isBreakable() { + return true; + } + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Strategy.java b/src/org/rascalmpl/ast/Strategy.java new file mode 100644 index 00000000000..dfacf4f726b --- /dev/null +++ b/src/org/rascalmpl/ast/Strategy.java @@ -0,0 +1,363 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Strategy extends AbstractAST { + public Strategy(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isBottomUp() { + return false; + } + + static public class BottomUp extends Strategy { + // Production: sig("BottomUp",[],breakable=false) + + + + public BottomUp(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isBottomUp() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyBottomUp(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof BottomUp)) { + return false; + } + BottomUp tmp = (BottomUp) o; + return true ; + } + + @Override + public int hashCode() { + return 521 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isBottomUpBreak() { + return false; + } + + static public class BottomUpBreak extends Strategy { + // Production: sig("BottomUpBreak",[],breakable=false) + + + + public BottomUpBreak(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isBottomUpBreak() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyBottomUpBreak(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof BottomUpBreak)) { + return false; + } + BottomUpBreak tmp = (BottomUpBreak) o; + return true ; + } + + @Override + public int hashCode() { + return 839 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isInnermost() { + return false; + } + + static public class Innermost extends Strategy { + // Production: sig("Innermost",[],breakable=false) + + + + public Innermost(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isInnermost() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyInnermost(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Innermost)) { + return false; + } + Innermost tmp = (Innermost) o; + return true ; + } + + @Override + public int hashCode() { + return 191 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isOutermost() { + return false; + } + + static public class Outermost extends Strategy { + // Production: sig("Outermost",[],breakable=false) + + + + public Outermost(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isOutermost() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyOutermost(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Outermost)) { + return false; + } + Outermost tmp = (Outermost) o; + return true ; + } + + @Override + public int hashCode() { + return 599 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTopDown() { + return false; + } + + static public class TopDown extends Strategy { + // Production: sig("TopDown",[],breakable=false) + + + + public TopDown(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isTopDown() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyTopDown(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TopDown)) { + return false; + } + TopDown tmp = (TopDown) o; + return true ; + } + + @Override + public int hashCode() { + return 109 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isTopDownBreak() { + return false; + } + + static public class TopDownBreak extends Strategy { + // Production: sig("TopDownBreak",[],breakable=false) + + + + public TopDownBreak(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isTopDownBreak() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStrategyTopDownBreak(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof TopDownBreak)) { + return false; + } + TopDownBreak tmp = (TopDownBreak) o; + return true ; + } + + @Override + public int hashCode() { + return 977 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringCharacter.java b/src/org/rascalmpl/ast/StringCharacter.java new file mode 100644 index 00000000000..710fa8f7501 --- /dev/null +++ b/src/org/rascalmpl/ast/StringCharacter.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringCharacter extends AbstractAST { + public StringCharacter(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends StringCharacter { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitStringCharacterLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringConstant.java b/src/org/rascalmpl/ast/StringConstant.java new file mode 100644 index 00000000000..d4ac3288e17 --- /dev/null +++ b/src/org/rascalmpl/ast/StringConstant.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringConstant extends AbstractAST { + public StringConstant(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends StringConstant { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitStringConstantLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringLiteral.java b/src/org/rascalmpl/ast/StringLiteral.java new file mode 100644 index 00000000000..f03b46e78fc --- /dev/null +++ b/src/org/rascalmpl/ast/StringLiteral.java @@ -0,0 +1,366 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringLiteral extends AbstractAST { + public StringLiteral(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPre() { + return false; + } + + public org.rascalmpl.ast.PreStringChars getPre() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasConstant() { + return false; + } + + public org.rascalmpl.ast.StringConstant getConstant() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.StringTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTemplate() { + return false; + } + + public org.rascalmpl.ast.StringTemplate getTemplate() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isInterpolated() { + return false; + } + + static public class Interpolated extends StringLiteral { + // Production: sig("Interpolated",[arg("org.rascalmpl.ast.PreStringChars","pre"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.StringTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.PreStringChars pre; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.StringTail tail; + + public Interpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PreStringChars pre, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.StringTail tail) { + super(src, node); + + this.pre = pre; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringLiteralInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pre.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pre.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Interpolated)) { + return false; + } + Interpolated tmp = (Interpolated) o; + return true && tmp.pre.equals(this.pre) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 2 + 947 * pre.hashCode() + 281 * expression.hashCode() + 409 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PreStringChars getPre() { + return this.pre; + } + + @Override + public boolean hasPre() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.StringTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pre), clone(expression), clone(tail)); + } + + } + public boolean isNonInterpolated() { + return false; + } + + static public class NonInterpolated extends StringLiteral { + // Production: sig("NonInterpolated",[arg("org.rascalmpl.ast.StringConstant","constant")],breakable=false) + + + private final org.rascalmpl.ast.StringConstant constant; + + public NonInterpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.StringConstant constant) { + super(src, node); + + this.constant = constant; + } + + @Override + public boolean isNonInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringLiteralNonInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = constant.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + constant.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NonInterpolated)) { + return false; + } + NonInterpolated tmp = (NonInterpolated) o; + return true && tmp.constant.equals(this.constant) ; + } + + @Override + public int hashCode() { + return 97 + 607 * constant.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.StringConstant getConstant() { + return this.constant; + } + + @Override + public boolean hasConstant() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(constant)); + } + + } + public boolean isTemplate() { + return false; + } + + static public class Template extends StringLiteral { + // Production: sig("Template",[arg("org.rascalmpl.ast.PreStringChars","pre"),arg("org.rascalmpl.ast.StringTemplate","template"),arg("org.rascalmpl.ast.StringTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.PreStringChars pre; + private final org.rascalmpl.ast.StringTemplate template; + private final org.rascalmpl.ast.StringTail tail; + + public Template(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PreStringChars pre, org.rascalmpl.ast.StringTemplate template, org.rascalmpl.ast.StringTail tail) { + super(src, node); + + this.pre = pre; + this.template = template; + this.tail = tail; + } + + @Override + public boolean isTemplate() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringLiteralTemplate(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = pre.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + pre.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = template.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + template.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Template)) { + return false; + } + Template tmp = (Template) o; + return true && tmp.pre.equals(this.pre) && tmp.template.equals(this.template) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 547 + 283 * pre.hashCode() + 757 * template.hashCode() + 347 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PreStringChars getPre() { + return this.pre; + } + + @Override + public boolean hasPre() { + return true; + } + @Override + public org.rascalmpl.ast.StringTemplate getTemplate() { + return this.template; + } + + @Override + public boolean hasTemplate() { + return true; + } + @Override + public org.rascalmpl.ast.StringTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(pre), clone(template), clone(tail)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringMiddle.java b/src/org/rascalmpl/ast/StringMiddle.java new file mode 100644 index 00000000000..1044fd29bff --- /dev/null +++ b/src/org/rascalmpl/ast/StringMiddle.java @@ -0,0 +1,359 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringMiddle extends AbstractAST { + public StringMiddle(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMid() { + return false; + } + + public org.rascalmpl.ast.MidStringChars getMid() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.StringMiddle getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTemplate() { + return false; + } + + public org.rascalmpl.ast.StringTemplate getTemplate() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isInterpolated() { + return false; + } + + static public class Interpolated extends StringMiddle { + // Production: sig("Interpolated",[arg("org.rascalmpl.ast.MidStringChars","mid"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.StringMiddle","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidStringChars mid; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.StringMiddle tail; + + public Interpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidStringChars mid, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.StringMiddle tail) { + super(src, node); + + this.mid = mid; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringMiddleInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Interpolated)) { + return false; + } + Interpolated tmp = (Interpolated) o; + return true && tmp.mid.equals(this.mid) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 73 + 181 * mid.hashCode() + 499 * expression.hashCode() + 227 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidStringChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(expression), clone(tail)); + } + + } + public boolean isMid() { + return false; + } + + static public class Mid extends StringMiddle { + // Production: sig("Mid",[arg("org.rascalmpl.ast.MidStringChars","mid")],breakable=false) + + + private final org.rascalmpl.ast.MidStringChars mid; + + public Mid(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidStringChars mid) { + super(src, node); + + this.mid = mid; + } + + @Override + public boolean isMid() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringMiddleMid(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Mid)) { + return false; + } + Mid tmp = (Mid) o; + return true && tmp.mid.equals(this.mid) ; + } + + @Override + public int hashCode() { + return 389 + 479 * mid.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidStringChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid)); + } + + } + public boolean isTemplate() { + return false; + } + + static public class Template extends StringMiddle { + // Production: sig("Template",[arg("org.rascalmpl.ast.MidStringChars","mid"),arg("org.rascalmpl.ast.StringTemplate","template"),arg("org.rascalmpl.ast.StringMiddle","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidStringChars mid; + private final org.rascalmpl.ast.StringTemplate template; + private final org.rascalmpl.ast.StringMiddle tail; + + public Template(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidStringChars mid, org.rascalmpl.ast.StringTemplate template, org.rascalmpl.ast.StringMiddle tail) { + super(src, node); + + this.mid = mid; + this.template = template; + this.tail = tail; + } + + @Override + public boolean isTemplate() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringMiddleTemplate(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = template.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + template.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Template)) { + return false; + } + Template tmp = (Template) o; + return true && tmp.mid.equals(this.mid) && tmp.template.equals(this.template) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 103 + 859 * mid.hashCode() + 163 * template.hashCode() + 739 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidStringChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.StringTemplate getTemplate() { + return this.template; + } + + @Override + public boolean hasTemplate() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(template), clone(tail)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringTail.java b/src/org/rascalmpl/ast/StringTail.java new file mode 100644 index 00000000000..66e660ca0c5 --- /dev/null +++ b/src/org/rascalmpl/ast/StringTail.java @@ -0,0 +1,366 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringTail extends AbstractAST { + public StringTail(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMid() { + return false; + } + + public org.rascalmpl.ast.MidStringChars getMid() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPost() { + return false; + } + + public org.rascalmpl.ast.PostStringChars getPost() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTail() { + return false; + } + + public org.rascalmpl.ast.StringTail getTail() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTemplate() { + return false; + } + + public org.rascalmpl.ast.StringTemplate getTemplate() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isMidInterpolated() { + return false; + } + + static public class MidInterpolated extends StringTail { + // Production: sig("MidInterpolated",[arg("org.rascalmpl.ast.MidStringChars","mid"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.StringTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidStringChars mid; + private final org.rascalmpl.ast.Expression expression; + private final org.rascalmpl.ast.StringTail tail; + + public MidInterpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidStringChars mid, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.StringTail tail) { + super(src, node); + + this.mid = mid; + this.expression = expression; + this.tail = tail; + } + + @Override + public boolean isMidInterpolated() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTailMidInterpolated(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MidInterpolated)) { + return false; + } + MidInterpolated tmp = (MidInterpolated) o; + return true && tmp.mid.equals(this.mid) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 821 + 977 * mid.hashCode() + 677 * expression.hashCode() + 11 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidStringChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + @Override + public org.rascalmpl.ast.StringTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(expression), clone(tail)); + } + + } + public boolean isMidTemplate() { + return false; + } + + static public class MidTemplate extends StringTail { + // Production: sig("MidTemplate",[arg("org.rascalmpl.ast.MidStringChars","mid"),arg("org.rascalmpl.ast.StringTemplate","template"),arg("org.rascalmpl.ast.StringTail","tail")],breakable=false) + + + private final org.rascalmpl.ast.MidStringChars mid; + private final org.rascalmpl.ast.StringTemplate template; + private final org.rascalmpl.ast.StringTail tail; + + public MidTemplate(ISourceLocation src, IConstructor node , org.rascalmpl.ast.MidStringChars mid, org.rascalmpl.ast.StringTemplate template, org.rascalmpl.ast.StringTail tail) { + super(src, node); + + this.mid = mid; + this.template = template; + this.tail = tail; + } + + @Override + public boolean isMidTemplate() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTailMidTemplate(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = mid.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + mid.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = template.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + template.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = tail.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + tail.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MidTemplate)) { + return false; + } + MidTemplate tmp = (MidTemplate) o; + return true && tmp.mid.equals(this.mid) && tmp.template.equals(this.template) && tmp.tail.equals(this.tail) ; + } + + @Override + public int hashCode() { + return 691 + 71 * mid.hashCode() + 181 * template.hashCode() + 199 * tail.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.MidStringChars getMid() { + return this.mid; + } + + @Override + public boolean hasMid() { + return true; + } + @Override + public org.rascalmpl.ast.StringTemplate getTemplate() { + return this.template; + } + + @Override + public boolean hasTemplate() { + return true; + } + @Override + public org.rascalmpl.ast.StringTail getTail() { + return this.tail; + } + + @Override + public boolean hasTail() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(mid), clone(template), clone(tail)); + } + + } + public boolean isPost() { + return false; + } + + static public class Post extends StringTail { + // Production: sig("Post",[arg("org.rascalmpl.ast.PostStringChars","post")],breakable=false) + + + private final org.rascalmpl.ast.PostStringChars post; + + public Post(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PostStringChars post) { + super(src, node); + + this.post = post; + } + + @Override + public boolean isPost() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTailPost(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = post.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + post.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Post)) { + return false; + } + Post tmp = (Post) o; + return true && tmp.post.equals(this.post) ; + } + + @Override + public int hashCode() { + return 787 + 193 * post.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.PostStringChars getPost() { + return this.post; + } + + @Override + public boolean hasPost() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(post)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StringTemplate.java b/src/org/rascalmpl/ast/StringTemplate.java new file mode 100644 index 00000000000..fc0dfaf0606 --- /dev/null +++ b/src/org/rascalmpl/ast/StringTemplate.java @@ -0,0 +1,859 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StringTemplate extends AbstractAST { + public StringTemplate(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasConditions() { + return false; + } + + public java.util.List getConditions() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasGenerators() { + return false; + } + + public java.util.List getGenerators() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPostStats() { + return false; + } + + public java.util.List getPostStats() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPostStatsElse() { + return false; + } + + public java.util.List getPostStatsElse() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPostStatsThen() { + return false; + } + + public java.util.List getPostStatsThen() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPreStats() { + return false; + } + + public java.util.List getPreStats() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPreStatsElse() { + return false; + } + + public java.util.List getPreStatsElse() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasPreStatsThen() { + return false; + } + + public java.util.List getPreStatsThen() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCondition() { + return false; + } + + public org.rascalmpl.ast.Expression getCondition() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBody() { + return false; + } + + public org.rascalmpl.ast.StringMiddle getBody() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasElseString() { + return false; + } + + public org.rascalmpl.ast.StringMiddle getElseString() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasThenString() { + return false; + } + + public org.rascalmpl.ast.StringMiddle getThenString() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDoWhile() { + return false; + } + + static public class DoWhile extends StringTemplate { + // Production: sig("DoWhile",[arg("java.util.List\","preStats"),arg("org.rascalmpl.ast.StringMiddle","body"),arg("java.util.List\","postStats"),arg("org.rascalmpl.ast.Expression","condition")],breakable=false) + + + private final java.util.List preStats; + private final org.rascalmpl.ast.StringMiddle body; + private final java.util.List postStats; + private final org.rascalmpl.ast.Expression condition; + + public DoWhile(ISourceLocation src, IConstructor node , java.util.List preStats, org.rascalmpl.ast.StringMiddle body, java.util.List postStats, org.rascalmpl.ast.Expression condition) { + super(src, node); + + this.preStats = preStats; + this.body = body; + this.postStats = postStats; + this.condition = condition; + } + + @Override + public boolean isDoWhile() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTemplateDoWhile(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : preStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = condition.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + condition.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DoWhile)) { + return false; + } + DoWhile tmp = (DoWhile) o; + return true && tmp.preStats.equals(this.preStats) && tmp.body.equals(this.body) && tmp.postStats.equals(this.postStats) && tmp.condition.equals(this.condition) ; + } + + @Override + public int hashCode() { + return 199 + 389 * preStats.hashCode() + 281 * body.hashCode() + 389 * postStats.hashCode() + 683 * condition.hashCode() ; + } + + + @Override + public java.util.List getPreStats() { + return this.preStats; + } + + @Override + public boolean hasPreStats() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getPostStats() { + return this.postStats; + } + + @Override + public boolean hasPostStats() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getCondition() { + return this.condition; + } + + @Override + public boolean hasCondition() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(preStats), clone(body), clone(postStats), clone(condition)); + } + + } + public boolean isFor() { + return false; + } + + static public class For extends StringTemplate { + // Production: sig("For",[arg("java.util.List\","generators"),arg("java.util.List\","preStats"),arg("org.rascalmpl.ast.StringMiddle","body"),arg("java.util.List\","postStats")],breakable=false) + + + private final java.util.List generators; + private final java.util.List preStats; + private final org.rascalmpl.ast.StringMiddle body; + private final java.util.List postStats; + + public For(ISourceLocation src, IConstructor node , java.util.List generators, java.util.List preStats, org.rascalmpl.ast.StringMiddle body, java.util.List postStats) { + super(src, node); + + this.generators = generators; + this.preStats = preStats; + this.body = body; + this.postStats = postStats; + } + + @Override + public boolean isFor() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTemplateFor(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : generators) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : preStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof For)) { + return false; + } + For tmp = (For) o; + return true && tmp.generators.equals(this.generators) && tmp.preStats.equals(this.preStats) && tmp.body.equals(this.body) && tmp.postStats.equals(this.postStats) ; + } + + @Override + public int hashCode() { + return 577 + 653 * generators.hashCode() + 73 * preStats.hashCode() + 991 * body.hashCode() + 911 * postStats.hashCode() ; + } + + + @Override + public java.util.List getGenerators() { + return this.generators; + } + + @Override + public boolean hasGenerators() { + return true; + } + @Override + public java.util.List getPreStats() { + return this.preStats; + } + + @Override + public boolean hasPreStats() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getPostStats() { + return this.postStats; + } + + @Override + public boolean hasPostStats() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(generators), clone(preStats), clone(body), clone(postStats)); + } + + } + public boolean isIfThen() { + return false; + } + + static public class IfThen extends StringTemplate { + // Production: sig("IfThen",[arg("java.util.List\","conditions"),arg("java.util.List\","preStats"),arg("org.rascalmpl.ast.StringMiddle","body"),arg("java.util.List\","postStats")],breakable=false) + + + private final java.util.List conditions; + private final java.util.List preStats; + private final org.rascalmpl.ast.StringMiddle body; + private final java.util.List postStats; + + public IfThen(ISourceLocation src, IConstructor node , java.util.List conditions, java.util.List preStats, org.rascalmpl.ast.StringMiddle body, java.util.List postStats) { + super(src, node); + + this.conditions = conditions; + this.preStats = preStats; + this.body = body; + this.postStats = postStats; + } + + @Override + public boolean isIfThen() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTemplateIfThen(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : preStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfThen)) { + return false; + } + IfThen tmp = (IfThen) o; + return true && tmp.conditions.equals(this.conditions) && tmp.preStats.equals(this.preStats) && tmp.body.equals(this.body) && tmp.postStats.equals(this.postStats) ; + } + + @Override + public int hashCode() { + return 379 + 811 * conditions.hashCode() + 373 * preStats.hashCode() + 83 * body.hashCode() + 71 * postStats.hashCode() ; + } + + + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + @Override + public java.util.List getPreStats() { + return this.preStats; + } + + @Override + public boolean hasPreStats() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getPostStats() { + return this.postStats; + } + + @Override + public boolean hasPostStats() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(conditions), clone(preStats), clone(body), clone(postStats)); + } + + } + public boolean isIfThenElse() { + return false; + } + + static public class IfThenElse extends StringTemplate { + // Production: sig("IfThenElse",[arg("java.util.List\","conditions"),arg("java.util.List\","preStatsThen"),arg("org.rascalmpl.ast.StringMiddle","thenString"),arg("java.util.List\","postStatsThen"),arg("java.util.List\","preStatsElse"),arg("org.rascalmpl.ast.StringMiddle","elseString"),arg("java.util.List\","postStatsElse")],breakable=false) + + + private final java.util.List conditions; + private final java.util.List preStatsThen; + private final org.rascalmpl.ast.StringMiddle thenString; + private final java.util.List postStatsThen; + private final java.util.List preStatsElse; + private final org.rascalmpl.ast.StringMiddle elseString; + private final java.util.List postStatsElse; + + public IfThenElse(ISourceLocation src, IConstructor node , java.util.List conditions, java.util.List preStatsThen, org.rascalmpl.ast.StringMiddle thenString, java.util.List postStatsThen, java.util.List preStatsElse, org.rascalmpl.ast.StringMiddle elseString, java.util.List postStatsElse) { + super(src, node); + + this.conditions = conditions; + this.preStatsThen = preStatsThen; + this.thenString = thenString; + this.postStatsThen = postStatsThen; + this.preStatsElse = preStatsElse; + this.elseString = elseString; + this.postStatsElse = postStatsElse; + } + + @Override + public boolean isIfThenElse() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTemplateIfThenElse(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : conditions) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : preStatsThen) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = thenString.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + thenString.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStatsThen) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + for (AbstractAST $elem : preStatsElse) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = elseString.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + elseString.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStatsElse) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IfThenElse)) { + return false; + } + IfThenElse tmp = (IfThenElse) o; + return true && tmp.conditions.equals(this.conditions) && tmp.preStatsThen.equals(this.preStatsThen) && tmp.thenString.equals(this.thenString) && tmp.postStatsThen.equals(this.postStatsThen) && tmp.preStatsElse.equals(this.preStatsElse) && tmp.elseString.equals(this.elseString) && tmp.postStatsElse.equals(this.postStatsElse) ; + } + + @Override + public int hashCode() { + return 683 + 839 * conditions.hashCode() + 577 * preStatsThen.hashCode() + 41 * thenString.hashCode() + 809 * postStatsThen.hashCode() + 821 * preStatsElse.hashCode() + 821 * elseString.hashCode() + 59 * postStatsElse.hashCode() ; + } + + + @Override + public java.util.List getConditions() { + return this.conditions; + } + + @Override + public boolean hasConditions() { + return true; + } + @Override + public java.util.List getPreStatsThen() { + return this.preStatsThen; + } + + @Override + public boolean hasPreStatsThen() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getThenString() { + return this.thenString; + } + + @Override + public boolean hasThenString() { + return true; + } + @Override + public java.util.List getPostStatsThen() { + return this.postStatsThen; + } + + @Override + public boolean hasPostStatsThen() { + return true; + } + @Override + public java.util.List getPreStatsElse() { + return this.preStatsElse; + } + + @Override + public boolean hasPreStatsElse() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getElseString() { + return this.elseString; + } + + @Override + public boolean hasElseString() { + return true; + } + @Override + public java.util.List getPostStatsElse() { + return this.postStatsElse; + } + + @Override + public boolean hasPostStatsElse() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(conditions), clone(preStatsThen), clone(thenString), clone(postStatsThen), clone(preStatsElse), clone(elseString), clone(postStatsElse)); + } + + } + public boolean isWhile() { + return false; + } + + static public class While extends StringTemplate { + // Production: sig("While",[arg("org.rascalmpl.ast.Expression","condition"),arg("java.util.List\","preStats"),arg("org.rascalmpl.ast.StringMiddle","body"),arg("java.util.List\","postStats")],breakable=false) + + + private final org.rascalmpl.ast.Expression condition; + private final java.util.List preStats; + private final org.rascalmpl.ast.StringMiddle body; + private final java.util.List postStats; + + public While(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression condition, java.util.List preStats, org.rascalmpl.ast.StringMiddle body, java.util.List postStats) { + super(src, node); + + this.condition = condition; + this.preStats = preStats; + this.body = body; + this.postStats = postStats; + } + + @Override + public boolean isWhile() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStringTemplateWhile(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = condition.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + condition.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : preStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = body.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + body.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : postStats) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof While)) { + return false; + } + While tmp = (While) o; + return true && tmp.condition.equals(this.condition) && tmp.preStats.equals(this.preStats) && tmp.body.equals(this.body) && tmp.postStats.equals(this.postStats) ; + } + + @Override + public int hashCode() { + return 139 + 233 * condition.hashCode() + 331 * preStats.hashCode() + 359 * body.hashCode() + 151 * postStats.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getCondition() { + return this.condition; + } + + @Override + public boolean hasCondition() { + return true; + } + @Override + public java.util.List getPreStats() { + return this.preStats; + } + + @Override + public boolean hasPreStats() { + return true; + } + @Override + public org.rascalmpl.ast.StringMiddle getBody() { + return this.body; + } + + @Override + public boolean hasBody() { + return true; + } + @Override + public java.util.List getPostStats() { + return this.postStats; + } + + @Override + public boolean hasPostStats() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(condition), clone(preStats), clone(body), clone(postStats)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/StructuredType.java b/src/org/rascalmpl/ast/StructuredType.java new file mode 100644 index 00000000000..b2c20b4df88 --- /dev/null +++ b/src/org/rascalmpl/ast/StructuredType.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class StructuredType extends AbstractAST { + public StructuredType(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasArguments() { + return false; + } + + public java.util.List getArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBasicType() { + return false; + } + + public org.rascalmpl.ast.BasicType getBasicType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends StructuredType { + // Production: sig("Default",[arg("org.rascalmpl.ast.BasicType","basicType"),arg("java.util.List\","arguments")],breakable=false) + + + private final org.rascalmpl.ast.BasicType basicType; + private final java.util.List arguments; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.BasicType basicType, java.util.List arguments) { + super(src, node); + + this.basicType = basicType; + this.arguments = arguments; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitStructuredTypeDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = basicType.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + basicType.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : arguments) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.basicType.equals(this.basicType) && tmp.arguments.equals(this.arguments) ; + } + + @Override + public int hashCode() { + return 311 + 73 * basicType.hashCode() + 619 * arguments.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.BasicType getBasicType() { + return this.basicType; + } + + @Override + public boolean hasBasicType() { + return true; + } + @Override + public java.util.List getArguments() { + return this.arguments; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(basicType), clone(arguments)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Sym.java b/src/org/rascalmpl/ast/Sym.java new file mode 100644 index 00000000000..255873930b7 --- /dev/null +++ b/src/org/rascalmpl/ast/Sym.java @@ -0,0 +1,2208 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Sym extends AbstractAST { + public Sym(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasAlternatives() { + return false; + } + + public java.util.List getAlternatives() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasParameters() { + return false; + } + + public java.util.List getParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSequence() { + return false; + } + + public java.util.List getSequence() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCistring() { + return false; + } + + public org.rascalmpl.ast.CaseInsensitiveStringConstant getCistring() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasCharClass() { + return false; + } + + public org.rascalmpl.ast.Class getCharClass() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasColumn() { + return false; + } + + public org.rascalmpl.ast.IntegerLiteral getColumn() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasNonterminal() { + return false; + } + + public org.rascalmpl.ast.Nonterminal getNonterminal() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasLabel() { + return false; + } + + public org.rascalmpl.ast.NonterminalLabel getLabel() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasString() { + return false; + } + + public org.rascalmpl.ast.StringConstant getString() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFirst() { + return false; + } + + public org.rascalmpl.ast.Sym getFirst() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasMatch() { + return false; + } + + public org.rascalmpl.ast.Sym getMatch() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSep() { + return false; + } + + public org.rascalmpl.ast.Sym getSep() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSymbol() { + return false; + } + + public org.rascalmpl.ast.Sym getSymbol() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isAlternative() { + return false; + } + + static public class Alternative extends Sym { + // Production: sig("Alternative",[arg("org.rascalmpl.ast.Sym","first"),arg("java.util.List\","alternatives")],breakable=false) + + + private final org.rascalmpl.ast.Sym first; + private final java.util.List alternatives; + + public Alternative(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym first, java.util.List alternatives) { + super(src, node); + + this.first = first; + this.alternatives = alternatives; + } + + @Override + public boolean isAlternative() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymAlternative(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = first.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + first.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : alternatives) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Alternative)) { + return false; + } + Alternative tmp = (Alternative) o; + return true && tmp.first.equals(this.first) && tmp.alternatives.equals(this.alternatives) ; + } + + @Override + public int hashCode() { + return 5 + 191 * first.hashCode() + 467 * alternatives.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getFirst() { + return this.first; + } + + @Override + public boolean hasFirst() { + return true; + } + @Override + public java.util.List getAlternatives() { + return this.alternatives; + } + + @Override + public boolean hasAlternatives() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(first), clone(alternatives)); + } + + } + public boolean isCaseInsensitiveLiteral() { + return false; + } + + static public class CaseInsensitiveLiteral extends Sym { + // Production: sig("CaseInsensitiveLiteral",[arg("org.rascalmpl.ast.CaseInsensitiveStringConstant","cistring")],breakable=false) + + + private final org.rascalmpl.ast.CaseInsensitiveStringConstant cistring; + + public CaseInsensitiveLiteral(ISourceLocation src, IConstructor node , org.rascalmpl.ast.CaseInsensitiveStringConstant cistring) { + super(src, node); + + this.cistring = cistring; + } + + @Override + public boolean isCaseInsensitiveLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymCaseInsensitiveLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = cistring.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + cistring.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof CaseInsensitiveLiteral)) { + return false; + } + CaseInsensitiveLiteral tmp = (CaseInsensitiveLiteral) o; + return true && tmp.cistring.equals(this.cistring) ; + } + + @Override + public int hashCode() { + return 149 + 19 * cistring.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.CaseInsensitiveStringConstant getCistring() { + return this.cistring; + } + + @Override + public boolean hasCistring() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(cistring)); + } + + } + public boolean isCharacterClass() { + return false; + } + + static public class CharacterClass extends Sym { + // Production: sig("CharacterClass",[arg("org.rascalmpl.ast.Class","charClass")],breakable=false) + + + private final org.rascalmpl.ast.Class charClass; + + public CharacterClass(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Class charClass) { + super(src, node); + + this.charClass = charClass; + } + + @Override + public boolean isCharacterClass() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymCharacterClass(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = charClass.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + charClass.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof CharacterClass)) { + return false; + } + CharacterClass tmp = (CharacterClass) o; + return true && tmp.charClass.equals(this.charClass) ; + } + + @Override + public int hashCode() { + return 761 + 89 * charClass.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Class getCharClass() { + return this.charClass; + } + + @Override + public boolean hasCharClass() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(charClass)); + } + + } + public boolean isColumn() { + return false; + } + + static public class Column extends Sym { + // Production: sig("Column",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.IntegerLiteral","column")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.IntegerLiteral column; + + public Column(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.IntegerLiteral column) { + super(src, node); + + this.symbol = symbol; + this.column = column; + } + + @Override + public boolean isColumn() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymColumn(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = column.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + column.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Column)) { + return false; + } + Column tmp = (Column) o; + return true && tmp.symbol.equals(this.symbol) && tmp.column.equals(this.column) ; + } + + @Override + public int hashCode() { + return 587 + 67 * symbol.hashCode() + 191 * column.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.IntegerLiteral getColumn() { + return this.column; + } + + @Override + public boolean hasColumn() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(column)); + } + + } + public boolean isEmpty() { + return false; + } + + static public class Empty extends Sym { + // Production: sig("Empty",[],breakable=false) + + + + public Empty(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true ; + } + + @Override + public int hashCode() { + return 577 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isEndOfLine() { + return false; + } + + static public class EndOfLine extends Sym { + // Production: sig("EndOfLine",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public EndOfLine(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isEndOfLine() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymEndOfLine(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof EndOfLine)) { + return false; + } + EndOfLine tmp = (EndOfLine) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 263 + 647 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isExcept() { + return false; + } + + static public class Except extends Sym { + // Production: sig("Except",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.NonterminalLabel","label")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.NonterminalLabel label; + + public Except(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.NonterminalLabel label) { + super(src, node); + + this.symbol = symbol; + this.label = label; + } + + @Override + public boolean isExcept() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymExcept(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Except)) { + return false; + } + Except tmp = (Except) o; + return true && tmp.symbol.equals(this.symbol) && tmp.label.equals(this.label) ; + } + + @Override + public int hashCode() { + return 991 + 409 * symbol.hashCode() + 907 * label.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.NonterminalLabel getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(label)); + } + + } + public boolean isFollow() { + return false; + } + + static public class Follow extends Sym { + // Production: sig("Follow",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Sym","match")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Sym match; + + public Follow(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Sym match) { + super(src, node); + + this.symbol = symbol; + this.match = match; + } + + @Override + public boolean isFollow() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymFollow(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = match.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + match.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Follow)) { + return false; + } + Follow tmp = (Follow) o; + return true && tmp.symbol.equals(this.symbol) && tmp.match.equals(this.match) ; + } + + @Override + public int hashCode() { + return 89 + 347 * symbol.hashCode() + 509 * match.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getMatch() { + return this.match; + } + + @Override + public boolean hasMatch() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(match)); + } + + } + public boolean isIter() { + return false; + } + + static public class Iter extends Sym { + // Production: sig("Iter",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public Iter(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isIter() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymIter(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Iter)) { + return false; + } + Iter tmp = (Iter) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 151 + 599 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isIterSep() { + return false; + } + + static public class IterSep extends Sym { + // Production: sig("IterSep",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Sym","sep")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Sym sep; + + public IterSep(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Sym sep) { + super(src, node); + + this.symbol = symbol; + this.sep = sep; + } + + @Override + public boolean isIterSep() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymIterSep(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = sep.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + sep.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IterSep)) { + return false; + } + IterSep tmp = (IterSep) o; + return true && tmp.symbol.equals(this.symbol) && tmp.sep.equals(this.sep) ; + } + + @Override + public int hashCode() { + return 29 + 941 * symbol.hashCode() + 103 * sep.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getSep() { + return this.sep; + } + + @Override + public boolean hasSep() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(sep)); + } + + } + public boolean isIterStar() { + return false; + } + + static public class IterStar extends Sym { + // Production: sig("IterStar",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public IterStar(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isIterStar() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymIterStar(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IterStar)) { + return false; + } + IterStar tmp = (IterStar) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 67 + 769 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isIterStarSep() { + return false; + } + + static public class IterStarSep extends Sym { + // Production: sig("IterStarSep",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Sym","sep")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Sym sep; + + public IterStarSep(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Sym sep) { + super(src, node); + + this.symbol = symbol; + this.sep = sep; + } + + @Override + public boolean isIterStarSep() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymIterStarSep(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = sep.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + sep.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IterStarSep)) { + return false; + } + IterStarSep tmp = (IterStarSep) o; + return true && tmp.symbol.equals(this.symbol) && tmp.sep.equals(this.sep) ; + } + + @Override + public int hashCode() { + return 149 + 541 * symbol.hashCode() + 353 * sep.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getSep() { + return this.sep; + } + + @Override + public boolean hasSep() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(sep)); + } + + } + public boolean isLabeled() { + return false; + } + + static public class Labeled extends Sym { + // Production: sig("Labeled",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.NonterminalLabel","label")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.NonterminalLabel label; + + public Labeled(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.NonterminalLabel label) { + super(src, node); + + this.symbol = symbol; + this.label = label; + } + + @Override + public boolean isLabeled() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymLabeled(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = label.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + label.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Labeled)) { + return false; + } + Labeled tmp = (Labeled) o; + return true && tmp.symbol.equals(this.symbol) && tmp.label.equals(this.label) ; + } + + @Override + public int hashCode() { + return 23 + 787 * symbol.hashCode() + 863 * label.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.NonterminalLabel getLabel() { + return this.label; + } + + @Override + public boolean hasLabel() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(label)); + } + + } + public boolean isLiteral() { + return false; + } + + static public class Literal extends Sym { + // Production: sig("Literal",[arg("org.rascalmpl.ast.StringConstant","string")],breakable=false) + + + private final org.rascalmpl.ast.StringConstant string; + + public Literal(ISourceLocation src, IConstructor node , org.rascalmpl.ast.StringConstant string) { + super(src, node); + + this.string = string; + } + + @Override + public boolean isLiteral() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymLiteral(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = string.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + string.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Literal)) { + return false; + } + Literal tmp = (Literal) o; + return true && tmp.string.equals(this.string) ; + } + + @Override + public int hashCode() { + return 557 + 61 * string.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.StringConstant getString() { + return this.string; + } + + @Override + public boolean hasString() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(string)); + } + + } + public boolean isNonterminal() { + return false; + } + + static public class Nonterminal extends Sym { + // Production: sig("Nonterminal",[arg("org.rascalmpl.ast.Nonterminal","nonterminal")],breakable=false) + + + private final org.rascalmpl.ast.Nonterminal nonterminal; + + public Nonterminal(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Nonterminal nonterminal) { + super(src, node); + + this.nonterminal = nonterminal; + } + + @Override + public boolean isNonterminal() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymNonterminal(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = nonterminal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + nonterminal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Nonterminal)) { + return false; + } + Nonterminal tmp = (Nonterminal) o; + return true && tmp.nonterminal.equals(this.nonterminal) ; + } + + @Override + public int hashCode() { + return 281 + 263 * nonterminal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Nonterminal getNonterminal() { + return this.nonterminal; + } + + @Override + public boolean hasNonterminal() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(nonterminal)); + } + + } + public boolean isNotFollow() { + return false; + } + + static public class NotFollow extends Sym { + // Production: sig("NotFollow",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Sym","match")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Sym match; + + public NotFollow(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Sym match) { + super(src, node); + + this.symbol = symbol; + this.match = match; + } + + @Override + public boolean isNotFollow() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymNotFollow(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = match.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + match.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NotFollow)) { + return false; + } + NotFollow tmp = (NotFollow) o; + return true && tmp.symbol.equals(this.symbol) && tmp.match.equals(this.match) ; + } + + @Override + public int hashCode() { + return 19 + 61 * symbol.hashCode() + 241 * match.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getMatch() { + return this.match; + } + + @Override + public boolean hasMatch() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(match)); + } + + } + public boolean isNotPrecede() { + return false; + } + + static public class NotPrecede extends Sym { + // Production: sig("NotPrecede",[arg("org.rascalmpl.ast.Sym","match"),arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym match; + private final org.rascalmpl.ast.Sym symbol; + + public NotPrecede(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym match, org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.match = match; + this.symbol = symbol; + } + + @Override + public boolean isNotPrecede() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymNotPrecede(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = match.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + match.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NotPrecede)) { + return false; + } + NotPrecede tmp = (NotPrecede) o; + return true && tmp.match.equals(this.match) && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 409 + 443 * match.hashCode() + 11 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getMatch() { + return this.match; + } + + @Override + public boolean hasMatch() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(match), clone(symbol)); + } + + } + public boolean isOptional() { + return false; + } + + static public class Optional extends Sym { + // Production: sig("Optional",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public Optional(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isOptional() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymOptional(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Optional)) { + return false; + } + Optional tmp = (Optional) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 389 + 229 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isParameter() { + return false; + } + + static public class Parameter extends Sym { + // Production: sig("Parameter",[arg("org.rascalmpl.ast.Nonterminal","nonterminal")],breakable=false) + + + private final org.rascalmpl.ast.Nonterminal nonterminal; + + public Parameter(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Nonterminal nonterminal) { + super(src, node); + + this.nonterminal = nonterminal; + } + + @Override + public boolean isParameter() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymParameter(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = nonterminal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + nonterminal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Parameter)) { + return false; + } + Parameter tmp = (Parameter) o; + return true && tmp.nonterminal.equals(this.nonterminal) ; + } + + @Override + public int hashCode() { + return 193 + 617 * nonterminal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Nonterminal getNonterminal() { + return this.nonterminal; + } + + @Override + public boolean hasNonterminal() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(nonterminal)); + } + + } + public boolean isParametrized() { + return false; + } + + static public class Parametrized extends Sym { + // Production: sig("Parametrized",[arg("org.rascalmpl.ast.Nonterminal","nonterminal"),arg("java.util.List\","parameters")],breakable=false) + + + private final org.rascalmpl.ast.Nonterminal nonterminal; + private final java.util.List parameters; + + public Parametrized(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Nonterminal nonterminal, java.util.List parameters) { + super(src, node); + + this.nonterminal = nonterminal; + this.parameters = parameters; + } + + @Override + public boolean isParametrized() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymParametrized(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = nonterminal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + nonterminal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : parameters) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Parametrized)) { + return false; + } + Parametrized tmp = (Parametrized) o; + return true && tmp.nonterminal.equals(this.nonterminal) && tmp.parameters.equals(this.parameters) ; + } + + @Override + public int hashCode() { + return 521 + 269 * nonterminal.hashCode() + 839 * parameters.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Nonterminal getNonterminal() { + return this.nonterminal; + } + + @Override + public boolean hasNonterminal() { + return true; + } + @Override + public java.util.List getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(nonterminal), clone(parameters)); + } + + } + public boolean isPrecede() { + return false; + } + + static public class Precede extends Sym { + // Production: sig("Precede",[arg("org.rascalmpl.ast.Sym","match"),arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym match; + private final org.rascalmpl.ast.Sym symbol; + + public Precede(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym match, org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.match = match; + this.symbol = symbol; + } + + @Override + public boolean isPrecede() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymPrecede(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = match.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + match.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Precede)) { + return false; + } + Precede tmp = (Precede) o; + return true && tmp.match.equals(this.match) && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 743 + 751 * match.hashCode() + 241 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getMatch() { + return this.match; + } + + @Override + public boolean hasMatch() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(match), clone(symbol)); + } + + } + public boolean isSequence() { + return false; + } + + static public class Sequence extends Sym { + // Production: sig("Sequence",[arg("org.rascalmpl.ast.Sym","first"),arg("java.util.List\","sequence")],breakable=false) + + + private final org.rascalmpl.ast.Sym first; + private final java.util.List sequence; + + public Sequence(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym first, java.util.List sequence) { + super(src, node); + + this.first = first; + this.sequence = sequence; + } + + @Override + public boolean isSequence() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymSequence(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = first.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + first.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : sequence) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Sequence)) { + return false; + } + Sequence tmp = (Sequence) o; + return true && tmp.first.equals(this.first) && tmp.sequence.equals(this.sequence) ; + } + + @Override + public int hashCode() { + return 911 + 827 * first.hashCode() + 29 * sequence.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getFirst() { + return this.first; + } + + @Override + public boolean hasFirst() { + return true; + } + @Override + public java.util.List getSequence() { + return this.sequence; + } + + @Override + public boolean hasSequence() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(first), clone(sequence)); + } + + } + public boolean isStart() { + return false; + } + + static public class Start extends Sym { + // Production: sig("Start",[arg("org.rascalmpl.ast.Nonterminal","nonterminal")],breakable=false) + + + private final org.rascalmpl.ast.Nonterminal nonterminal; + + public Start(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Nonterminal nonterminal) { + super(src, node); + + this.nonterminal = nonterminal; + } + + @Override + public boolean isStart() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymStart(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = nonterminal.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + nonterminal.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Start)) { + return false; + } + Start tmp = (Start) o; + return true && tmp.nonterminal.equals(this.nonterminal) ; + } + + @Override + public int hashCode() { + return 947 + 883 * nonterminal.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Nonterminal getNonterminal() { + return this.nonterminal; + } + + @Override + public boolean hasNonterminal() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(nonterminal)); + } + + } + public boolean isStartOfLine() { + return false; + } + + static public class StartOfLine extends Sym { + // Production: sig("StartOfLine",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public StartOfLine(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isStartOfLine() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymStartOfLine(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof StartOfLine)) { + return false; + } + StartOfLine tmp = (StartOfLine) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 743 + 313 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isUnequal() { + return false; + } + + static public class Unequal extends Sym { + // Production: sig("Unequal",[arg("org.rascalmpl.ast.Sym","symbol"),arg("org.rascalmpl.ast.Sym","match")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + private final org.rascalmpl.ast.Sym match; + + public Unequal(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol, org.rascalmpl.ast.Sym match) { + super(src, node); + + this.symbol = symbol; + this.match = match; + } + + @Override + public boolean isUnequal() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSymUnequal(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = match.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + match.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Unequal)) { + return false; + } + Unequal tmp = (Unequal) o; + return true && tmp.symbol.equals(this.symbol) && tmp.match.equals(this.match) ; + } + + @Override + public int hashCode() { + return 607 + 727 * symbol.hashCode() + 883 * match.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getMatch() { + return this.match; + } + + @Override + public boolean hasMatch() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol), clone(match)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/SyntaxDefinition.java b/src/org/rascalmpl/ast/SyntaxDefinition.java new file mode 100644 index 00000000000..e5a16c10b5f --- /dev/null +++ b/src/org/rascalmpl/ast/SyntaxDefinition.java @@ -0,0 +1,471 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class SyntaxDefinition extends AbstractAST { + public SyntaxDefinition(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasProduction() { + return false; + } + + public org.rascalmpl.ast.Prod getProduction() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStart() { + return false; + } + + public org.rascalmpl.ast.Start getStart() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasDefined() { + return false; + } + + public org.rascalmpl.ast.Sym getDefined() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasVis() { + return false; + } + + public org.rascalmpl.ast.Visibility getVis() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isKeyword() { + return false; + } + + static public class Keyword extends SyntaxDefinition { + // Production: sig("Keyword",[arg("org.rascalmpl.ast.Sym","defined"),arg("org.rascalmpl.ast.Prod","production")],breakable=false) + + + private final org.rascalmpl.ast.Sym defined; + private final org.rascalmpl.ast.Prod production; + + public Keyword(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym defined, org.rascalmpl.ast.Prod production) { + super(src, node); + + this.defined = defined; + this.production = production; + } + + @Override + public boolean isKeyword() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSyntaxDefinitionKeyword(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = defined.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + defined.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = production.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + production.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Keyword)) { + return false; + } + Keyword tmp = (Keyword) o; + return true && tmp.defined.equals(this.defined) && tmp.production.equals(this.production) ; + } + + @Override + public int hashCode() { + return 617 + 233 * defined.hashCode() + 263 * production.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getDefined() { + return this.defined; + } + + @Override + public boolean hasDefined() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getProduction() { + return this.production; + } + + @Override + public boolean hasProduction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(defined), clone(production)); + } + + } + public boolean isLanguage() { + return false; + } + + static public class Language extends SyntaxDefinition { + // Production: sig("Language",[arg("org.rascalmpl.ast.Start","start"),arg("org.rascalmpl.ast.Sym","defined"),arg("org.rascalmpl.ast.Prod","production")],breakable=false) + + + private final org.rascalmpl.ast.Start start; + private final org.rascalmpl.ast.Sym defined; + private final org.rascalmpl.ast.Prod production; + + public Language(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Start start, org.rascalmpl.ast.Sym defined, org.rascalmpl.ast.Prod production) { + super(src, node); + + this.start = start; + this.defined = defined; + this.production = production; + } + + @Override + public boolean isLanguage() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSyntaxDefinitionLanguage(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = start.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + start.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = defined.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + defined.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = production.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + production.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Language)) { + return false; + } + Language tmp = (Language) o; + return true && tmp.start.equals(this.start) && tmp.defined.equals(this.defined) && tmp.production.equals(this.production) ; + } + + @Override + public int hashCode() { + return 163 + 683 * start.hashCode() + 661 * defined.hashCode() + 499 * production.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Start getStart() { + return this.start; + } + + @Override + public boolean hasStart() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getDefined() { + return this.defined; + } + + @Override + public boolean hasDefined() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getProduction() { + return this.production; + } + + @Override + public boolean hasProduction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(start), clone(defined), clone(production)); + } + + } + public boolean isLayout() { + return false; + } + + static public class Layout extends SyntaxDefinition { + // Production: sig("Layout",[arg("org.rascalmpl.ast.Visibility","vis"),arg("org.rascalmpl.ast.Sym","defined"),arg("org.rascalmpl.ast.Prod","production")],breakable=false) + + + private final org.rascalmpl.ast.Visibility vis; + private final org.rascalmpl.ast.Sym defined; + private final org.rascalmpl.ast.Prod production; + + public Layout(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Visibility vis, org.rascalmpl.ast.Sym defined, org.rascalmpl.ast.Prod production) { + super(src, node); + + this.vis = vis; + this.defined = defined; + this.production = production; + } + + @Override + public boolean isLayout() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSyntaxDefinitionLayout(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = vis.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + vis.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = defined.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + defined.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = production.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + production.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Layout)) { + return false; + } + Layout tmp = (Layout) o; + return true && tmp.vis.equals(this.vis) && tmp.defined.equals(this.defined) && tmp.production.equals(this.production) ; + } + + @Override + public int hashCode() { + return 769 + 163 * vis.hashCode() + 641 * defined.hashCode() + 313 * production.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Visibility getVis() { + return this.vis; + } + + @Override + public boolean hasVis() { + return true; + } + @Override + public org.rascalmpl.ast.Sym getDefined() { + return this.defined; + } + + @Override + public boolean hasDefined() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getProduction() { + return this.production; + } + + @Override + public boolean hasProduction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(vis), clone(defined), clone(production)); + } + + } + public boolean isLexical() { + return false; + } + + static public class Lexical extends SyntaxDefinition { + // Production: sig("Lexical",[arg("org.rascalmpl.ast.Sym","defined"),arg("org.rascalmpl.ast.Prod","production")],breakable=false) + + + private final org.rascalmpl.ast.Sym defined; + private final org.rascalmpl.ast.Prod production; + + public Lexical(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym defined, org.rascalmpl.ast.Prod production) { + super(src, node); + + this.defined = defined; + this.production = production; + } + + @Override + public boolean isLexical() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitSyntaxDefinitionLexical(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = defined.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + defined.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = production.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + production.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Lexical)) { + return false; + } + Lexical tmp = (Lexical) o; + return true && tmp.defined.equals(this.defined) && tmp.production.equals(this.production) ; + } + + @Override + public int hashCode() { + return 509 + 563 * defined.hashCode() + 149 * production.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getDefined() { + return this.defined; + } + + @Override + public boolean hasDefined() { + return true; + } + @Override + public org.rascalmpl.ast.Prod getProduction() { + return this.production; + } + + @Override + public boolean hasProduction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(defined), clone(production)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Tag.java b/src/org/rascalmpl/ast/Tag.java new file mode 100644 index 00000000000..b658316cc1e --- /dev/null +++ b/src/org/rascalmpl/ast/Tag.java @@ -0,0 +1,314 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Tag extends AbstractAST { + public Tag(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasExpression() { + return false; + } + + public org.rascalmpl.ast.Expression getExpression() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasContents() { + return false; + } + + public org.rascalmpl.ast.TagString getContents() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Tag { + // Production: sig("Default",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.TagString","contents")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.TagString contents; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.TagString contents) { + super(src, node); + + this.name = name; + this.contents = contents; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTagDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = contents.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + contents.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.name.equals(this.name) && tmp.contents.equals(this.contents) ; + } + + @Override + public int hashCode() { + return 431 + 67 * name.hashCode() + 19 * contents.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.TagString getContents() { + return this.contents; + } + + @Override + public boolean hasContents() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(contents)); + } + + } + public boolean isEmpty() { + return false; + } + + static public class Empty extends Tag { + // Production: sig("Empty",[arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + + public Empty(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTagEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 181 + 599 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } + public boolean isExpression() { + return false; + } + + static public class Expression extends Tag { + // Production: sig("Expression",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","expression")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression expression; + + public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression expression) { + super(src, node); + + this.name = name; + this.expression = expression; + } + + @Override + public boolean isExpression() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTagExpression(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = expression.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + expression.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Expression)) { + return false; + } + Expression tmp = (Expression) o; + return true && tmp.name.equals(this.name) && tmp.expression.equals(this.expression) ; + } + + @Override + public int hashCode() { + return 101 + 421 * name.hashCode() + 277 * expression.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getExpression() { + return this.expression; + } + + @Override + public boolean hasExpression() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(expression)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/TagString.java b/src/org/rascalmpl/ast/TagString.java new file mode 100644 index 00000000000..ef1899a6a21 --- /dev/null +++ b/src/org/rascalmpl/ast/TagString.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class TagString extends AbstractAST { + public TagString(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends TagString { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitTagStringLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Tags.java b/src/org/rascalmpl/ast/Tags.java new file mode 100644 index 00000000000..7ee4dacb2a9 --- /dev/null +++ b/src/org/rascalmpl/ast/Tags.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Tags extends AbstractAST { + public Tags(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasTags() { + return false; + } + + public java.util.List getTags() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Tags { + // Production: sig("Default",[arg("java.util.List\","tags")],breakable=false) + + + private final java.util.List tags; + + public Default(ISourceLocation src, IConstructor node , java.util.List tags) { + super(src, node); + + this.tags = tags; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTagsDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + for (AbstractAST $elem : tags) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.tags.equals(this.tags) ; + } + + @Override + public int hashCode() { + return 487 + 797 * tags.hashCode() ; + } + + + @Override + public java.util.List getTags() { + return this.tags; + } + + @Override + public boolean hasTags() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(tags)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Target.java b/src/org/rascalmpl/ast/Target.java new file mode 100644 index 00000000000..a84492f3059 --- /dev/null +++ b/src/org/rascalmpl/ast/Target.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Target extends AbstractAST { + public Target(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isEmpty() { + return false; + } + + static public class Empty extends Target { + // Production: sig("Empty",[],breakable=false) + + + + public Empty(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTargetEmpty(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Empty)) { + return false; + } + Empty tmp = (Empty) o; + return true ; + } + + @Override + public int hashCode() { + return 787 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isLabeled() { + return false; + } + + static public class Labeled extends Target { + // Production: sig("Labeled",[arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + + public Labeled(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isLabeled() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTargetLabeled(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Labeled)) { + return false; + } + Labeled tmp = (Labeled) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 397 + 191 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/TimePartNoTZ.java b/src/org/rascalmpl/ast/TimePartNoTZ.java new file mode 100644 index 00000000000..18e43c9bbf5 --- /dev/null +++ b/src/org/rascalmpl/ast/TimePartNoTZ.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class TimePartNoTZ extends AbstractAST { + public TimePartNoTZ(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends TimePartNoTZ { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitTimePartNoTZLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/TimeZonePart.java b/src/org/rascalmpl/ast/TimeZonePart.java new file mode 100644 index 00000000000..814c39ce8c7 --- /dev/null +++ b/src/org/rascalmpl/ast/TimeZonePart.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class TimeZonePart extends AbstractAST { + public TimeZonePart(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends TimeZonePart { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitTimeZonePartLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Toplevel.java b/src/org/rascalmpl/ast/Toplevel.java new file mode 100644 index 00000000000..80e0db16d93 --- /dev/null +++ b/src/org/rascalmpl/ast/Toplevel.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Toplevel extends AbstractAST { + public Toplevel(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasDeclaration() { + return false; + } + + public org.rascalmpl.ast.Declaration getDeclaration() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isGivenVisibility() { + return false; + } + + static public class GivenVisibility extends Toplevel { + // Production: sig("GivenVisibility",[arg("org.rascalmpl.ast.Declaration","declaration")],breakable=false) + + + private final org.rascalmpl.ast.Declaration declaration; + + public GivenVisibility(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declaration declaration) { + super(src, node); + + this.declaration = declaration; + } + + @Override + public boolean isGivenVisibility() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitToplevelGivenVisibility(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = declaration.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + declaration.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GivenVisibility)) { + return false; + } + GivenVisibility tmp = (GivenVisibility) o; + return true && tmp.declaration.equals(this.declaration) ; + } + + @Override + public int hashCode() { + return 977 + 173 * declaration.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Declaration getDeclaration() { + return this.declaration; + } + + @Override + public boolean hasDeclaration() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(declaration)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Type.java b/src/org/rascalmpl/ast/Type.java new file mode 100644 index 00000000000..c7719d2047b --- /dev/null +++ b/src/org/rascalmpl/ast/Type.java @@ -0,0 +1,681 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Type extends AbstractAST { + public Type(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasBasic() { + return false; + } + + public org.rascalmpl.ast.BasicType getBasic() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSelector() { + return false; + } + + public org.rascalmpl.ast.DataTypeSelector getSelector() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasFunction() { + return false; + } + + public org.rascalmpl.ast.FunctionType getFunction() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStructured() { + return false; + } + + public org.rascalmpl.ast.StructuredType getStructured() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSymbol() { + return false; + } + + public org.rascalmpl.ast.Sym getSymbol() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasTypeVar() { + return false; + } + + public org.rascalmpl.ast.TypeVar getTypeVar() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasUser() { + return false; + } + + public org.rascalmpl.ast.UserType getUser() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isBasic() { + return false; + } + + static public class Basic extends Type { + // Production: sig("Basic",[arg("org.rascalmpl.ast.BasicType","basic")],breakable=false) + + + private final org.rascalmpl.ast.BasicType basic; + + public Basic(ISourceLocation src, IConstructor node , org.rascalmpl.ast.BasicType basic) { + super(src, node); + + this.basic = basic; + } + + @Override + public boolean isBasic() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeBasic(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = basic.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + basic.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Basic)) { + return false; + } + Basic tmp = (Basic) o; + return true && tmp.basic.equals(this.basic) ; + } + + @Override + public int hashCode() { + return 541 + 491 * basic.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.BasicType getBasic() { + return this.basic; + } + + @Override + public boolean hasBasic() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(basic)); + } + + } + public boolean isBracket() { + return false; + } + + static public class Bracket extends Type { + // Production: sig("Bracket",[arg("org.rascalmpl.ast.Type","type")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + + public Bracket(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type) { + super(src, node); + + this.type = type; + } + + @Override + public boolean isBracket() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeBracket(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bracket)) { + return false; + } + Bracket tmp = (Bracket) o; + return true && tmp.type.equals(this.type) ; + } + + @Override + public int hashCode() { + return 331 + 167 * type.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type)); + } + + } + public boolean isFunction() { + return false; + } + + static public class Function extends Type { + // Production: sig("Function",[arg("org.rascalmpl.ast.FunctionType","function")],breakable=false) + + + private final org.rascalmpl.ast.FunctionType function; + + public Function(ISourceLocation src, IConstructor node , org.rascalmpl.ast.FunctionType function) { + super(src, node); + + this.function = function; + } + + @Override + public boolean isFunction() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeFunction(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = function.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + function.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Function)) { + return false; + } + Function tmp = (Function) o; + return true && tmp.function.equals(this.function) ; + } + + @Override + public int hashCode() { + return 809 + 109 * function.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.FunctionType getFunction() { + return this.function; + } + + @Override + public boolean hasFunction() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(function)); + } + + } + public boolean isSelector() { + return false; + } + + static public class Selector extends Type { + // Production: sig("Selector",[arg("org.rascalmpl.ast.DataTypeSelector","selector")],breakable=false) + + + private final org.rascalmpl.ast.DataTypeSelector selector; + + public Selector(ISourceLocation src, IConstructor node , org.rascalmpl.ast.DataTypeSelector selector) { + super(src, node); + + this.selector = selector; + } + + @Override + public boolean isSelector() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeSelector(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = selector.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + selector.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Selector)) { + return false; + } + Selector tmp = (Selector) o; + return true && tmp.selector.equals(this.selector) ; + } + + @Override + public int hashCode() { + return 373 + 449 * selector.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.DataTypeSelector getSelector() { + return this.selector; + } + + @Override + public boolean hasSelector() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(selector)); + } + + } + public boolean isStructured() { + return false; + } + + static public class Structured extends Type { + // Production: sig("Structured",[arg("org.rascalmpl.ast.StructuredType","structured")],breakable=false) + + + private final org.rascalmpl.ast.StructuredType structured; + + public Structured(ISourceLocation src, IConstructor node , org.rascalmpl.ast.StructuredType structured) { + super(src, node); + + this.structured = structured; + } + + @Override + public boolean isStructured() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeStructured(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = structured.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + structured.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Structured)) { + return false; + } + Structured tmp = (Structured) o; + return true && tmp.structured.equals(this.structured) ; + } + + @Override + public int hashCode() { + return 571 + 467 * structured.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.StructuredType getStructured() { + return this.structured; + } + + @Override + public boolean hasStructured() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(structured)); + } + + } + public boolean isSymbol() { + return false; + } + + static public class Symbol extends Type { + // Production: sig("Symbol",[arg("org.rascalmpl.ast.Sym","symbol")],breakable=false) + + + private final org.rascalmpl.ast.Sym symbol; + + public Symbol(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Sym symbol) { + super(src, node); + + this.symbol = symbol; + } + + @Override + public boolean isSymbol() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeSymbol(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = symbol.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + symbol.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Symbol)) { + return false; + } + Symbol tmp = (Symbol) o; + return true && tmp.symbol.equals(this.symbol) ; + } + + @Override + public int hashCode() { + return 691 + 701 * symbol.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Sym getSymbol() { + return this.symbol; + } + + @Override + public boolean hasSymbol() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(symbol)); + } + + } + public boolean isUser() { + return false; + } + + static public class User extends Type { + // Production: sig("User",[arg("org.rascalmpl.ast.UserType","user")],breakable=false) + + + private final org.rascalmpl.ast.UserType user; + + public User(ISourceLocation src, IConstructor node , org.rascalmpl.ast.UserType user) { + super(src, node); + + this.user = user; + } + + @Override + public boolean isUser() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeUser(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = user.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + user.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof User)) { + return false; + } + User tmp = (User) o; + return true && tmp.user.equals(this.user) ; + } + + @Override + public int hashCode() { + return 19 + 137 * user.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.UserType getUser() { + return this.user; + } + + @Override + public boolean hasUser() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(user)); + } + + } + public boolean isVariable() { + return false; + } + + static public class Variable extends Type { + // Production: sig("Variable",[arg("org.rascalmpl.ast.TypeVar","typeVar")],breakable=false) + + + private final org.rascalmpl.ast.TypeVar typeVar; + + public Variable(ISourceLocation src, IConstructor node , org.rascalmpl.ast.TypeVar typeVar) { + super(src, node); + + this.typeVar = typeVar; + } + + @Override + public boolean isVariable() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeVariable(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = typeVar.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + typeVar.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Variable)) { + return false; + } + Variable tmp = (Variable) o; + return true && tmp.typeVar.equals(this.typeVar) ; + } + + @Override + public int hashCode() { + return 907 + 41 * typeVar.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.TypeVar getTypeVar() { + return this.typeVar; + } + + @Override + public boolean hasTypeVar() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(typeVar)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/TypeArg.java b/src/org/rascalmpl/ast/TypeArg.java new file mode 100644 index 00000000000..7e7739e6839 --- /dev/null +++ b/src/org/rascalmpl/ast/TypeArg.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class TypeArg extends AbstractAST { + public TypeArg(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasType() { + return false; + } + + public org.rascalmpl.ast.Type getType() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends TypeArg { + // Production: sig("Default",[arg("org.rascalmpl.ast.Type","type")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + + public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type) { + super(src, node); + + this.type = type; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeArgDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true && tmp.type.equals(this.type) ; + } + + @Override + public int hashCode() { + return 59 + 823 * type.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type)); + } + + } + public boolean isNamed() { + return false; + } + + static public class Named extends TypeArg { + // Production: sig("Named",[arg("org.rascalmpl.ast.Type","type"),arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Type type; + private final org.rascalmpl.ast.Name name; + + public Named(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Type type, org.rascalmpl.ast.Name name) { + super(src, node); + + this.type = type; + this.name = name; + } + + @Override + public boolean isNamed() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeArgNamed(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = type.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + type.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Named)) { + return false; + } + Named tmp = (Named) o; + return true && tmp.type.equals(this.type) && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 139 + 293 * type.hashCode() + 773 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Type getType() { + return this.type; + } + + @Override + public boolean hasType() { + return true; + } + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(type), clone(name)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/TypeVar.java b/src/org/rascalmpl/ast/TypeVar.java new file mode 100644 index 00000000000..fe9ddcbbe12 --- /dev/null +++ b/src/org/rascalmpl/ast/TypeVar.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class TypeVar extends AbstractAST { + public TypeVar(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasBound() { + return false; + } + + public org.rascalmpl.ast.Type getBound() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isBounded() { + return false; + } + + static public class Bounded extends TypeVar { + // Production: sig("Bounded",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Type","bound")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Type bound; + + public Bounded(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.Type bound) { + super(src, node); + + this.name = name; + this.bound = bound; + } + + @Override + public boolean isBounded() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeVarBounded(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = bound.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + bound.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Bounded)) { + return false; + } + Bounded tmp = (Bounded) o; + return true && tmp.name.equals(this.name) && tmp.bound.equals(this.bound) ; + } + + @Override + public int hashCode() { + return 293 + 421 * name.hashCode() + 467 * bound.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Type getBound() { + return this.bound; + } + + @Override + public boolean hasBound() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(bound)); + } + + } + public boolean isFree() { + return false; + } + + static public class Free extends TypeVar { + // Production: sig("Free",[arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + + public Free(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isFree() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitTypeVarFree(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Free)) { + return false; + } + Free tmp = (Free) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 181 + 383 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/URLChars.java b/src/org/rascalmpl/ast/URLChars.java new file mode 100644 index 00000000000..ab016bf9a01 --- /dev/null +++ b/src/org/rascalmpl/ast/URLChars.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class URLChars extends AbstractAST { + public URLChars(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends URLChars { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitURLCharsLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/UnicodeEscape.java b/src/org/rascalmpl/ast/UnicodeEscape.java new file mode 100644 index 00000000000..21170244124 --- /dev/null +++ b/src/org/rascalmpl/ast/UnicodeEscape.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class UnicodeEscape extends AbstractAST { + public UnicodeEscape(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + static public class Lexical extends UnicodeEscape { + private final java.lang.String string; + public Lexical(ISourceLocation src, IConstructor node, java.lang.String string) { + super(src, node); + this.string = string; + } + public java.lang.String getString() { + return string; + } + + @Override + public int hashCode() { + return string.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof Lexical && ((Lexical) o).string.equals(string); + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null, string); + } + + @Override + public AbstractAST findNode(int offset) { + if (src.getOffset() <= offset && offset < src.getOffset() + src.getLength()) { + return this; + } + return null; + } + + public java.lang.String toString() { + return string; + } + public T accept(IASTVisitor v) { + return v.visitUnicodeEscapeLexical(this); + } +} + + +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/UserType.java b/src/org/rascalmpl/ast/UserType.java new file mode 100644 index 00000000000..4412e457c6d --- /dev/null +++ b/src/org/rascalmpl/ast/UserType.java @@ -0,0 +1,216 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class UserType extends AbstractAST { + public UserType(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasParameters() { + return false; + } + + public java.util.List getParameters() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.QualifiedName getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isName() { + return false; + } + + static public class Name extends UserType { + // Production: sig("Name",[arg("org.rascalmpl.ast.QualifiedName","name")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + + public Name(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isName() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitUserTypeName(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Name)) { + return false; + } + Name tmp = (Name) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 263 + 463 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } + public boolean isParametric() { + return false; + } + + static public class Parametric extends UserType { + // Production: sig("Parametric",[arg("org.rascalmpl.ast.QualifiedName","name"),arg("java.util.List\","parameters")],breakable=false) + + + private final org.rascalmpl.ast.QualifiedName name; + private final java.util.List parameters; + + public Parametric(ISourceLocation src, IConstructor node , org.rascalmpl.ast.QualifiedName name, java.util.List parameters) { + super(src, node); + + this.name = name; + this.parameters = parameters; + } + + @Override + public boolean isParametric() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitUserTypeParametric(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : parameters) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Parametric)) { + return false; + } + Parametric tmp = (Parametric) o; + return true && tmp.name.equals(this.name) && tmp.parameters.equals(this.parameters) ; + } + + @Override + public int hashCode() { + return 223 + 139 * name.hashCode() + 347 * parameters.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.QualifiedName getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getParameters() { + return this.parameters; + } + + @Override + public boolean hasParameters() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(parameters)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Variable.java b/src/org/rascalmpl/ast/Variable.java new file mode 100644 index 00000000000..cd729995ec5 --- /dev/null +++ b/src/org/rascalmpl/ast/Variable.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Variable extends AbstractAST { + public Variable(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasInitial() { + return false; + } + + public org.rascalmpl.ast.Expression getInitial() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isInitialized() { + return false; + } + + static public class Initialized extends Variable { + // Production: sig("Initialized",[arg("org.rascalmpl.ast.Name","name"),arg("org.rascalmpl.ast.Expression","initial")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final org.rascalmpl.ast.Expression initial; + + public Initialized(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, org.rascalmpl.ast.Expression initial) { + super(src, node); + + this.name = name; + this.initial = initial; + } + + @Override + public boolean isInitialized() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVariableInitialized(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = initial.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + initial.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Initialized)) { + return false; + } + Initialized tmp = (Initialized) o; + return true && tmp.name.equals(this.name) && tmp.initial.equals(this.initial) ; + } + + @Override + public int hashCode() { + return 557 + 131 * name.hashCode() + 797 * initial.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getInitial() { + return this.initial; + } + + @Override + public boolean hasInitial() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(initial)); + } + + } + public boolean isUnInitialized() { + return false; + } + + static public class UnInitialized extends Variable { + // Production: sig("UnInitialized",[arg("org.rascalmpl.ast.Name","name")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + + public UnInitialized(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name) { + super(src, node); + + this.name = name; + } + + @Override + public boolean isUnInitialized() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVariableUnInitialized(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof UnInitialized)) { + return false; + } + UnInitialized tmp = (UnInitialized) o; + return true && tmp.name.equals(this.name) ; + } + + @Override + public int hashCode() { + return 149 + 877 * name.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Variant.java b/src/org/rascalmpl/ast/Variant.java new file mode 100644 index 00000000000..81f794323ca --- /dev/null +++ b/src/org/rascalmpl/ast/Variant.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Variant extends AbstractAST { + public Variant(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasArguments() { + return false; + } + + public java.util.List getArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasKeywordArguments() { + return false; + } + + public org.rascalmpl.ast.KeywordFormals getKeywordArguments() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasName() { + return false; + } + + public org.rascalmpl.ast.Name getName() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isNAryConstructor() { + return false; + } + + static public class NAryConstructor extends Variant { + // Production: sig("NAryConstructor",[arg("org.rascalmpl.ast.Name","name"),arg("java.util.List\","arguments"),arg("org.rascalmpl.ast.KeywordFormals","keywordArguments")],breakable=false) + + + private final org.rascalmpl.ast.Name name; + private final java.util.List arguments; + private final org.rascalmpl.ast.KeywordFormals keywordArguments; + + public NAryConstructor(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Name name, java.util.List arguments, org.rascalmpl.ast.KeywordFormals keywordArguments) { + super(src, node); + + this.name = name; + this.arguments = arguments; + this.keywordArguments = keywordArguments; + } + + @Override + public boolean isNAryConstructor() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVariantNAryConstructor(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = name.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + name.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : arguments) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + $l = keywordArguments.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + keywordArguments.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof NAryConstructor)) { + return false; + } + NAryConstructor tmp = (NAryConstructor) o; + return true && tmp.name.equals(this.name) && tmp.arguments.equals(this.arguments) && tmp.keywordArguments.equals(this.keywordArguments) ; + } + + @Override + public int hashCode() { + return 401 + 787 * name.hashCode() + 239 * arguments.hashCode() + 997 * keywordArguments.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Name getName() { + return this.name; + } + + @Override + public boolean hasName() { + return true; + } + @Override + public java.util.List getArguments() { + return this.arguments; + } + + @Override + public boolean hasArguments() { + return true; + } + @Override + public org.rascalmpl.ast.KeywordFormals getKeywordArguments() { + return this.keywordArguments; + } + + @Override + public boolean hasKeywordArguments() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(name), clone(arguments), clone(keywordArguments)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Visibility.java b/src/org/rascalmpl/ast/Visibility.java new file mode 100644 index 00000000000..153a25a5b71 --- /dev/null +++ b/src/org/rascalmpl/ast/Visibility.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Visibility extends AbstractAST { + public Visibility(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + + + + + public boolean isDefault() { + return false; + } + + static public class Default extends Visibility { + // Production: sig("Default",[],breakable=false) + + + + public Default(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVisibilityDefault(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Default)) { + return false; + } + Default tmp = (Default) o; + return true ; + } + + @Override + public int hashCode() { + return 641 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isPrivate() { + return false; + } + + static public class Private extends Visibility { + // Production: sig("Private",[],breakable=false) + + + + public Private(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isPrivate() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVisibilityPrivate(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Private)) { + return false; + } + Private tmp = (Private) o; + return true ; + } + + @Override + public int hashCode() { + return 701 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } + public boolean isPublic() { + return false; + } + + static public class Public extends Visibility { + // Production: sig("Public",[],breakable=false) + + + + public Public(ISourceLocation src, IConstructor node ) { + super(src, node); + + } + + @Override + public boolean isPublic() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVisibilityPublic(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Public)) { + return false; + } + Public tmp = (Public) o; + return true ; + } + + @Override + public int hashCode() { + return 13 ; + } + + + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null ); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/ast/Visit.java b/src/org/rascalmpl/ast/Visit.java new file mode 100644 index 00000000000..31ee6b548a6 --- /dev/null +++ b/src/org/rascalmpl/ast/Visit.java @@ -0,0 +1,263 @@ +/******************************************************************************* + * Copyright (c) 2009-2015 CWI + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI + * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl + * * Paul Klint - Paul.Klint@cwi.nl - CWI + * * Mark Hills - Mark.Hills@cwi.nl (CWI) + * * Arnold Lankamp - Arnold.Lankamp@cwi.nl + * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI + *******************************************************************************/ +package org.rascalmpl.ast; + + +import io.usethesource.vallang.IConstructor; +import io.usethesource.vallang.ISourceLocation; + +@SuppressWarnings(value = {"unused"}) +public abstract class Visit extends AbstractAST { + public Visit(ISourceLocation src, IConstructor node) { + super(src /* we forget node on purpose */); + } + + + public boolean hasCases() { + return false; + } + + public java.util.List getCases() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasSubject() { + return false; + } + + public org.rascalmpl.ast.Expression getSubject() { + throw new UnsupportedOperationException(this.src.toString()); + } + public boolean hasStrategy() { + return false; + } + + public org.rascalmpl.ast.Strategy getStrategy() { + throw new UnsupportedOperationException(this.src.toString()); + } + + + + + public boolean isDefaultStrategy() { + return false; + } + + static public class DefaultStrategy extends Visit { + // Production: sig("DefaultStrategy",[arg("org.rascalmpl.ast.Expression","subject"),arg("java.util.List\","cases")],breakable=false) + + + private final org.rascalmpl.ast.Expression subject; + private final java.util.List cases; + + public DefaultStrategy(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression subject, java.util.List cases) { + super(src, node); + + this.subject = subject; + this.cases = cases; + } + + @Override + public boolean isDefaultStrategy() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVisitDefaultStrategy(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = subject.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + subject.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : cases) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof DefaultStrategy)) { + return false; + } + DefaultStrategy tmp = (DefaultStrategy) o; + return true && tmp.subject.equals(this.subject) && tmp.cases.equals(this.cases) ; + } + + @Override + public int hashCode() { + return 179 + 797 * subject.hashCode() + 101 * cases.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Expression getSubject() { + return this.subject; + } + + @Override + public boolean hasSubject() { + return true; + } + @Override + public java.util.List getCases() { + return this.cases; + } + + @Override + public boolean hasCases() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(subject), clone(cases)); + } + + } + public boolean isGivenStrategy() { + return false; + } + + static public class GivenStrategy extends Visit { + // Production: sig("GivenStrategy",[arg("org.rascalmpl.ast.Strategy","strategy"),arg("org.rascalmpl.ast.Expression","subject"),arg("java.util.List\","cases")],breakable=false) + + + private final org.rascalmpl.ast.Strategy strategy; + private final org.rascalmpl.ast.Expression subject; + private final java.util.List cases; + + public GivenStrategy(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Strategy strategy, org.rascalmpl.ast.Expression subject, java.util.List cases) { + super(src, node); + + this.strategy = strategy; + this.subject = subject; + this.cases = cases; + } + + @Override + public boolean isGivenStrategy() { + return true; + } + + @Override + public T accept(IASTVisitor visitor) { + return visitor.visitVisitGivenStrategy(this); + } + + @Override + protected void addForLineNumber(int $line, java.util.List $result) { + if (getLocation().getBeginLine() == $line) { + $result.add(this); + } + ISourceLocation $l; + + $l = strategy.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + strategy.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + $l = subject.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + subject.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + for (AbstractAST $elem : cases) { + $l = $elem.getLocation(); + if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { + $elem.addForLineNumber($line, $result); + } + if ($l.getBeginLine() > $line) { + return; + } + + } + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof GivenStrategy)) { + return false; + } + GivenStrategy tmp = (GivenStrategy) o; + return true && tmp.strategy.equals(this.strategy) && tmp.subject.equals(this.subject) && tmp.cases.equals(this.cases) ; + } + + @Override + public int hashCode() { + return 17 + 797 * strategy.hashCode() + 499 * subject.hashCode() + 347 * cases.hashCode() ; + } + + + @Override + public org.rascalmpl.ast.Strategy getStrategy() { + return this.strategy; + } + + @Override + public boolean hasStrategy() { + return true; + } + @Override + public org.rascalmpl.ast.Expression getSubject() { + return this.subject; + } + + @Override + public boolean hasSubject() { + return true; + } + @Override + public java.util.List getCases() { + return this.cases; + } + + @Override + public boolean hasCases() { + return true; + } + + @Override + public Object clone() { + return newInstance(getClass(), src, (IConstructor) null , clone(strategy), clone(subject), clone(cases)); + } + + } +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/BreakingChanges.rsc b/src/org/rascalmpl/compiler/BreakingChanges.rsc new file mode 100644 index 00000000000..f441e4cdfea --- /dev/null +++ b/src/org/rascalmpl/compiler/BreakingChanges.rsc @@ -0,0 +1,83 @@ +module BreakingChanges + +import IO; +import Map; +import ValueIO; +import Location; +import Set; +import String; +import util::FileSystem; +import lang::rascalcore::check::RascalConfig; +import analysis::typepal::TModel; + +map[loc,loc] breakingDiffs(TModel old, TModel new){ + missing = domain(old.logical2physical) - domain(new.logical2physical); + return domainR(old.logical2physical, missing); +} + +set[loc] getTPLs(loc repo) + = find(repo, "tpl"); + +bool requireDetails(str path, set[str] details) + = !isEmpty(details) && any(d <- details, contains(path, d)); + +set[loc] similar(loc d, TModel new){ + dpath = d.path; + n = findLast(dpath, "$"); + if(n >=0){ + dpath = dpath[..n]; + } + found = {}; + for(x <- new.logical2physical){ + if(startsWith(x.path, dpath)){ + found += x; + } + } + return found; +} +void reportDiffs(map[loc,loc] diffs, TModel old, TModel new){ + for(d <- diffs){ + println("old : "); + for(s <- similar(d, new)){ + println("new : "); + } + } +} +void breaking(loc old, loc new, set[str] details = {}){ + oldTPLs = getTPLs(old); oldRelTPLs = {relativize(old, tpl) | tpl <- oldTPLs}; + newTPLs = getTPLs(new); newRelTPLs = {relativize(new, tpl) | tpl <- newTPLs}; + set[str] removed = {}; + nchanges = 0; + for(oldRelTPL <- oldRelTPLs){ + oldPath = oldRelTPL.path; + tmOld = readBinaryValueFile(#TModel, old + oldPath); + if(exists(new + oldPath)){ + tmNew = readBinaryValueFile(#TModel, new + oldPath); + b = breakingDiffs(tmOld, tmNew); + if(!isEmpty(b)){ + nchanges += size(b); + println("- changes"); + if(requireDetails(oldPath, details)){ + reportDiffs(b, tmOld, tmNew); + } + } + } else { + removed += oldPath; + println("- was removed"); + } + } + println("\nSUMMARY + ' Old: , tpls, + ' New: , tpls + ' Files in Old not in New: + ' <}> + ' New files in New: + ' <}> + ' Breaking changes: "); +} + +void main(loc old = |mvn://org.rascalmpl--rascal--0.40.17|, + loc new = |mvn://org.rascalmpl--rascal--0.41.0-RC54|, + set[str] details = {"Content"}){ + breaking(old, new, details = details); +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/CheckTestSources.rsc b/src/org/rascalmpl/compiler/CheckTestSources.rsc index 0afd0d560e7..9fcd3de8496 100644 --- a/src/org/rascalmpl/compiler/CheckTestSources.rsc +++ b/src/org/rascalmpl/compiler/CheckTestSources.rsc @@ -36,6 +36,7 @@ import util::FileSystem; import util::Benchmark; import lang::rascalcore::compile::util::Names; import lang::rascalcore::check::RascalConfig; +import lang::rascalcore::check::TestConfigs; void main() = checkTestSources([]); @@ -61,22 +62,22 @@ void checkTestSources(list[str] cmdLineArgs) { total = 0; list[str] modulesToCheck = []; - + pcfg = getAllSrcREPOPathConfig(keep=true); if("all" in cmdLineArgs){ - modulesToCheck = getRascalModules(|std:///|, genCompilerConfig.typepalPathConfig); + modulesToCheck = getRascalModules(REPO + "rascal/src/org/rascalmpl/library", pcfg); } else { testFolders = [ //|std:///lang/rascal/tests|, //REPO + "/rascal-core/lang/rascalcore/check::tests", REPO + "/typepal/src/" ]; - modulesToCheck = [ *getRascalModules(testFolder, genCompilerConfig.typepalPathConfig) + modulesToCheck = [ *getRascalModules(testFolder, pcfg) | testFolder <- testFolders ]; } - ignored = ["lang::rascal::tests::concrete::Patterns3" // takes too long + ignoredModules = ["lang::rascal::tests::concrete::Patterns3" // takes too long ]; - modulesToCheck -= ignored; + modulesToCheck -= ignoredModules; list[str] exceptions = []; int n = size(modulesToCheck); @@ -91,7 +92,7 @@ void checkTestSources(list[str] cmdLineArgs) { } println("Checked test modules"); println(" failed to check: "); - if(!isEmpty(ignored)) { println("Ignored: "); } + if(!isEmpty(ignoredModules)) { println("Ignored: "); } secs = total/1000000000; println("Time: seconds"); } diff --git a/src/org/rascalmpl/compiler/CompileTestSources.rsc b/src/org/rascalmpl/compiler/CompileTestSources.rsc index 3a5bd5ee2ef..5ee3f9e6f05 100644 --- a/src/org/rascalmpl/compiler/CompileTestSources.rsc +++ b/src/org/rascalmpl/compiler/CompileTestSources.rsc @@ -40,12 +40,13 @@ import lang::rascalcore::compile::Compile; import util::FileSystem; import util::Benchmark; import lang::rascalcore::compile::util::Names; +import lang::rascalcore::check::TestConfigs; -loc REPO = |file:///Users/paulklint/git/|; +loc GIT_REPO = |file:///Users/paulklint/git/|; -PathConfig manualTestConfig= pathConfig(bin= REPO + "generated-sources/target/classes", - generatedSources = REPO + "generated-sources/target/generated-sources", - resources = REPO + "generated-sources/target/classes" //|project://rascal-core/target/generated-test-resources| +PathConfig manualTestConfig= pathConfig(bin= GIT_REPO + "generated-sources/target/classes", + generatedSources = GIT_REPO + "generated-sources/target/generated-sources", + generatedResources = GIT_REPO + "generated-sources/target/classes" //|project://rascal-core/target/generated-test-resources| ); void main() = compileTestSources(manualTestConfig); @@ -150,9 +151,9 @@ void compileTestSources(PathConfig pcfg) { | loc file <- find(testFolder, "rsc") // all Rascal source files ]; - ignored = ["lang::rascal::tests::concrete::Patterns3" // takes too long + ignoredModules = ["lang::rascal::tests::concrete::Patterns3" // takes too long ]; - testModules -= ignored; + testModules -= ignoredModules; println("Compiling test modules:"); println(testModules); @@ -169,7 +170,7 @@ void compileTestSources(PathConfig pcfg) { } println("Compiled test modules"); println(" failed to compile: "); - if(!isEmpty(ignored)) { println("Ignored: "); } + if(!isEmpty(ignoredModules)) { println("Ignored: "); } secs = total/1000000000; println("Time: seconds"); } diff --git a/src/org/rascalmpl/compiler/GenerateTestSources.rsc b/src/org/rascalmpl/compiler/GenerateTestSources.rsc index 414d5834403..dbe705d66ff 100644 --- a/src/org/rascalmpl/compiler/GenerateTestSources.rsc +++ b/src/org/rascalmpl/compiler/GenerateTestSources.rsc @@ -38,6 +38,7 @@ import util::Monitor; import util::Benchmark; import lang::rascalcore::compile::util::Names; import util::SystemAPI; +import lang::rascalcore::check::TestConfigs; // if cmdLineArgs contains "all", then all files in the rascal project are used (~400 files) // otherwise only standard library and test files (~200 files) @@ -45,10 +46,10 @@ void main(list[str] cmdLineArgs) = generateTestSources(cmdLineArgs); void main() = main([]); -loc REPO = |file:///Users/paulklint/git/|; +loc GIT_REPO = |file:///Users/paulklint/git/|; -list[str] getRascalModules(loc rootFolder) - = [ replaceAll(file[extension=""].path[1..], "/", "::") +list[str] getRascalModules(loc rootFolder, PathConfig pcfg) + = [ getModuleName(file, pcfg) //replaceAll(file[extension=""].path[1..], "/", "::") | loc file <- find(rootFolder, "rsc") ]; @@ -58,57 +59,64 @@ void generateTestSources(list[str] cmdLineArgs) { return; } - genCompilerConfig = getAllSrcCompilerConfig()[logPathConfig=false]; + pcfg = getAllSrcREPOPathConfig(keep=true); + genCompilerConfig = getAllSrcREPOCompilerConfig(pcfg, keep=true); map[str,int] durations = (); - modulesToCompile = []; + list[str] modulesToCompile = []; if("all" in cmdLineArgs){ - modulesToCompile = getRascalModules(|std:///|); + modulesToCompile = getRascalModules(GIT_REPO + "rascal/src/org/rascalmpl/library", pcfg); } else { - testFolders = [ |std:///lang/rascal/tests|, - //REPO + "/rascal-core/lang/rascalcore/check::tests" - REPO + "/typepal/src/" + testFolders = [ GIT_REPO + "rascal/src/org/rascalmpl/library/lang/rascal/tests" + , GIT_REPO + "rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests" + , GIT_REPO + "rascal/src/org/rascalmpl/library/lang/rascalcore/agrammar/tests" + // , GIT_REPO + "rascal/src/org/rascalmpl/compiler/lang/rascalcore/check/tests" ]; - modulesToCompile = [ *getRascalModules(testFolder) + modulesToCompile = [ *getRascalModules(testFolder, pcfg) | testFolder <- testFolders ]; } - ignored = ["lang::rascal::tests::concrete::Patterns3", - "lang::rascal::syntax::tests::ExpressionGrammars" - ]; - modulesToCompile -= ignored; + ignoredModules = ["lang::rascal::tests::concrete::Patterns3", + "lang::rascal::syntax::tests::ExpressionGrammars", + "lang::sdf2::util::SDF2Grammar", + "lang::sdf2::util::Importer" + ]; + modulesToCompile -= ignoredModules; list[str] exceptions = []; int n = size(modulesToCompile); for (i <- index(modulesToCompile)) { m = modulesToCompile[i]; println("Compiling module [/]"); - e = safeCompile(m, genCompilerConfig, (int d) { durations[m] = d; }); + e = safeCompile(m, genCompilerConfig, void (int d) { durations[m] = d; }); if(!isEmpty(e)){ exceptions += e; } } println("Compiled modules"); - println(" failed to compile: "); - if(!isEmpty(ignored)) { println("Ignored: "); } + println(" failed to compile:"); iprintln(exceptions); + if(!isEmpty(ignoredModules)) { println("Ignored: "); } secs = isEmpty(durations) ? 0 : sum(range(durations))/1000000000; println("Time: minutes"); //iprintln(sort({ | m <- durations}, bool (<_,int i>, <_, int j>) { return i < j; })); } str safeCompile(str \module, RascalCompilerConfig compilerConfig, void (int duration) measure) { + result = ""; try { measure(cpuTimeOf(() { msgs = compile(\module, compilerConfig); if(!isEmpty(msgs)){ iprintln(msgs); } + errors = [ msg | msg <- msgs, msg is error ]; + result = isEmpty(errors) ? "" : ""; })); - return ""; + return result; } catch value exception: { println("Something unexpected went wrong during test source generation for <\module>: diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/CompilerPathConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/CompilerPathConfig.rsc new file mode 100644 index 00000000000..2cb16ea939e --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/CompilerPathConfig.rsc @@ -0,0 +1,10 @@ +module lang::rascalcore::CompilerPathConfig + +extend util::PathConfig; + +data PathConfig( + loc generatedSources = |unknown:///|, + loc generatedTestSources = |unknown:///|, + loc generatedResources = |unknown:///|, + loc generatedTestResources = |unknown:///| +); \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Attributes.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Attributes.rsc index 4506be02fef..8a8b2e52af3 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Attributes.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Attributes.rsc @@ -41,11 +41,11 @@ public set[AAttr] mods2attrs(ProdModifier* mods) = {mod2attr(m) | ProdModifier m public AAttr mod2attr(ProdModifier m) { switch (m) { - case \associativity(\left()) : return \aassoc(AAssociativity::aleft()); - case \associativity(\right()) : return \aassoc(AAssociativity::aright()); - case \associativity(\nonAssociative()) : return \aassoc(AAssociativity::\a-non-assoc()); - case \associativity(\associative()) : return \aassoc(AAssociativity::\aassoc()); - case \bracket() : return AAttr::\abracket(); + case \associativity(\left()) : return \aassoc(aleft()); + case \associativity(\right()) : return \aassoc(aright()); + case \associativity(\nonAssociative()) : return \aassoc(\a-non-assoc()); + case \associativity(\associative()) : return \aassoc(\aassoc()); + case \bracket() : return \abracket(); case \tag(\default(Name n, TagString s)) : return \atag(""("")); case \tag(\empty(Name n)) : return \atag(""()); case \tag(\expression(Name n, literal(string(nonInterpolated(StringConstant l))))) @@ -60,8 +60,8 @@ public AAttr mod2attr(ProdModifier m) { Maybe[AAssociativity] mods2assoc(ProdModifier* mods) = (nothing() | just(x) | ProdModifier m <- mods, just(AAssociativity x) := mod2assoc(m)); -Maybe[AAssociativity] mod2assoc(\associativity(\left())) = just(AAssociativity::aleft()); -Maybe[AAssociativity] mod2assoc(\associativity(\right())) = just(AAssociativity::aright()); -Maybe[AAssociativity] mod2assoc(\associativity(\associative())) = just(AAssociativity::aleft()); -Maybe[AAssociativity] mod2assoc(\associativity(\nonAssociative())) = just(AAssociativity::\a-non-assoc()); +Maybe[AAssociativity] mod2assoc(\associativity(\left())) = just(aleft()); +Maybe[AAssociativity] mod2assoc(\associativity(\right())) = just(aright()); +Maybe[AAssociativity] mod2assoc(\associativity(\associative())) = just(aleft()); +Maybe[AAssociativity] mod2assoc(\associativity(\nonAssociative())) = just(\a-non-assoc()); default Maybe[AAssociativity] mod2assoc(ProdModifier _) = nothing(); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Layout.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Layout.rsc index 549562fabd4..5e46e780b54 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Layout.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/agrammar/definition/Layout.rsc @@ -68,6 +68,6 @@ public AType regulars(AType s, AType l, set[AType] others) { case x:\iter-star(AType n) => inheritLabel(x, \iter-star-seps(n, [l])) when !isLexicalAType(x) case x:\iter-seps(AType n, [AType sep]) => inheritLabel(x, \iter-seps(n,[l,sep,l])) when !isLexicalAType(x), sep != l, sep notin others, isValidSep(sep, others) case x:\iter-star-seps(AType n, [AType sep]) => inheritLabel(x, \iter-star-seps(n, [l, sep, l])) when !isLexicalAType(x), sep != l, sep notin others, isValidSep(sep, others) - case x:\seq(list[AType] elems) => inheritLabel(x, \seq(intermix(elems, l, others))) + case x:\seq(list[AType] elems) => inheritLabel(x, \seq(intermix(elems, l, others))) when !isLexicalAType(x) } } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc index 4eadb124740..1f2f3564282 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc @@ -32,13 +32,12 @@ module lang::rascalcore::check::ADTandGrammar as well as a grammar using the key key_grammar. While doing so it also performs some consistency checks. */ -extend lang::rascalcore::check::CheckerCommon; + +import lang::rascalcore::check::ModuleLocations; import lang::rascalcore::agrammar::definition::Layout; import lang::rascalcore::agrammar::definition::Keywords; -import lang::rascal::\syntax::Rascal; - import IO; import Node; import Set; @@ -49,6 +48,8 @@ import Message; import Map; import util::Reflective; +extend lang::rascalcore::check::CheckerCommon; + void addADTsAndCommonKeywordFields(Solver s){ addADTs(s); addCommonKeywordFields(s); @@ -164,21 +165,23 @@ list[&T <: node ] unsetRec(list[&T <: node] args) = [unsetRec(a) | a <- args]; bool isManualLayout(AProduction p) = (p has attributes && atag("manual"()) in p.attributes); -tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports, set[str] extends, map[str,TModel] transient_tms, ModuleStatus ms){ +tuple[bool, TModel, ModuleStatus] addGrammar(MODID moduleId, set[MODID] imports, set[MODID] extends, map[MODID,TModel] transient_tms, ModuleStatus ms){ try { rel[AType,AProduction] definedProductions = {}; allStarts = {}; - for(m <- {qualifiedModuleName, *imports, *extends}){ + qualifiedModuleName = moduleId2moduleName(moduleId); + for(m <- {moduleId, *imports, *extends}){ TModel tm1; if(transient_tms[m]?){ tm1 = transient_tms[m]; } else { = getTModelForModule(m, ms); if(!found) { - msg = error("Cannot add grammar, tmodel for not found", ms.moduleLocs[qualifiedModuleName] ? |unknown:///|); - ms.messages[qualifiedModuleName] ? {} += { msg }; + msg = error("Cannot add grammar or tmodel since `` is not found", ms.moduleLocs[moduleId] ? |unknown:///|); + //println(msg); // TODO: Just to record this event; this should probably go to a log file + ms.messages[moduleId] ? {} += { msg }; tm1 = tmodel(modelName=qualifiedModuleName, messages=[msg]); - return ; + return ; } } facts = tm1.facts; @@ -222,7 +225,7 @@ tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports // Check keyword rules - tm = checkKeywords(allProductions, transient_tms[qualifiedModuleName]); + tm = checkKeywords(allProductions, transient_tms[moduleId]); // Check layout @@ -239,7 +242,7 @@ tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports definedLayout = aadt("$default$", [], layoutSyntax()); if(isEmpty(allLayouts) || !isEmpty(allStarts)){ - syntaxDefinitions += (AType::layouts("$default$"): achoice(AType::layouts("$default$"), {prod(AType::layouts("$default$"), [])})); + syntaxDefinitions += (layouts("$default$"): achoice(layouts("$default$"), {prod(layouts("$default$"), [])})); } if(size(allLayouts) >= 1){ @@ -311,14 +314,14 @@ tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports g = layouts(g, definedLayout, allManualLayouts); //println("ADTandGrammar:"); iprintln(g, lineLimit=10000); //g = expandKeywords(g); - g.rules += (AType::aempty():achoice(AType::aempty(), {prod(AType::aempty(),[])})); + g.rules += (aempty():achoice(aempty(), {prod(aempty(),[])})); tm = tmlayouts(tm, definedLayout, allManualLayouts); //println("ADTandGrammar:"); iprintln(g, lineLimit=10000); tm.store[key_grammar] = [g]; - return ; + return ; } catch TypeUnavailable(): { // protect against undefined entities in the grammar that have not yet been reported. - return ; + return ; } } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc index 22ff2fe7fd5..8a7ce513151 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc @@ -34,8 +34,13 @@ module lang::rascalcore::check::AType extend lang::rascalcore::check::ATypeBase; extend lang::rascalcore::agrammar::definition::Characters; +import lang::rascalcore::check::ATypeParamBase; + +import IO; import Node; import Set; +import String; +import List; // ---- asubtype -------------------------------------------------------------- @@ -84,16 +89,8 @@ default bool asubtype(AType l, AType r){ return asubtype(l, t); case \seq(list[AType] rl): return \seq(list[AType] ll) := l && asubtypeList(ll, rl); - case p2:aparameter(str _, AType b2): { - res = false; - if(l is aparameter){ - res = asubtypeParam(l, r); - } else { - res = p2.closed ? (equivalent(l, b2) || l is avoid) : asubtype(l, b2); // [S6, S8] - } - //println("asubtype(, ) =\> "); - return res; - } + case p:aparameter(str _, AType _): + return asubtypeRightTypeParam(l, p); case areified(AType t): return asubtype(l, t); } @@ -103,35 +100,78 @@ default bool asubtype(AType l, AType r){ return l == r; } -bool asubtype(p1:aparameter(str n1, AType b1), AType r) - = asubtypeParam(p1, r); +bool occursTypeParameter(str nm, AType t){ + unm = deUnique(nm); + visit(t){ + case p:aparameter(_,_): + if(unm == deUnique(p.pname)) return true; + } + return false; +} // From "Exploring Type Parameters: +// [S1] asubtype(aparameter(n1, b1,closed=false), aparameter(n2, b2, closed=false)) = true; +// [S2] asubtype(aparameter(n1, b1,closed=true), aparameter(n2, b2,closed=true)) = n1 == n2 +// [S3] asubtype(p1:aparameter(n1, b1,closed=false), aparameter(n2, b2,closed=true)) = asubtype(p1, b2); // let op parameters in bounds +// [S4] asubtype(aparameter(n1, b1,closed=true), p2:aparameter(n2, b2,closed=false)) = asubtype(b1, p2); + +// [S5a] asubtype(aparameter(n, b, closed=false), r) = asubtype(b, r) when !(r is aparameter), !occursTypeParameter(n, r) +// [S5b] asubtype(aparameter(n, b, closed=false), r) = true when occursTypeParameter(n, r) +// [S6a] asubtype(l, aparameter(n, b,closed=false)) = asubtype(l, b) when !(l is aparameter), !occursTypeParameter(n, l) +// [S6b] asubtype(l, aparameter(n, b,closed=false)) = false when occursTypeParameter(n, l) +// [S7a] asubtype(aparameter(n, b,closed=true), r) = true when occursTypeParameter(n, r) +// [S7b] asubtype(aparameter(n, b,closed=true), r) = asubtype(b, r) when !(r is aparameter), !occursTypeParameter(n, r) +// [S8a] asubtype(l, aparameter(n, b,closed=true)) = l is avoid +// [S8b] asubtype(l, aparameter(n, b,closed=true)) = false when occursTypeParameter(n, l) +// [S8c] asubtype(l, aparameter(n, b,closed=true)) = equivalent(l,b) when !(l is parameter), !occursTypeParameter(n, l) + +bool asubtypeRightTypeParam(AType l, r:aparameter(str rnm, AType bnd)){ + res = false; + if(l is aparameter){ + res = asubtypeLeftTypeParam(l, r); + } else { + if(occursTypeParameter(rnm, l)){ + res = false; + } else { + res = r.closed ? (equivalent(l, bnd) || l is avoid) : asubtype(l, bnd); // [S6, S8] + } + } + //println("asubtypeRightTypeParam(, ) =\> "); + return res; +} + +bool asubtype(p1:aparameter(str n1, AType b1), AType r) + = asubtypeLeftTypeParam(p1, r); + // aparameter, open -bool asubtypeParam(p1:aparameter(str n1, AType b1, closed=false), AType r) { +bool asubtypeLeftTypeParam(p1:aparameter(str n1, AType b1, closed=false), AType r) { res = false; if(aparameter(str _, AType _, closed=false) := r){ // [S1] res = true; } else if(aparameter(str _, AType b2, closed=true) := r){ // [S3] res = asubtype(p1, b2); + } else if(occursTypeParameter(n1, r)){ + res = true; } else { // [S5] res = asubtype(b1, r); } - //println("asubtype(, ) =\> "); + // println("asubtypeLeftTypeParam(, ) =\> "); return res; } // aparameter, closed -bool asubtypeParam(p1:aparameter(str n1, AType b1, closed=true), AType r) { +bool asubtypeLeftTypeParam(p1:aparameter(str n1, AType b1, closed=true), AType r) { res = false; if(aparameter(str n2, AType _, closed=true) := r ){ // [S2] res = n1 == n2; + } else if(occursTypeParameter(n1, r)){ + res = true; } else if(p2:aparameter(str _, AType _,closed=false) := r){// [S4] res = asubtype(b1, p2); } else { // [S7] res = asubtype(b1, r); } - //println("asubtype(, ) =\> "); + // println("asubtypeLeftTypeParam(, ) =\> "); return res; } @@ -148,8 +188,6 @@ bool asubtype(ac:acons(AType a, list[AType] ap, list[Keyword] _), AType b){ return comparableList(ap, bp); case adt: aadt(str _, list[AType] _, _): return asubtype(a,adt); - case afunc(a,list[AType] bp, list[Keyword] _): - return comparableList(ap, bp); case anode(_): return true; case afunc(AType b, list[AType] bp, list[Keyword] _): @@ -182,8 +220,10 @@ bool asubtype(adt:aadt(str n, list[AType] l, SyntaxRole sr), AType b){ switch(b){ case anode(_): return true; + ////////// case acons(AType a, list[AType] _, list[Keyword] _): - return asubtype(adt, a); + if(isConcreteSyntaxRole(sr)) return asubtype(adt, a); + ///////// case aadt(n, list[AType] r, _): return asubtypeList(l, r); case aadt("Tree", _, _): @@ -192,6 +232,8 @@ bool asubtype(adt:aadt(str n, list[AType] l, SyntaxRole sr), AType b){ if(isConcreteSyntaxRole(sr)) return asubtype(adt, t); case avalue(): return true; + case p:aparameter(_, _): + return asubtypeRightTypeParam(adt, p); } fail; } @@ -386,6 +428,8 @@ bool asubtype(areified(AType s), AType b){ return true; case avalue(): return true; + case p: aparameter(_, _): + return asubtypeRightTypeParam(s, p); } fail; } @@ -428,11 +472,6 @@ bool asubtype(l:\achar-class(_), AType r){ fail; } -bool asubtype(l:\achar-class(list[ACharRange] _), achar(int c)) = l == \achar-class([arange(c,c)]); - -bool asubtype(achar(int c), \achar-class(list[ACharRange] ranges)) - = difference(ranges, [arange(c,c)]) == [arange(c,c)]; - bool asubtype(atypeList(list[AType] l), atypeList(list[AType] r)) = asubtypeList(l, r); // asubtype on lists of atypes @@ -467,61 +506,17 @@ default bool isLayoutAType(AType _) = false; .Synopsis Check if two types are comparable, i.e., have a common supertype. } -bool comparable(AType s, AType t) - = s == t || asubtype(s,t) || asubtype(t,s); +bool comparable(AType s, AType t){ + return s == t || asubtype(s,t) || asubtype(t,s); +} bool comparableList(list[AType] l, list[AType] r) { if(size(l) == 0){ return size(r) == 0; } - //for(i <- index(l)){ - // b = comparable(l[i], r[i]); - // println("comparableList : , =\> "); - //} return size(l) == size(r) && all(i <- index(l), comparable(l[i], r[i])); } -bool outerComparable(AType l, AType r){ - return outerComparable1(l, r); -} - -bool outerComparable1(AType l, l) = true; -bool outerComparable1(alist(_), alist(_)) = true; -bool outerComparable1(aset(_), aset(_)) = true; -bool outerComparable1(abag(_), abag(_)) = true; -bool outerComparable1(arel(atypeList(list[AType] ts1)), arel(atypeList(list[AType] ts2))) = size(ts1) == size(ts2); -bool outerComparable1(arel(_), aset(_)) = true; -bool outerComparable1(aset(_), arel(_)) = true; -bool outerComparable1(alrel(atypeList(list[AType] ts1)), alrel(atypeList(list[AType] ts2))) = size(ts1) == size(ts2); -bool outerComparable1(alrel(_), alist(_)) = true; -bool outerComparable1(atuple(atypeList(ts1)), atuple(atypeList(ts2))) = size(ts1) == size(ts2); -bool outerComparable1(amap(_,_), amap(_,_)) = true; - -bool outerComparable1(f1:afunc(AType r1, list[AType] p1, list[Keyword] _), f2:afunc(AType r2, list[AType] p2, list[Keyword] _)) - = outerComparable(r1, r2) && (f1.varArgs ? (f2.varArgs ? outerComparable(p1, p2) - : outerComparable(p1[0..-1], p2)) - : (f2.varArgs ? outerComparable(p1, p2[0..-1]) - : outerComparable(p1, p2))); - -bool outerComparable1(afunc(AType r1, list[AType] p1, list[Keyword] _), acons(AType r2, list[AType] p2, list[Keyword] _)) - = outerComparable(r1, r2) && outerComparable(p1, p2); -bool outerComparable1(acons(AType r1, list[AType] p1, list[Keyword] _), afunc(AType r2, list[AType] p2, list[Keyword] _)) - = outerComparable(r1, r2) && outerComparable(p1, p2); - -bool outerComparable1(aparameter(str pname1, AType bound1), aparameter(str pname2, AType bound2)) - = outerComparable(bound1, bound2); - -bool outerComparable1(aadt(str adtName1, list[AType] parameters1, SyntaxRole syntaxRole1), areified(_)) = true; - - -default bool outerComparable1(AType l, AType r) { - return comparable(l, r); -} - -bool outerComparable(list[AType] l, list[AType] r) = all(i <- index(l), outerComparable(l[i], r[i])) when size(l) == size(r) && size(l) > 0; -default bool outerComparable(list[AType] l, list[AType] r) = size(l) == 0 && size(r) == 0; - - @doc{ .Synopsis Check if two types are equivalent. @@ -631,8 +626,11 @@ AType alub(a1:aadt(str n, list[AType] lp, SyntaxRole lsr), a2:aadt(n, list[AType = addADTLabel(a1, a2, aadt(n, alubList(lp,rp), sr)) when size(lp) == size(rp) && size(getTypeParamNames(lp)) == 0 && sr := overloadSyntaxRole({lsr, rsr}) && sr != illegalSyntax(); -AType alub(aadt(str n, list[AType] lp, SyntaxRole _), aadt(str m, list[AType] rp,SyntaxRole _)) = anode([]) when n != m; -AType alub(a1: aadt(str ln, list[AType] lp,SyntaxRole _), acons(AType b, _, _)) = alub(a1,b); +AType alub(aadt(str n, list[AType] lp, SyntaxRole lr), aadt(str m, list[AType] rp,SyntaxRole rr)) + = n != m && (n == "Tree" && rr != dataSyntax() || m == "Tree" && lr != dataSyntax()) + ? aadt("Tree", [], dataSyntax()) + : anode([]); +//AType alub(a1: aadt(str ln, list[AType] lp,SyntaxRole _), acons(AType b, _, _)) = alub(a1,b); AType addADTLabel(AType a1, AType a2, AType adt){ if(a1.alabel? && a1.alabel == a2.alabel) adt = adt[alabel=a1.alabel]; @@ -661,7 +659,7 @@ AType alub(afunc(AType lr, list[AType] lp, list[Keyword] lkw), acons(AType rr, l return avalue(); } -AType alub(acons(AType a, list[AType] lp, list[Keyword] _), a2:aadt(str n, list[AType] rp, SyntaxRole _)) = alub(a,a2); +//AType alub(acons(AType a, list[AType] lp, list[Keyword] _), a2:aadt(str n, list[AType] rp, SyntaxRole _)) = alub(a,a2); AType alub(acons(AType _, list[AType] _, list[Keyword] _), anode(_)) = anode([]); AType alub(anode(list[AType] l), anode(list[AType] r)) = anode(l & r); @@ -687,17 +685,17 @@ AType alub(areified(AType l), anode(_)) = anode([]); AType alub(l:\achar-class(_), r:\achar-class(_)) = union(l, r); -AType alub(\iter(AType l), \iter(AType r)) = aadt("Tree", [], dataSyntax()); +AType alub(\iter(AType l), \iter(AType r)) = aadt("Tree", [], dataSyntax()) when l != r; AType alub(\iter(AType l), \iter-star(AType r)) = aadt("Tree", [], dataSyntax()); -AType alub(\iter-star(AType l), \iter-star(AType r)) = aadt("Tree", [], dataSyntax()); +AType alub(\iter-star(AType l), \iter-star(AType r)) = aadt("Tree", [], dataSyntax()) when l != r; AType alub(\iter-star(AType l), \iter(AType r)) = aadt("Tree", [], dataSyntax()); -AType alub(\iter-seps(_, _), \iter-seps(_,_)) = aadt("Tree", [], dataSyntax()); -AType alub(\iter-seps(_,_), \iter-star-seps(AType r,_)) = aadt("Tree", [], dataSyntax()); +AType alub(\iter-seps(AType l, _), \iter-seps(AType r,_)) = aadt("Tree", [], dataSyntax()) when l != r; +AType alub(\iter-seps(AType l,_), \iter-star-seps(AType r,_)) = aadt("Tree", [], dataSyntax()) when l != r; -AType alub(\iter-star-seps(AType l, _), \iter-star-seps(AType r, _)) = aadt("Tree", [], dataSyntax()); -AType alub(\iter-star-seps(AType l, _), \iter-seps(AType r, _)) = aadt("Tree", [], dataSyntax()); +AType alub(\iter-star-seps(AType l, _), \iter-star-seps(AType r, _)) = aadt("Tree", [], dataSyntax()) when l != r; +AType alub(\iter-star-seps(AType l, _), \iter-seps(AType r, _)) = aadt("Tree", [], dataSyntax()) when l != r; AType alub(l:aadt("Tree", _, _), AType r) = l when r is \achar-class || r is seq || r is opt || r is alt || r is iter || r is \iter-star || r is \iter-seps || r is \iter-star-seps; @@ -817,7 +815,7 @@ AType aglb(aadt(str n, list[AType] lp, SyntaxRole _), aadt(str m, list[AType] rp AType aglb(a1: aadt(str ln, list[AType] lp,SyntaxRole _), acons(AType b, _, _)) = aglb(a1,b); public AType aglb(acons(AType la, list[AType] _, list[Keyword] _), acons(AType ra, list[AType] _, list[Keyword] _)) = aglb(la,ra); -public AType aglb(acons(AType a, list[AType] lp, list[Keyword] _), aadt(str n, list[AType] rp, SyntaxRole sr)) = aglb(a,aadt(n,rp,sr)); +//public AType aglb(acons(AType a, list[AType] lp, list[Keyword] _), aadt(str n, list[AType] rp, SyntaxRole sr)) = aglb(a,aadt(n,rp,sr)); public AType aglb(acons(AType _, list[AType] _, list[Keyword] _), anode(list[AType] r)) = anode(r); public AType aglb(aalias(str _, list[AType] _, AType aliased), AType r) = aglb(aliased, r); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeBase.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeBase.rsc index b583aea0550..bd754637dec 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeBase.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeBase.rsc @@ -26,14 +26,14 @@ POSSIBILITY OF SUCH DAMAGE. } @bootstrapParser module lang::rascalcore::check::ATypeBase - + /* Basic declarations for the ATypes used in the checker. They extend the datat type AType introduced in TypePal. */ extend analysis::typepal::TypePal; -import lang::rascal::\syntax::Rascal; +extend lang::rascal::\syntax::Rascal; //import IO; import List; @@ -156,25 +156,12 @@ public AProduction achoice(AType s, set[AProduction] achoices){ fail; } -// ---- Parse Tree -data ATree - = appl(AProduction aprod, list[ATree] args/*, loc src=|unknown:///|*/) // <1> - | cycle(AType atype, int cycleLength) // <2> - | aamb(set[ATree] alternatives) // <3> - | achar(int character) // <4> - ; public /*const*/ AType treeType = aadt("Tree", [], dataSyntax()); public bool isTreeType(AType t) = treeType := t; -//@doc{ -//.Synopsis -//Annotate a parse tree node with a source location. -//} -//anno loc Tree@\loc; // TODO: weg - data SyntaxRole = dataSyntax() | contextFreeSyntax() @@ -341,9 +328,9 @@ data AType //public AType \iter-star-seps(AType atype, []) = \iter-star(atype); // flattening rules -public AType seq([*AType a, seq(list[AType] b), *AType c]) = seq(a + b + c); +public AType seq([*AType a, seq(list[AType] b), *AType c]) = AType::seq(a + b + c); -public AType alt({*AType a, alt(set[AType] b)}) = alt(a + b); +public AType alt({*AType a, alt(set[AType] b)}) = AType::alt(a + b); data AType // <19> = \conditional(AType atype, set[ACondition] conditions); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeInstantiation.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeInstantiation.rsc index f4477f314f8..07df4c713a2 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeInstantiation.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeInstantiation.rsc @@ -42,16 +42,16 @@ module lang::rascalcore::check::ATypeInstantiation Note: it is assumed that the type parameters in receiver and sender AType have already been properly renamed */ -extend lang::rascalcore::check::ATypeUtils; +extend lang::rascalcore::check::ATypeParamBase; extend lang::rascalcore::check::NameUtils; +extend lang::rascalcore::check::ATypeUtils; +import List; import Map; import Set; import Node; import String; -public alias Bindings = map[str varName, AType varType]; - public Bindings unifyRascalTypeParams(AType r, AType s, Bindings b){ b2 = matchRascalTypeParams(r, s, b); return matchRascalTypeParams(s, r, b2); @@ -96,7 +96,7 @@ public Bindings matchRascalTypeParams(AType r, AType s, Bindings b) { } public Bindings matchRascalTypeParams0(AType r, AType s, Bindings b) { - + //println("ENTER matchRascalTypeParams0: , , "); // The simple case: if the receiver is a basic type or a node // (i.e., has no internal structure), just do a comparability // check. The receiver obviously does not contain a parameter. @@ -112,7 +112,7 @@ public Bindings matchRascalTypeParams0(AType r, AType s, Bindings b) { if (varName in b) { lubbed = alub(s, b[varName]); if (!asubtype(lubbed, varBound)) - throw invalidMatch("Type parameter `` should be less than , but is bound to "); + throw invalidMatch("Type parameter `` should be less than , but is bound to "); b[varName] = lubbed; } else { b[varName] = s; @@ -131,6 +131,7 @@ public Bindings matchRascalTypeParams0(AType r, AType s, Bindings b) { b[varName] = s; } } + //println("LEAVE matchRascalTypeParams0: , =\> "); return b; } @@ -179,6 +180,10 @@ public Bindings matchRascalTypeParams0(AType r, AType s, Bindings b) { if ( isConstructorAType(r) && isADTAType(s) ) { return matchRascalTypeParams0(getConstructorResultType(r), s, b); } + + if ( isADTAType(r) && isConstructorAType(s) ) { + return matchRascalTypeParams0(r, getConstructorResultType(s), b); + } // For functions, match the return types and the parameter types // TODO: kewyword params? @@ -199,59 +204,11 @@ public Bindings matchRascalTypeParams0(AType r, AType s, Bindings b) { if(comparable(r, s)) return b; - throw invalidMatch("Types and do not match"); + throw invalidMatch("Types and do not match"); } AType invalidInstantiation(str pname, AType bound, AType actual){ - throw invalidInstantiation("Type parameter `` should be less than ``, but is bound to ``"); -} - -AType makeClosedTypeParams(AType t){ - return visit(t) { case par:aparameter(_,_) => par[closed=true] }; -} - -void requireClosedTypeParams(AType t){ - if(hasOpenTypeParams(t)){ - throw "requireClosedTypeParams: "; - } -} - -bool hasOpenTypeParams(AType t){ - return /aparameter(_,_,closed=false) := t; -} - -// Make all type parameters unique with given suffix -AType makeUniqueTypeParams(AType t, str suffix){ - return visit(t) { case param:aparameter(str pname, AType _bound): { - if(findLast(pname, ".") < 0){ - param.pname = param.pname + "." + suffix; - insert param; - } - } - }; -} - -// Make all type parameters unique with given suffix -list[AType] makeUniqueTypeParams(list[AType] ts, str suffix){ - return [ makeUniqueTypeParams(t, suffix) | t <- ts ]; -} - -// Reverse the makeUnique operation -str deUnique(str s) { - i = findLast(s, "."); - return i > 0 ? s[0..i] : s; -} - -AType deUnique(AType t){ - return visit(t) { case param:aparameter(str pname, AType _bound): { - param.pname = deUnique(pname); - insert param; - } - }; -} - -Bindings deUniqueTypeParams(Bindings b){ - return (deUnique(key) : deUnique(b[key]) | key <- b); + throw invalidInstantiation("Type parameter `&` should be less than ``, but is bound to ``"); } // NOTE used during match, no bounds check is needed since that is already done during the match @@ -276,16 +233,13 @@ AType instantiateRascalTypeParameters(Tree selector, AType t, Bindings bindings, return t; else return visit(t) { case param:aparameter(str pname, AType bound): { - if(bindings[pname]?){ - if(asubtype(bindings[pname], bound)){ - repl = param.alabel? ? bindings[pname][alabel=param.alabel] : bindings[pname]; //TODO simplified for compiler - insert repl; - } - else { - s.report(error(selector, "Type parameter %q should be less than %t, found %t", deUnique(pname), bound, bindings[pname])); + if(pname in bindings){ + ult = bindings[pname]; + if(asubtype(ult, bound)){ + insert param.alabel? ? ult[alabel=param.alabel] : ult; + } else { + s.report(error(selector, "Type parameter &%q should be less than %t, found %t", deUnique(pname), deUnique(bound), deUnique(ult))); } - } else { - insert param; } } }; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeParamBase.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeParamBase.rsc new file mode 100644 index 00000000000..fbc04550e51 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeParamBase.rsc @@ -0,0 +1,109 @@ +module lang::rascalcore::check::ATypeParamBase + +extend lang::rascalcore::check::ATypeBase; +extend lang::rascalcore::check::ATypeExceptions; + +public alias Bindings = map[str varName, AType varType]; + +AType makeClosedTypeParams(AType t){ + return visit(t) { case par:aparameter(_, _) => par[closed=true] }; +} + +void requireClosedTypeParams(AType t){ + if(hasOpenTypeParams(t)){ + throw "requireClosedTypeParams: "; + } +} + +bool hasOpenTypeParams(AType t){ + return /aparameter(_,_,closed=false) := t; +} + +// Make all type parameters unique with given suffix +AType makeUniqueTypeParams(AType t, str suffix){ + return visit(t) { case param:aparameter(str pname, AType _bound): { + if(findLast(pname, ".") < 0){ + param.pname = param.pname + "." + suffix; + insert param; + } + } + }; +} + +// Make all type parameters unique with given suffix +list[AType] makeUniqueTypeParams(list[AType] ts, str suffix){ + return [ makeUniqueTypeParams(t, suffix) | t <- ts ]; +} + +// Reverse the makeUnique operation +str deUnique(str s) { + i = findLast(s, "."); + return i > 0 ? s[0..i] : s; +} + +AType deUnique(AType t){ + return visit(t) { case param:aparameter(str pname, AType _bound): { + param.pname = deUnique(pname); + insert param; + } + }; +} + +Bindings deUniqueTypeParams(Bindings b){ + return (deUnique(key) : deUnique(b[key]) | key <- b); +} + +@doc{ +.Synopsis +Determine if the given type is an type variable (parameter). +} +bool isRascalTypeParam(aparameter(_,_)) = true; +default bool isRascalTypeParam(AType _) = false; + +@doc{Create a type representing a type parameter (type variable).} +AType makeTypeVar(str varName) = aparameter(varName, avalue()); + +@doc{Create a type representing a type parameter (type variable) and bound.} +AType makeTypeVarWithBound(str varName, AType varBound) = aparameter(varName, varBound); + +@doc{Get the name of a Rascal type parameter.} +str getRascalTypeParamName(AType t) { + if (aparameter(tvn,_) := t) return tvn; + throw rascalCheckerInternalError("getRascalTypeParamName given unexpected type: "); +} + +@doc{Get the bound of a type parameter.} +AType getRascalTypeParamBound(AType t) { + if (aparameter(_,tvb) := t) return tvb; + throw rascalCheckerInternalError("getRascalTypeParamBound given unexpected type: "); +} + +@doc{Get all the type parameters inside a given type.} +set[AType] collectRascalTypeParams(AType t) { + + return { rt | / AType rt : aparameter(_,_) := t }; + //return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := t }; // TODO: "alabel" is unset to enable subset check later, reconsider +} + +@doc{Get all the type parameters inside a given type.} +set[AType] collectAndUnlabelRascalTypeParams(AType t) { + return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := t }; // TODO: "alabel" is unset to enable subset check later, reconsider +} + +@doc{Get all the type parameters inside a given set of productions.} +set[AType] collectAndUnlabelRascalTypeParams(set[AProduction] prods) { + return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := prods }; // TODO: "alabel" is unset to enable subset check later, reconsider +} + +@doc{See if a type contains any type parameters.} +bool typeContainsRascalTypeParams(AType t) = size(collectRascalTypeParams(t)) > 0; + +@doc{Return the names of all type variables in the given type.} +set[str] typeParamNames(AType t) { + return { tvn | aparameter(tvn,_) <- collectRascalTypeParams(t) }; +} + +@doc{Set "closed" to its default in all type parameters occurring in a value} +&T uncloseTypeParams(&T v) + = visit(v) { case p:aparameter(_,_,closed=true) => unset(p,"closed") }; + \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc index 008934b44e8..4243ece11cc 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc @@ -24,17 +24,6 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } -@license{ - Copyright (c) 2009-2015 CWI - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html -} -@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} -@contributor{Mark Hills - Mark.Hills@cwi.nl (CWI)} -@contributor{Paul Klint - Paul.Klint@cwi.nl (CWI)} -@contributor{Anastasia Izmaylova - Anastasia.Izmaylova@cwi.nl (CWI)} @bootstrapParser module lang::rascalcore::check::ATypeUtils @@ -44,13 +33,14 @@ module lang::rascalcore::check::ATypeUtils */ extend lang::rascalcore::check::AType; +//extend lang::rascalcore::check::ATypeInstantiation; extend lang::rascalcore::check::ATypeExceptions; extend lang::rascalcore::check::BasicRascalConfig; extend ParseTree; import analysis::typepal::Messenger; -import lang::rascal::\syntax::Rascal; +extend lang::rascal::\syntax::Rascal; import lang::rascalcore::compile::util::Names; // TODO: undesired forward reference @@ -350,12 +340,9 @@ AType symbol2atype1(Symbol::label(str label, symbol)){ } AType symbol2atype1(Symbol::\set(Symbol symbol)) = aset(symbol2atype(symbol)); -AType symbol2atype1(Symbol::\rel(list[Symbol] symbols)) = arel(atypeList(symbol2atype(symbols))); -AType symbol2atype1(Symbol::\lrel(list[Symbol] symbols)) = alrel(atypeList(symbol2atype(symbols))); AType symbol2atype1(Symbol::\tuple(list[Symbol] symbols)) = atuple(atypeList(symbol2atype(symbols))); AType symbol2atype1(Symbol::\list(Symbol symbol)) = alist(symbol2atype(symbol)); AType symbol2atype1(Symbol::\map(Symbol from, Symbol to)) = amap(symbol2atype(from), symbol2atype(to)); -AType symbol2atype1(Symbol::\bag(Symbol symbol)) = abag(symbol2atype(symbol)); AType symbol2atype1(Symbol::\adt(str name, list[Symbol] parameters)) = aadt(name, symbol2atype(parameters), dataSyntax()); AType symbol2atype1(Symbol::\cons(Symbol \adt, str name, list[Symbol] parameters)) = acons(symbol2atype(\adt), symbol2atype(parameters), [])[alabel=name]; @@ -368,7 +355,7 @@ AType symbol2atype1(Symbol::\cons(Symbol \adt, str name, list[Symbol] parameters AType symbol2atype1(Symbol::sort(str name)) = aadt(name, [], contextFreeSyntax()); AType symbol2atype1(Symbol::lex(str name)) = aadt(name, [], lexicalSyntax()); AType symbol2atype1(Symbol::keywords(str name)) = aadt(name, [], keywordSyntax()); -AType symbol2atype1(Symbol::layouts(str name)) = AType::layouts(name); +AType symbol2atype1(Symbol::layouts(str name)) = aadt(name, [], layoutSyntax()); AType symbol2atype1(Symbol::\parameterized-sort(str name, list[Symbol] parameters)) = aadt(name, symbol2atype(parameters), contextFreeSyntax()); @@ -1249,67 +1236,6 @@ AType getReifiedType(AType t) { throw rascalCheckerInternalError("getReifiedType given unexpected type: "); } -@doc{ -.Synopsis -Determine if the given type is an type variable (parameter). -} -bool isRascalTypeParam(aparameter(_,_)) = true; -default bool isRascalTypeParam(AType _) = false; - -@doc{Create a type representing a type parameter (type variable).} -AType makeTypeVar(str varName) = aparameter(varName, avalue()); - -@doc{Create a type representing a type parameter (type variable) and bound.} -AType makeTypeVarWithBound(str varName, AType varBound) = aparameter(varName, varBound); - -@doc{Get the name of a Rascal type parameter.} -str getRascalTypeParamName(AType t) { - if (aparameter(tvn,_) := t) return tvn; - throw rascalCheckerInternalError("getRascalTypeParamName given unexpected type: "); -} - -@doc{Get the bound of a type parameter.} -AType getRascalTypeParamBound(AType t) { - if (aparameter(_,tvb) := t) return tvb; - throw rascalCheckerInternalError("getRascalTypeParamBound given unexpected type: "); -} - -@doc{Get all the type parameters inside a given type.} -set[AType] collectRascalTypeParams(AType t) { - - return { rt | / AType rt : aparameter(_,_) := t }; - //return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := t }; // TODO: "alabel" is unset to enable subset check later, reconsider -} - -@doc{Get all the type parameters inside a given type.} -set[AType] collectAndUnlabelRascalTypeParams(AType t) { - return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := t }; // TODO: "alabel" is unset to enable subset check later, reconsider -} - -@doc{Get all the type parameters inside a given set of productions.} -set[AType] collectAndUnlabelRascalTypeParams(set[AProduction] prods) { - return { unset(rt, "alabel") | / AType rt : aparameter(_,_) := prods }; // TODO: "alabel" is unset to enable subset check later, reconsider -} - -@doc{Provide an initial type map from the type parameters in the type to void.} -map[str,AType] initializeRascalTypeParamMap(AType t) { - set[AType] rt = collectRascalTypeParams(t); - return ( getRascalTypeParamName(tv) : makeVoidType() | tv <- rt ); -} - -@doc{See if a type contains any type parameters.} -bool typeContainsRascalTypeParams(AType t) = size(collectRascalTypeParams(t)) > 0; - -@doc{Return the names of all type variables in the given type.} -set[str] typeParamNames(AType t) { - return { tvn | aparameter(tvn,_) <- collectRascalTypeParams(t) }; -} - -@doc{Set "closed" to its default in all type parameters occurring in a value} -&T uncloseTypeParams(&T v) - = visit(v) { case p:aparameter(_,_,closed=true) => unset(p,"closed") }; - - // ---- element & container types @doc{Is this type a non-container type?} @@ -1390,9 +1316,10 @@ bool isLexicalAType(AType::\iter-star(AType s, isLexical=b)) = b; //isLexicalATy bool isLexicalAType(AType::\iter-seps(AType s,_, isLexical=b)) = b; //isLexicalAType(s); bool isLexicalAType(AType::\iter-star-seps(AType s,_, isLexical=b)) = b; //isLexicalAType(s); +bool isLexicalAType(\opt(AType atype)) = isLexicalAType(atype); bool isLexicalAType(seq(list[AType] symbols)) = all(s <- symbols, isLexicalAType(s)); bool isLexicalAType(alt(set[AType] alternatives)) = any(s <- alternatives, isLexicalAType(s)); -bool isLexicalAType(AType t) = false; +default bool isLexicalAType(AType t) = false; // ---- literal/terminal @doc{Synopsis: Determine if the given type is a terminal symbol (a literal or character class).} @@ -1447,6 +1374,7 @@ bool isRegExpType(AType tp) = isEmpty(tp) || isIterType(tp) || isOptType(tp) || isAltType(tp) || isSeqType(tp); bool isIterType(aparameter(_,AType tvb)) = isIterType(tvb); +bool isIterType(AType::\conditional(AType ss,_)) = isIterType(ss); bool isIterType(AType::\iter(_)) = true; bool isIterType(AType::\iter-star(_)) = true; bool isIterType(AType::\iter-seps(_,_)) = true; @@ -1455,6 +1383,7 @@ bool isIterType(AType::\opt(_)) = true; default bool isIterType(AType _) = false; AType getIterElementType(aparameter(_,AType tvb)) = getIterElementType(tvb); +AType getIterElementType(AType::\conditional(AType ss,_)) = getIterElementType(ss); AType getIterElementType(AType::\iter(AType i)) = i; AType getIterElementType(AType::\iter-star(AType i)) = i; AType getIterElementType(AType::\iter-seps(AType i,_)) = i; @@ -1465,6 +1394,7 @@ default AType getIterElementType(AType i) { } int getIterOrOptDelta(aparameter(_,AType tvb)) = getIterOrOptDelta(tvb); +int getIterOrOptDelta(AType::\conditional(AType ss,_)) = getIterOrOptDelta(ss); int getIterOrOptDelta(AType::\iter(AType i, isLexical=b)) = b ? 1 : 2; int getIterOrOptDelta(AType::\iter-star(AType i, isLexical=b)) = b ? 1 : 2; int getIterOrOptDelta(AType::\iter-seps(AType i, list[AType] seps, isLexical=b)) { diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/BasicRascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/BasicRascalConfig.rsc index db9ec8ce715..d1ab5097363 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/BasicRascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/BasicRascalConfig.rsc @@ -31,11 +31,13 @@ module lang::rascalcore::check::BasicRascalConfig Basic configuration information as required by TypePal, including IdRole, PathRole, ScopeRole, DefInfo and the like. The checker itself is configure in RascalConfig. */ -extend analysis::typepal::TypePal; import lang::rascal::\syntax::Rascal; import Location; import util::SemVer; +import String; + +extend analysis::typepal::TypePal; data IdRole = moduleId() @@ -60,20 +62,54 @@ data IdRole | typeVarId() ; -public set[IdRole] syntaxRoles = {aliasId(), nonterminalId(), lexicalId(), layoutId(), keywordId()}; +public set[IdRole] baseSyntaxRoles = {nonterminalId(), lexicalId(), layoutId(), keywordId()}; +public set[IdRole] syntaxRoles = {aliasId()} + baseSyntaxRoles; public set[IdRole] dataOrSyntaxRoles = {dataId()} + syntaxRoles; public set[IdRole] dataRoles = {aliasId(), dataId()}; public set[IdRole] outerFormalRoles = {formalId(), keywordFormalId()}; public set[IdRole] positionalFormalRoles = {formalId(), nestedFormalId()}; public set[IdRole] formalRoles = outerFormalRoles + {nestedFormalId()}; -public set[IdRole] variableRoles = formalRoles + {variableId(), moduleVariableId(), patternVariableId()}; -public set[IdRole] inferrableRoles = formalRoles + {variableId(), moduleVariableId(), patternVariableId()}; +public set[IdRole] localVariableRoles = formalRoles + {variableId(), patternVariableId()}; +public set[IdRole] variableRoles = localVariableRoles + { moduleVariableId() }; +public set[IdRole] inferrableRoles = variableRoles; public set[IdRole] keepInTModelRoles = dataOrSyntaxRoles + { moduleId(), constructorId(), functionId(), fieldId(), keywordFieldId(), annoId(), - moduleVariableId(), productionId(), nonterminalId() + moduleVariableId(), productionId() }; public set[IdRole] assignableRoles = variableRoles; +set[IdRole] variableOrAliasRoles = variableRoles + {aliasId()}; +set[IdRole] functionRoles = {functionId(), constructorId(), productionId()}; +set[IdRole] variableOrFunctionRoles = variableRoles + functionRoles; +set[IdRole] variableAliasOrFunctionRoles = variableOrAliasRoles + functionRoles; + +// For each IdRole give a set of forbidden overloads with other IdRoles +// Not listed here or empty forbids: all overloads are allowed +public map[IdRole, set[IdRole]] forbiddenIdRoleOverloading = + (functionId(): variableRoles, + constructorId(): variableRoles - {moduleVariableId(), productionId()}, + productionId(): variableRoles - {moduleVariableId(), constructorId()}, + variableId(): variableOrFunctionRoles, + moduleVariableId(): variableOrFunctionRoles - {constructorId(), productionId()}, + formalId(): variableOrFunctionRoles - {nestedFormalId()}, + nestedFormalId(): variableOrFunctionRoles - {formalId(), nestedFormalId()}, + keywordFormalId(): variableOrFunctionRoles, + patternVariableId(): variableOrFunctionRoles, + + nonterminalId(): baseSyntaxRoles - nonterminalId(), + lexicalId(): baseSyntaxRoles - lexicalId(), + layoutId(): baseSyntaxRoles - layoutId(), + keywordId(): baseSyntaxRoles - keywordId(), + + fieldId(): { }, + keywordFieldId(): { }, + dataId(): { }, + + aliasId(): {aliasId()}, + typeVarId(): { }, + annoId(): { } + ); + data PathRole = importPath() | extendPath() @@ -136,15 +172,22 @@ public str key_grammar = "grammar"; public str key_ADTs = "ADTs"; public str key_common_keyword_fields = "CommonKeywordFields"; +private str MD5_CONTRIB_SEPARATOR = "@"; +private map[str, str] MD5_ESCAPES = (MD5_CONTRIB_SEPARATOR: "\\"); + +@synopsis{Hash a variable number of contributing values (MD5).} +str normalizedMD5Hash(value contribs...) + = md5Hash(removeWhitespace(intercalate(MD5_CONTRIB_SEPARATOR, [escape("", MD5_ESCAPES) | c <- contribs]))); + bool isValidRascalTplVersion(str version) = equalVersion(version, currentRascalTplVersion); str getCurrentRascalTplVersion() = currentRascalTplVersion; -str currentRascalTplVersion = "2.0.0"; +str currentRascalTplVersion = "3.0.0"; data TModel ( - str rascalTplVersion = "2.0.0" + str rascalTplVersion = "3.0.0" ); // Define alias for TypePalConfig diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc index e06507778bc..98ec75730d4 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc @@ -28,12 +28,10 @@ POSSIBILITY OF SUCH DAMAGE. module lang::rascalcore::check::Checker /* - Top level driver for the checker (rascalTModelForLocsNote). + Top level driver for the checker (rascalTModelForLocs). Note that the checker calls the code generator (given as parameter) when there are no type errors. */ -import lang::rascal::\syntax::Rascal; - extend lang::rascalcore::check::ADTandGrammar; extend lang::rascalcore::check::CollectDeclaration; extend lang::rascalcore::check::CollectExpression; @@ -48,7 +46,6 @@ extend lang::rascalcore::check::CheckerCommon; import lang::rascalcore::compile::CompileTimeError; import lang::rascalcore::check::ModuleLocations; -extend lang::rascalcore::check::TestConfigs; import analysis::typepal::Exception; @@ -66,14 +63,7 @@ import util::FileSystem; import util::Monitor; import util::Benchmark; import analysis::graphs::Graph; - -// Duplicate in lang::rascalcore::compile::util::Names, factor out -data PathConfig( - loc generatedSources=|unknown:///|, - loc generatedTestSources=|unknown:///|, - loc resources = |unknown:///|, - loc testResources =|unknown:///| -); +import lang::rascalcore::CompilerPathConfig; void rascalPreCollectInitialization(map[str, Tree] _namedTrees, Collector c){ @@ -81,8 +71,8 @@ void rascalPreCollectInitialization(map[str, Tree] _namedTrees, Collector c){ c.push(key_allow_use_before_def, <|none:///|(0,0,<0,0>,<0,0>), |none:///|(0,0,<0,0>,<0,0>)>); } -list[Message] validatePathConfigForChecker(PathConfig pcfg, loc mloc) { - msgs = []; +set[Message] validatePathConfigForChecker(PathConfig pcfg, loc mloc) { + msgs = {}; if(isEmpty(pcfg.srcs)) msgs += error("PathConfig: `srcs` is empty", mloc); for(src <- pcfg.srcs){ @@ -92,18 +82,17 @@ list[Message] validatePathConfigForChecker(PathConfig pcfg, loc mloc) { if(!exists(lb)) msgs += warning("PathConfig `libs`: does not exist (yet)", lb); } - if(!exists(pcfg.resources)) { + if(pcfg.generatedResources != |unknown:///| && !exists(pcfg.generatedResources)) { try { - mkDirectory(pcfg.resources); + mkDirectory(pcfg.generatedResources); } catch e: { - msgs += error("PathConfig `resources`: ", pcfg.resources); + msgs += error("PathConfig `generatedResources`: ", pcfg.generatedResources); } } - return msgs; } -list[Message] validatePathConfigForCompiler(PathConfig pcfg, loc mloc) { +set[Message] validatePathConfigForCompiler(PathConfig pcfg, loc mloc) { msgs = validatePathConfigForChecker(pcfg, mloc); if(!exists(pcfg.bin)){ try { @@ -115,101 +104,125 @@ list[Message] validatePathConfigForCompiler(PathConfig pcfg, loc mloc) { return msgs; } +bool errorsPresent(TModel tmodel) = errorsPresent(tmodel.messages); +bool errorsPresent(set[Message] msgs) = errorsPresent(toList(msgs)); +bool errorsPresent(list[Message] msgs) = !isEmpty([ e | e:error(_,_) <- msgs ]); + // ---- Various check functions --------------------------------------------- // Dummy compile function (used when running only the checker) -list[Message] dummy_compile1(str _qualifiedModuleName, lang::rascal::\syntax::Rascal::Module _M, map[str,TModel] _transient_tms, ModuleStatus _ms, RascalCompilerConfig _compilerConfig) +list[Message] dummy_compile1(MODID _moduleId, lang::rascal::\syntax::Rascal::Module _M, map[MODID,TModel] _transient_tms, ModuleStatus _ms, RascalCompilerConfig _compilerConfig) = []; // rascalTModelForLocs is the basic work horse +// Essential assumption: all changed modules are included in mlocs. +// If this is not the case, changed modules not in mlocs will not be checked. ModuleStatus rascalTModelForLocs( list[loc] mlocs, RascalCompilerConfig compilerConfig, - list[Message](str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen + list[Message](MODID moduleId, lang::rascal::\syntax::Rascal::Module M, map[MODID,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen ){ pcfg = compilerConfig.typepalPathConfig; - + if(compilerConfig.logPathConfig) { iprintln(pcfg); } - msgs = validatePathConfigForChecker(pcfg, mlocs[0]); - ModuleStatus ms = newModuleStatus(compilerConfig); - - mnames = + + if(isEmpty(mlocs)) return ms; + + set[Message] msgs = validatePathConfigForChecker(pcfg, mlocs[0]); + + list[str] mnames = []; + mids = for(mloc <- mlocs){ - if(!exists(mloc)){ - msgs += error(" does not exist", mloc); - append "LocationDoesNotExist: "; - } else { + if(isRascalLogicalLoc(mloc)){ + mnames += moduleId2moduleName(mloc); + append mloc; + } else + if(exists(mloc)){ try { - append getRascalModuleName(mloc, pcfg); - } catch e: { - append "NoModuleNameFound: "; + mname = getRascalModuleName(mloc, pcfg); + mnames += mname; + append moduleName2moduleId(mname); + } catch _: { msgs += error("No module name found for ", mloc); } + } else { + msgs += error(" does not exist", mloc); } }; - if(allModulesHaveValidTpls(mlocs, pcfg)){ - = libraryDependenciesAreCompatible(mlocs, ms); - - if(compatibleLibs && uptodateTPls(mlocs, mnames, pcfg)){ - for (i <- index(mlocs)) { - = getTModelForModule(mnames[i], ms); - if(!found){ - throw "TModel for not found (no changes)"; - } + if(size(mlocs) != size(mnames)){ // not all mlocs could be mapped to a module + for(mid <- mids){ + ms.messages[mid] = msgs; + } + if(errorsPresent(msgs)){ + pcfg.messages += toList(msgs); + ms.pathConfig = pcfg; + ms.compilerConfig.typepalPathConfig.messages += pcfg.messages; + } + return ms; + } + + = libraryDependenciesAreCompatible(mids, ms); + + if(compatibleLibs && uptodateTPls(mlocs, mnames, pcfg)){ + for (i <- index(mids)) { + = getTModelForModule(mids[i], ms); + if(!found){ + throw "TModel for not found (no changes)"; } - return ms; } + return ms; } for (int i <- index(mlocs)) { + mid = mids[i]; mloc = mlocs[i]; mname = mnames[i]; - if(isModuleLocationInLibs(mname, mloc, pcfg)){ - ms.status[mname] ? {} += {rsc_not_found()}; + if(isModuleLocationInLibs(mloc, pcfg)){ + ms = addProperty(mloc, ms, tpl_from_library()); } - ms.moduleLocs[mname] = mloc; - msgs += toList(ms.messages[mname] ? {}); + ms.moduleLocs[mid] = mloc; + ms.messages[mid] = {}; } str jobName = ""; - topModuleNames = toSet(mnames); + ms.changedModules = topModuleIds = toSet(mids); + topModuleNames = mnames; try { - ms = getImportAndExtendGraph(topModuleNames, ms); + ms = getImportAndExtendGraph(topModuleIds, ms); // if(/error(_,_) := ms.messages){ - // return clearTModelCache(ms); // } - imports_and_extends = ms.strPaths<0,2>; + imports_and_extends = ms.paths<0,2>; = stronglyConnectedComponentsAndTopSort(imports_and_extends); - map[str, set[str]] module2component = (m : c | c <- components, m <- c); + map[MODID, set[MODID]] module2component = (m : c | c <- components, m <- c); - list[str] ordered = []; + list[MODID] ordered = []; if(isEmpty(sorted)){ - ordered = toList(topModuleNames); - for(str topModuleName <- topModuleNames){ - module2component[topModuleName] = {topModuleName}; + ordered = toList(topModuleIds); + for(MODID topModuleId <- topModuleIds){ + module2component[topModuleId] = {topModuleId}; } } else { ordered = reverse(sorted); - singletons = toList(topModuleNames - toSet(ordered)); + singletons = toList(topModuleIds - toSet(ordered)); ordered += singletons; - for(str singleton <- singletons){ + for(MODID singleton <- singletons){ module2component[singleton] = {singleton}; } } - map[str, loc] moduleScopes = (); - map[str,str] path2module = (ms.moduleLocs[mname].path : mname | mname <- ms.moduleLocs); + // map[loc, loc] moduleScopes = (); + //map[str,loc] path2module = (ms.moduleLocs[mname].path : mname | mname <- ms.moduleLocs); mi = 0; nmodules = size(ordered); @@ -219,17 +232,24 @@ ModuleStatus rascalTModelForLocs( while(mi < nmodules) { component = module2component[ordered[mi]]; - //println("while: , Ambiguity: "); - jobStep(jobName, intercalate(" + ", [*component]), work=size(component)); - - recheck = !all(m <- component, ms.status[m]?, (tpl_uptodate() in ms.status[m] || checked() in ms.status[m])); + sizeComponent = size(component); + componentNames = + for(c <- component){ + cstr = ""; + append replaceAll(cstr[0] == "/" ? cstr[1..] : cstr, "/", "::"); + }; + + jobStep(jobName, intercalate(" + ", [*componentNames]), work=size(componentNames)); + + recheck = !all(m <- component, hasAnyProperty(m, ms, tpl_uptodate(), checked())); for(m <- component){ + mi += 1; if(!recheck){ - if(tpl_uptodate() notin ms.status[m]){ + if(hasNotProperty(m, ms, tpl_uptodate())){ = getTModelForModule(m, ms); if(found){ - ms.status[m] += {tpl_uptodate(), checked()}; + ms = addProperty(m, ms, tpl_uptodate(), checked()); } } } @@ -239,78 +259,86 @@ ModuleStatus rascalTModelForLocs( any_tpl_outdated = any(m <- component, tplOutdated(m, pcfg)); if(any_tpl_outdated){ for(m <- component){ - ms.status[m] -= {tpl_uptodate(), checked()}; - ms.status[m] += {rsc_changed()}; + ms = deleteProperty(m, ms, tpl_uptodate(), checked()); } } else { for(m <- component){ m_compatible = false; - = getTModelForModule(m, ms); - if(found && !tplOutdated(m, pcfg)){ - imports_extends_m = imports_and_extends[m]; + try { + = getTModelForModule(m, ms); + if(found && !tplOutdated(m, pcfg)){ + imports_extends_m = imports_and_extends[m]; - = importsAndExtendsAreBinaryCompatible(tm, imports_extends_m, ms); - if(m_compatible){ - ms.status[m] += {tpl_uptodate(), checked(), bom_update_needed()}; + = importsAndExtendsAreBinaryCompatible(tm, imports_extends_m, ms); + if(m_compatible){ + ms = addProperty(m, ms, tpl_uptodate(), checked(), bom_update_needed()); + } } - } + } catch rascalTplVersionError(_,_,_,_): { + ms = addProperty(m, ms, tpl_version_error()); + // m_compatible remains false + }; + compatible_with_all_imports = compatible_with_all_imports && m_compatible; } } - any_rsc_changed = any(m <- component, rsc_changed() in ms.status[m]); - any_from_lib = any(m <- component, rsc_not_found() in ms.status[m]); + any_rsc_changed = any(m <- component, hasProperty(m, ms, rsc_changed())); + all_rsc_found = all(m <- component, hasNotProperty(m, ms, rsc_not_found())); + any_from_lib = any(m <- component, hasProperty(m, ms, tpl_from_library())); all_tmodels_uptodate = true; for(m <- component){ - if(tpl_uptodate() notin ms.status[m] && checked() notin ms.status[m]) + if(hasNotProperty(m, ms, tpl_uptodate(), checked())) all_tmodels_uptodate = false; } - recheckCond = !any_from_lib && (!compatible_with_all_imports || any_rsc_changed || !all_tmodels_uptodate); + recheckCond = !any_from_lib && all_rsc_found && (!compatible_with_all_imports || any_rsc_changed || !all_tmodels_uptodate); if(recheckCond){ - if(ms.compilerConfig.verbose){ - println("recheck : compatible_with_all_imports: , any_rsc_changed: , all_tmodels_uptodate: "); - } - + // if(ms.compilerConfig.verbose){ + // println("recheck : compatible_with_all_imports: , any_rsc_changed: , all_tmodels_uptodate: "); + // } + = rascalTModelComponent(component, ms); - moduleScopes += getModuleScopes(tm); + // moduleScopes += getModuleScopes(tm); map[str,TModel] tmodels_for_component = (); - map[str,set[str]] m_imports = (); - map[str,set[str]] m_extends = (); - for(m <- component, rsc_not_found() notin ms.status[m], MStatus::ignored() notin ms.status[m]){ - imports = { imp | <- ms.strPaths, m1 == m }; + map[MODID,set[MODID]] m_imports = (); + map[MODID,set[MODID]] m_extends = (); + for(m <- component, hasNotProperty(m, ms, rsc_not_found(), ModuleProperty::ignored())){ + imports = { imp | <- ms.paths, m1 == m, hasNotProperty(imp, ms, ModuleProperty::ignored())}; m_imports[m] = imports; - extends = { ext | <- ms.strPaths, m1 == m }; + extends = { ext | <- ms.paths, m1 == m, hasNotProperty(ext, ms, ModuleProperty::ignored()) }; m_extends[m] = extends; - invertedExtends = ms.strPaths<2,0>; + invertedExtends = ms.paths<2,0>; if(compilerConfig.warnUnused){ - // Look for unused imports or exports - usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole != moduleId(), path2module[l.path]?}; + // Look for unused imports or extends + //usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId(), path2module[l.path]?}; + usedModules = {l | loc l <- range(tm.useDef), l in tm.definitions, tm.definitions[l].idRole == moduleId()}; usedModules += {*invertedExtends[um] | um <- usedModules}; // use of an extended module via import list[Message] imsgs = []; = getModuleParseTree(m, ms); if(success){ if(compilerConfig.infoModuleChecked){ - imsgs += [info("Checked ", pt.header.name@\loc)]; + imsgs += [info("Checked ", pt.header.name@\loc)]; } check_imports: for(imod <- pt.header.imports, imod has \module){ iname = unescape(""); - if(!ms.status[iname]?){ - ms.status[iname] = {}; + inameId = moduleName2moduleId(iname); + if(hasProperty(inameId, ms, tpl_version_error(), rsc_not_found())){ + imsgs += error("Rascal TPL version error for ``, no source found", imod@\loc); } - if(iname notin usedModules){ + if(inameId notin usedModules){ if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){ continue check_imports; } - if(ms.moduleLocs[iname]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[iname].path, tm)){ + if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){ continue check_imports; } - if(ms.moduleLocs[iname]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[iname].path, tm)){ + if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){ continue check_imports; } - if((iname in component || checked() in ms.status[iname]) && rsc_not_found() notin ms.status[iname]){ - if(imod is \default){ + if((inameId in component || hasProperty(inameId, ms, checked())) && hasNotProperty(inameId, ms, rsc_not_found())){ + if(imod is \default){ imsgs += warning("Unused import of ``", imod@\loc); } //else { //TODO: maybe add option to turn off info messages? //imsgs += info("Extended module `` is unused in the current module", imod@\loc); @@ -326,50 +354,47 @@ ModuleStatus rascalTModelForLocs( } ms.messages[m] ? {} += toSet(tm.messages); - ms.status[m] += {tpl_uptodate(), checked()}; - if(!isEmpty([ e | e:error(_,_) <- ms.messages[m] ])){ - ms.status[m] += {check_error()}; + ms = addProperty(m, ms, tpl_uptodate(), checked()); + if(errorsPresent(ms.messages[m])){ + ms = addProperty(m, ms, check_error()); } } // prepare the TModels of the modules in this component for compilation - = prepareForCompilation(component, m_imports, m_extends, ms, moduleScopes, tm); + = prepareForCompilation(component, m_imports, m_extends, ms, tm); // generate code for the modules in this component - - for(str m <- component, MStatus::ignored() notin ms.status[m]){ + for(MODID m <- component, hasNotProperty(m, ms, ModuleProperty::ignored())){ = getModuleParseTree(m, ms); if(success){ - msgs = codgen(m, pt, transient_tms, ms, compilerConfig); - ms.messages[m] += toSet(msgs); - ms.status[m] += {code_generated()}; + lmsgs = codgen(m, pt, transient_tms, ms, compilerConfig); + ms.messages[m] += toSet(lmsgs); + ms = addProperty(m, ms, errorsPresent(lmsgs) ? code_generation_error() : code_generated()); } } - ms = doSaveModule(component, m_imports, m_extends, ms, moduleScopes, transient_tms, compilerConfig); + ms = doSaveModule(component, m_imports, m_extends, ms, transient_tms, compilerConfig); for(m <- component){ - ms.status[m] -= {rsc_changed()}; - ms.status[m] += {tpl_uptodate()}; + ms = deleteProperty(m, ms, rsc_changed()); + ms = addProperty(m, ms, tpl_uptodate()); } - } else { - for(m <- component){ - ms.status[m] += bom_update_needed(); - } } } } catch ParseError(loc src): { - for(str mname <- topModuleNames){ - ms.messages[mname] = { error("Parse error", src) }; + for(MODID mid <- topModuleIds){ + ms.messages[mid] = { error("Parse error", src) }; } - } catch rascalTplVersionError(str txt):{ - for(str mname <- topModuleNames){ - ms.messages[mname] = { error("", ms.moduleLocs[mname] ? |unknown:///|) }; + } catch rascalTplVersionError(str moduleName, loc tpl, str version, str txt):{ + for(MODID mid <- topModuleIds){ + causes = [ info("Module `` has outdated Rascal TPL version , no source found", tpl) ]; + ms.messages[mid] ? {} += { error("Import/extend of `` has ", + ms.moduleLocs[mid] ? |unknown:///|, + causes= causes) + }; } } catch Message msg: { - for(str mname <- topModuleNames){ - ms.messages[mname] = { error("During type checking: ", msg.at) }; + for(MODID mid <- topModuleIds){ + ms.messages[mid] = { error("During type checking: ", msg.at) }; } - } catch rascalBinaryNeedsRecompilation(str moduleName, Message msg): { - ms.messages[moduleName] = { msg }; } jobEnd(jobName); @@ -393,15 +418,17 @@ bool usesOrExtendsADT(str modulePath, str importPath, TModel tm){ return res; } -tuple[set[str], ModuleStatus] loadImportsAndExtends(str moduleName, ModuleStatus ms, Collector c, set[str] added){ +tuple[set[MODID], ModuleStatus] loadImportsAndExtends(set[MODID] moduleIds, ModuleStatus ms, Collector c, set[MODID] added){ pcfg = ms.pathConfig; - rel[str,str] contains = ms.strPaths<0,2>; - for(imp <- contains[moduleName]){ - if(imp notin added){ - if(tpl_uptodate() in ms.status[imp]){ + for( <- ms.paths, from in moduleIds){ + if(imp notin added, imp notin moduleIds){ + if(hasProperty(imp, ms, tpl_uptodate())){ added += imp; = getTModelForModule(imp, ms); try { + if(pathRole == importPath()){ + tm.defines = {d | d <- tm.defines, d.idRole == moduleVariableId() ==> d.defInfo.vis == publicVis() }; + } c.addTModel(tm); } catch wrongTplVersion(str reason): { ms.messages[imp] ? {} += { Message::error(reason, ms.moduleLocs[imp]) }; @@ -412,60 +439,56 @@ tuple[set[str], ModuleStatus] loadImportsAndExtends(str moduleName, ModuleStatus return ; } -tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleStatus ms){ - +tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleStatus ms){ pcfg = ms.pathConfig; compilerConfig = ms.compilerConfig; - modelName = intercalate(" + ", toList(moduleNames)); - map[str, Module] namedTrees = (); - for(str nm <- moduleNames){ - //ms.status[nm] = {}; - ms.messages[nm] = {}; + modelNames = [moduleId2moduleName(moduleId) | moduleId <- moduleIds]; + modelName = intercalate(" + ", modelNames); + map[MODID, Module] idTrees = (); + for(MODID mid <- moduleIds){ + mname = moduleId2moduleName(mid); + ms = removeTModel(mid, ms); mloc = |unknown:///|(0,0,<0,0>,<0,0>); try { - mloc = getRascalModuleLocation(nm, pcfg); - } catch e: { - err = error("Cannot get location for : ", mloc); - ms.messages[nm] = { err }; - ms.status[nm] += { rsc_not_found() }; - tm = tmodel(modelName=nm, messages=[ err ]); - ms = addTModel(nm, tm, ms); + mloc = getRascalModuleLocation(mid, ms); + if(endsWith(mloc.path, "tpl")){ + ms = addProperty(mid, ms, tpl_from_library()); + } + } catch Message err: { + ms.messages[mid] = { err }; + ms = addProperty(mid, ms, rsc_not_found()); + tm = tmodel(modelName=mname, messages=[ err ]); + ms = addTModel(mid, tm, ms); return ; } - if(mloc.extension != "rsc" || isModuleLocationInLibs(nm, mloc, pcfg)){ + if(!isRascalLogicalLoc(mloc) && (mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg))){ continue; } - = getModuleParseTree(nm, ms); + = getModuleParseTree(mid, ms); if(success){ tagsMap = getTags(pt.header.tags); - if(ignoreCompiler(tagsMap)) { - ms.messages[nm] ? {} += { Message::info("Ignoring module ", pt@\loc) }; - ms.status[nm] += MStatus::ignored(); - } else { - namedTrees[nm] = pt; + if(hasIgnoreCompilerTag(tagsMap)) { + ms.messages[mid] ? {} += { Message::info("Ignoring module ", pt.header.name@\loc) }; + ms = addProperty(mid, ms, ModuleProperty::ignored()); } + idTrees[mid] = pt; } //else { - // ms.messages[nm] += error("Cannot get parse tree for module ``", ms.moduleLocs[nm]); + // ms.messages[mid] += error("Cannot get parse tree for module ``", ms.moduleLocs[mid]); //} } - if(!isEmpty(namedTrees)){ + if(!isEmpty(idTrees)){ if(compilerConfig.verbose) { println("Checking ... "); } start_check = cpuTime(); resetClosureCounter(); + namedTrees = (moduleId2moduleName(mid) : idTrees[mid] | mid <- idTrees); c = newCollector(modelName, namedTrees, compilerConfig); c.push(key_pathconfig, pcfg); rascalPreCollectInitialization(namedTrees, c); - - added = {}; - for(str nm <- domain(namedTrees)){ - = loadImportsAndExtends(nm, ms, c, added); - added += a; - } - + = loadImportsAndExtends(domain(idTrees), ms, c, {}); for(str nm <- namedTrees){ collect(namedTrees[nm], c); } @@ -477,10 +500,10 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt s = newSolver(namedTrees, tm); tm = s.run(); } - tm.usesPhysicalLocs = true; - // for(mname <- moduleNames){ - // ms.messages[mname] = tm.messages; - // } + + for(mid <- moduleIds){ + ms.messages[mid] ? {} += toSet(tm.messages); + } //iprintln(tm.messages); check_time = (cpuTime() - start_check)/1000000; @@ -488,8 +511,9 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt if(compilerConfig.verbose) { println("Checked .... in ms"); } return ; } else { - ms.status[modelName]? {} += { tpl_saved() }; - = getTModelForModule(modelName, ms); + oneOfComponent = getOneFrom(moduleIds); + ms = addProperty(oneOfComponent, ms, tpl_saved()); + = getTModelForModule(oneOfComponent, ms); return ; } } @@ -498,18 +522,16 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt ModuleStatus rascalTModelForNames(list[str] moduleNames, RascalCompilerConfig compilerConfig, - list[Message] (str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen){ + list[Message] (MODID moduleId, lang::rascal::\syntax::Rascal::Module M, map[MODID,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen){ pcfg = compilerConfig.typepalPathConfig; mlocs = []; for(moduleName <- moduleNames){ try { mlocs += [ getRascalModuleLocation(moduleName, pcfg) ]; - } catch value e: { - mloc = |unknown:///|(0,0,<0,0>,<0,0>); - err = error("Cannot get location for : ", mloc); + } catch Message err: { ms = newModuleStatus(compilerConfig); - ms.messages[moduleName] = { err }; + ms.messages[moduleName2moduleId(moduleName)] = { err }; return ms; } } @@ -520,40 +542,28 @@ bool uptodateTPls(list[loc] candidates, list[str] mnames, PathConfig pcfg){ for(int i <- index(candidates)){ mloc = candidates[i]; = getTPLReadLoc(mnames[i], pcfg); - if(!found || lastModified(mloc) > lastModified(tpl)){ + if(!found || lastModified(mloc) >= lastModified(tpl)){ return false; } } return true; } -bool allModulesHaveValidTpls(list[loc] candidates, PathConfig pcfg){ - for(srcdir <- pcfg.srcs){ - for(loc mloc <- find(srcdir, "rsc")){ - try { - mname = getRascalModuleName(mloc, pcfg); - = getTPLReadLoc(mname, pcfg); - if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){ - return false; - } - } catch e:{ - return false; - } - } - } - return true; -} - -tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[loc] candidates, ModuleStatus ms){ +tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[MODID] candidates, ModuleStatus ms){ pcfg = ms.pathConfig; for(candidate <- candidates){ - mname = getRascalModuleName(candidate, pcfg); - = getTModelForModule(mname, ms); - imports_and_extends = ms.strPaths<0,2>[mname]; - = importsAndExtendsAreBinaryCompatible(tm, imports_and_extends, ms); - if(!compatible){ - return ; - } + try { + = getTModelForModule(candidate, ms); + if(found){ // TODO: needed? + imports_and_extends = tm.paths<0,2>[candidate]; // ms.paths<0,2>[candidate]; + = importsAndExtendsAreBinaryCompatible(tm, imports_and_extends, ms); + if(!compatible){ + return ; + } + } else { + return ; + } + } catch _: return ; } return ; } @@ -563,26 +573,101 @@ tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[loc] candidates, // name of the production has to mirror the Kernel compile result data ModuleMessages = program(loc src, set[Message] messages); +// Essential assumption: all changed modules are included in moduleLocs. +// If this is not the case, changed modules not in mlocs will not be checked. + list[ModuleMessages] check(list[loc] moduleLocs, RascalCompilerConfig compilerConfig){ - pcfg1 = compilerConfig.typepalPathConfig; pcfg1.classloaders = []; pcfg1.javaCompilerPath = []; + pcfg1 = compilerConfig.typepalPathConfig; compilerConfig.typepalPathConfig = pcfg1; ms = rascalTModelForLocs(moduleLocs, compilerConfig, dummy_compile1); - messagesNoModule = {}; - for(mname <- ms.messages, !ms.moduleLocs[mname]?){ - messagesNoModule += ms.messages[mname]; - } - return [ program(ms.moduleLocs[mname], ms.messages[mname] + messagesNoModule) | mname <- ms.messages, ms.moduleLocs[mname] ? ]; + + return reportModuleMessages(ms); +} + +list[ModuleMessages] reportModuleMessages(ModuleStatus ms){ + moduleIds = domain(ms.moduleLocs); + messagesNoModule = {*ms.messages[mid] | MODID mid <- ms.messages, (mid notin moduleIds || mid notin ms.moduleLocs)} + toSet(ms.pathConfig.messages); + msgs = [ program(ms.moduleLocs[mid], (ms.messages[mid] ? {}) + messagesNoModule) | MODID mid <- moduleIds ]; + if(isEmpty(msgs) && !isEmpty(messagesNoModule)){ + msgs = [ program(|unknown:///|, messagesNoModule) ]; + } + return msgs; } list[ModuleMessages] checkAll(loc root, RascalCompilerConfig compilerConfig){ return check(toList(find(root, "rsc")), compilerConfig); } +@synopsis{General commandline interface to the Rascal static checker} +@benefits{ +* The keyword fields of the main function generated commandline options, like `-libs` and `-srcs` +} +@pitfalls{ +* This interface is a strong stable contract between the checker and the rascal-maven-plugin. If +we remove or rename keyword fields here, then they the client code must be adapted as well. +} +int main( + list[loc] modules = [], // dirty modules to check + PathConfig pcfg = pathConfig(), + bool logPathConfig = false, + bool logImports = false, + bool verbose = false, + bool logWrittenFiles = false, + bool warnUnused = true, + bool warnUnusedFormals = true, + bool warnUnusedVariables = true, + bool warnUnusedPatternFormals = true, + bool infoModuleChecked = false, + bool errorsAsWarnings = false, + bool warningsAsErrors = false +) { + if (verbose) { + println("PathConfig:"); + iprintln(pcfg); + println("Dirty modules:"); + iprintln(modules); + } + + // resources should end up in the target binary folder + // if we want something intermediary instead, we'll have to copy + // them there at some point. + pcfg.generatedResources = pcfg.bin; + pcfg.generatedTestResources = pcfg.bin; + pcfg.generatedSources = pcfg.projectRoot + "gen/java"; + pcfg.generatedTestSources = pcfg.projectRoot + "gen/java"; + + rascalConfig = rascalCompilerConfig(pcfg, + logPathConfig = logPathConfig, + logImports = logImports, + verbose = verbose, + logWrittenFiles = logWrittenFiles, + warnUnused = warnUnused, + warnUnusedFormals = warnUnusedFormals, + warnUnusedVariables = warnUnusedVariables, + warnUnusedPatternFormals = warnUnusedPatternFormals, + infoModuleChecked = infoModuleChecked + ); + + list[ModuleMessages] messages = []; + + if (modules == []) { + //messages = [info("No modules to check.", |unknown:///|)]; + return 0; + } + else { + messages = check(modules, rascalConfig); + } + + flatMessages = [*msgs | program(_, msgs) <- messages]; + + return mainMessageHandler(flatMessages, projectRoot=pcfg.projectRoot, errorsAsWarnings=errorsAsWarnings, warningsAsErrors=warningsAsErrors); +} + // ---- Convenience check function during development ------------------------- -map[str, list[Message]] checkModules(list[str] moduleNames, RascalCompilerConfig compilerConfig) { +list[ModuleMessages] checkModules(list[str] moduleNames, RascalCompilerConfig compilerConfig) { ModuleStatus ms = rascalTModelForNames(moduleNames, compilerConfig, dummy_compile1); - return (mname : toList(msgs) | mname <- ms.messages, msgs := ms.messages[mname], !isEmpty(msgs)); + return reportModuleMessages(ms); } // -- calculate rename changes diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc index 93e78792fca..391ef186eef 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc @@ -39,10 +39,12 @@ extend analysis::typepal::FailMessage; extend lang::rascalcore::check::BasicRascalConfig; extend lang::rascalcore::check::ModuleLocations; +extend lang::rascalcore::CompilerPathConfig; +extend lang::rascalcore::check::LogicalLocations; extend analysis::typepal::Collector; -import lang::rascal::\syntax::Rascal; +extend lang::rascal::\syntax::Rascal; import DateTime; import Exception; import IO; @@ -66,43 +68,104 @@ void checkSupportedByParserGenerator(Tree t, Collector c){ }); } -data MStatus = +data ModuleProperty = rsc_not_found() - | tpl_not_found() | rsc_changed() - | parsed() + // | parsed() | parse_error() | module_dependencies_extracted() | checked() | check_error() | code_generated() + | code_generation_error() | tpl_uptodate() + | tpl_from_library() | tpl_saved() + | tpl_not_found() + | tpl_version_error() | ignored() | bom_update_needed() ; data ModuleStatus = moduleStatus( - rel[str, PathRole, str] strPaths, - rel[loc, PathRole, loc] paths, - map[str, Module] parseTrees, - list[str] parseTreeLIFO, - map[str, TModel] tmodels, - list[str] tmodelLIFO, - map[str,loc] moduleLocs, - map[str,datetime] moduleLastModified, - map[str, set[Message]] messages, - map[str, set[MStatus]] status, + rel[MODID, PathRole, MODID] paths, + map[MODID, Module] parseTrees, + list[MODID] parseTreeLIFO, + map[MODID, TModel] tmodels, + list[MODID] tmodelLIFO, + set[MODID] changedModules, + map[MODID,loc] moduleLocs, + map[MODID,datetime] moduleLastModified, + map[MODID, set[Message]] messages, + map[MODID, set[ModuleProperty]] status, PathConfig pathConfig, RascalCompilerConfig compilerConfig ); -ModuleStatus newModuleStatus(RascalCompilerConfig ccfg) = moduleStatus({}, {}, (), [], (), [], (), (), (), (), ccfg.typepalPathConfig, ccfg); +// p1 in status && p2 in status ... +bool hasProperty(MODID mid, ModuleStatus ms, ModuleProperty properties...){ + if(mid notin ms.status) return false; + mstatus = ms.status[mid]; + return !isEmpty(mstatus) && all(p <- properties, p in mstatus); +} + +// p1 in status || p2 in status ... +bool hasAnyProperty(MODID mid, ModuleStatus ms, ModuleProperty properties...){ + if(mid notin ms.status) return false; + mstatus = ms.status[mid]; + return !isEmpty(mstatus) && any(p <- properties, p in mstatus); +} + +// p1 notin status && p2 notin status ... +bool hasNotProperty(MODID mid, ModuleStatus ms, ModuleProperty properties...){ + if(mid notin ms.status) return true; + mstatus = ms.status[mid]; + return isEmpty(mstatus) || all(ModuleProperty p <- properties, p notin mstatus); +} + +ModuleStatus addProperty(MODID mid, ModuleStatus ms, ModuleProperty properties...){ + mstatus = mid notin ms.status ? {} : ms.status[mid]; + mstatus += toSet(properties); + ms.status[mid] = mstatus; + return ms; +} -bool isModuleLocationInLibs(str mname, loc l, PathConfig pcfg){ +ModuleStatus deleteProperty(MODID mid, ModuleStatus ms, ModuleProperty properties...){ + mstatus = mid notin ms.status ? {} : ms.status[mid]; + mstatus -= toSet(properties); + ms.status[mid] = mstatus; + return ms; +} + +ModuleStatus moduleStatus( // TEMPORARY FOR COMPATIBILITY BETWEEN VERSIONS + rel[str, PathRole, str] _strPaths, + rel[MODID, PathRole, MODID] _paths, + map[MODID, Module] _parseTrees, + list[MODID] _parseTreeLIFO, + map[MODID, TModel] _tmodels, + list[MODID] _tmodelLIFO, + set[MODID] _changedModules, + map[MODID,loc] _moduleLocs, + map[MODID,datetime] _moduleLastModified, + map[MODID, set[Message]] _messages, + map[MODID, set[ModuleProperty]] _status, + PathConfig pathConfig, + RascalCompilerConfig compilerConfig) + = newModuleStatus(pathConfig, compilerConfig); + +ModuleStatus newModuleStatus(PathConfig pcfg, TypePalConfig tcfg) + = moduleStatus({}, (), [], (), [], {}, (), (), (), (), pcfg, tcfg); + +ModuleStatus newModuleStatus() + = newModuleStatus(pathConfig(), tconfig()); + +ModuleStatus newModuleStatus(RascalCompilerConfig ccfg) + = newModuleStatus(ccfg.typepalPathConfig, ccfg); + +bool isModuleLocationInLibs(loc l, PathConfig pcfg){ + assert !isModuleId(l); res = l.extension == "tpl" || !isEmpty(pcfg.libs) && any(lib <- pcfg.libs, l.scheme == lib.scheme && l.path == lib.path); - //println("isModuleLocationInLibs: , ==\> "); return res; } @@ -110,17 +173,20 @@ bool traceTPL = false; bool traceParseTreeCache = false; bool traceTModelCache = false; -tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg){ - parts = split("::", qualifiedModuleName); +tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg) + = getTPLReadLoc(moduleName2moduleId(qualifiedModuleName), pcfg); + +tuple[bool,loc] getTPLReadLoc(MODID moduleId, PathConfig pcfg){ + assert isModuleId(moduleId) : "getTPLReadLoc: "; + parts = split("/", moduleId.path); parts = parts[0 .. size(parts)-1] + "$"; - res = intercalate("/", parts); fileName = intercalate("/", parts) + ".tpl"; - dirName = makeDirName(qualifiedModuleName); + dirName = makeDirName(parts); - for(loc dir <- [pcfg.resources, pcfg.bin] + pcfg.libs){ // In a bin or lib directory? - fileLoc = dir + "" + fileName; + for(loc dir <- [pcfg.generatedResources, pcfg.bin] + pcfg.libs){ // In a bin or lib directory? + fileLoc = dir + "" + fileName; if(exists(fileLoc)){ - if(traceTPL) println("getTPLReadLoc: =\> "); + if(traceTPL) println("getTPLReadLoc: =\> "); return ; } else { ;// if(traceTPL) @@ -130,21 +196,24 @@ tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg){ return ; } -tuple[bool,loc] getTPLWriteLoc(str qualifiedModuleName, PathConfig pcfg){ - fileName = ".tpl"; +tuple[bool,loc] getTPLWriteLoc(MODID moduleId, PathConfig pcfg){ + assert isModuleId(moduleId) : "getTPLWriteLoc: "; + qualifiedModuleName = moduleId2moduleName(moduleId); + fileName = ".tpl"; tplLoc = getGeneratedResourcesDir(qualifiedModuleName, pcfg) + fileName; return ; } datetime startOfEpoch = $2000-01-01T00:00:00.000+00:00$; -datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastModified, PathConfig pcfg){ - qualifiedModuleName = unescape(qualifiedModuleName); - try { - return moduleLastModified[qualifiedModuleName]; - } catch NoSuchKey(_): { +datetime getLastModified(MODID moduleId, ModuleStatus ms){ + assert isModuleId(moduleId) : "getLastModified: "; + qualifiedModuleName = moduleId2moduleName(moduleId); + if(moduleId in ms.moduleLastModified){ + return ms.moduleLastModified[moduleId]; + } else { try { - mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); + mloc = getRascalModuleLocation(moduleId, ms); return lastModified(mloc); } catch value _: { return startOfEpoch; @@ -152,155 +221,182 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM } } -// Check if a module is modified compared to a given timestamp -bool isModuleModified(str qualifiedModuleName, datetime timestamp, PathConfig pcfg){ - qualifiedModuleName = unescape(qualifiedModuleName); +// Check if a module is modified compared to a given timestamp in BOM +tuple[bool,ModuleStatus] isModuleModified(MODID moduleId, datetime timestamp, PathRole pathRole, ModuleStatus ms){ + pcfg = ms.pathConfig; try { - mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); - return lastModified(mloc) != timestamp; + mloc = getRascalModuleLocation(moduleId, ms); + bool modifiedChanged = lastModified(mloc) != timestamp; + if(pathRole == importPath()){ + return ; + } else { + // extendPath + // TODO: in the case of deep extend chains this might become inefficient since we are + // yoyo-ing up and down through the extend chains. + // Potential solution: maintain set of changed modules in ModuleStatus + = getTModelForModule(moduleId, ms); + if(found && tm.store[key_bom]? && rel[str,datetime,PathRole] bom := tm.store[key_bom]){ + for( <- bom){ + = isModuleModified(moduleName2moduleId(m), timestampInBom, pathRole, ms); + if(mchanged){ + return ; + } + } + return ; + } + return ; + } } catch value _: { - return false; + return ; } } -bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){ +bool tplOutdated(MODID moduleId, PathConfig pcfg){ try { + qualifiedModuleName = moduleId2moduleName(moduleId); mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); + if(endsWith(mloc.path, "tpl")) return false; = getTPLReadLoc(qualifiedModuleName, pcfg); lmMloc = lastModified(mloc); lmTpl = lastModified(tpl); res = !found || lmMloc > lmTpl; - //println("tplOutdated : ; mloc: \> tpl: : lmTpl>, (, )"); + // println("tplOutdated : ; mloc: \> tpl: : lmTpl>, (, )"); return res; - } catch e: { + } catch _: { return false; } } int parseTreeCacheSize = 20; -tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, ModuleStatus ms){ +Module dummyModule = [Module] "module DummyModule"; + +tuple[bool, Module, ModuleStatus] getModuleParseTree(MODID moduleId, ModuleStatus ms){ + assert isModuleId(moduleId) : "getModuleParseTree: "; pcfg = ms.pathConfig; - if(ms.parseTrees[qualifiedModuleName]?){ - if(traceParseTreeCache) println("*** using cached parse tree for "); - return ; + qualifiedModuleName = moduleId2moduleName(moduleId); + if(ms.parseTrees[moduleId]?){ + if(traceParseTreeCache) println("*** using cached parse tree for "); + return ; } else { - if(!ms.status[qualifiedModuleName]?){ - ms.status[qualifiedModuleName] = {}; - } - if(parse_error() notin ms.status[qualifiedModuleName]){ + if(hasNotProperty(moduleId, ms, parse_error())){ if(size(ms.parseTreeLIFO) >= parseTreeCacheSize){ ms.parseTrees = delete(ms.parseTrees, ms.parseTreeLIFO[-1]); if(traceParseTreeCache) println("*** deleting parse tree "); ms.parseTreeLIFO = ms.parseTreeLIFO[..-1]; } - ms.parseTreeLIFO = [qualifiedModuleName, *ms.parseTreeLIFO]; - mloc = |unknown:///|; + ms.parseTreeLIFO = [moduleId, *ms.parseTreeLIFO]; + mloc = moduleId; try { - mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); + mloc = getRascalModuleLocation(moduleId, ms); // Make sure we found a real source module (as opposed to a tpl module in a library - if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) { - ms.status[qualifiedModuleName] += {rsc_not_found()}; + if(isModuleLocationInLibs(mloc, pcfg)) { + ms = addProperty(moduleId, ms, tpl_from_library()); throw "No src or library module"; } - } catch _: { - ms.messages[qualifiedModuleName] ? {} += {error("Module not found", mloc)}; - mpt = [Module] "module "; - //ms.parseTrees[qualifiedModuleName] = mpt; - ms.moduleLocs[qualifiedModuleName] = mloc; - return ; + } catch e: { + ms.messages[moduleId] ? {} += {error("Module `` not found", mloc)}; + ms.moduleLocs[moduleId] = mloc; + return ; } - if(traceParseTreeCache) println("*** parsing from "); + if(traceParseTreeCache) println("*** parsing from "); try { - pt = parseModuleWithSpaces(mloc).top; - ms.parseTrees[qualifiedModuleName] = pt; - ms.moduleLocs[qualifiedModuleName] = getLoc(pt); - ms.status[qualifiedModuleName] += parsed(); + pt = parseModuleWithSpaces(mloc.top).top; + ms.parseTrees[moduleId] = pt; + newLoc = getLoc(pt); + ms.moduleLocs[moduleId] = newLoc; return ; - } catch _: {//ParseError(loc src): { - ms.messages[qualifiedModuleName] ? {} = {error("Parse error in ", mloc)}; - ms.moduleLocs[qualifiedModuleName] = mloc; - ms.status[qualifiedModuleName] += parse_error(); - return ", ms>; + } catch ParseError(loc src): { + ms.messages[moduleId] ? {} = {error("Parse error in ", src)}; + ms.moduleLocs[moduleId] = mloc; + ms = addProperty(moduleId, ms, parse_error()); + return ; } } - mpt = [Module] "module "; - ms.parseTrees[qualifiedModuleName] = mpt; - return ; + ms.parseTrees[moduleId] = dummyModule; + return ; } } +loc getRascalModuleLocation(MODID moduleId, ModuleStatus ms){ + if(moduleId in ms.moduleLocs){ + loc l = ms.moduleLocs[moduleId]; + if(!isRascalLogicalLoc(l)) return l; + } + return getRascalModuleLocation(moduleId2moduleName(moduleId), ms.pathConfig); +} + /* * We implement a caching mechanism for TModels with the following properties: * - tmodelCacheSize tmodels are cached. - * - TModels on file (.tpl) physical locations have been replaced by logical locations where possible. - * - When a TModel is read in, physical locations are NOT YET converted by logical logical locations - * and only do that when absolutely needed - * - The policy is to keep TModels in the cache in this unconverted logical form as long as possible. + * - In TModels on file (.tpl) physical locations have been replaced by logical locations where possible. + * - The policy is to always keep TModels in the cache in this logical form. * - During its presence in the cache, the BOM of a TModel may get updated. - * - When a TModel has to be removed from the cache, it is converted back to the logical form (if needed) and written back to file. + * - When a TModel has to be removed from the cache, it is written back to file (if needed). */ int tmodelCacheSize = 30; // should be > 0 ModuleStatus clearTModelCache(ModuleStatus ms){ - todo = { mname | mname <- ms.status, bom_update_needed() in ms.status[mname]}; + todo = { mname | mname <- ms.status, hasProperty(mname, ms, bom_update_needed())}; for(candidate <- ms.tmodelLIFO){ - ms = removeOldestTModelFromCache(ms, updateBOMneeded=true); + ms = removeOldestTModelFromCache(ms/*, updateBOMneeded=true*/); todo -= candidate; } for(candidate <- todo){ - ms = removeTModel(candidate, ms, updateBOMneeded=true); - ms.status[candidate] -= bom_update_needed(); + ms = removeTModel(candidate, ms/*, updateBOMneeded=true*/); + ms = deleteProperty(candidate, ms, bom_update_needed()); } return ms; } -rel[str,datetime,PathRole] makeBom(str qualifiedModuleName, ModuleStatus ms){ - map[str,datetime] moduleLastModified = ms.moduleLastModified; +rel[str,datetime,PathRole] makeBom(MODID moduleId, ModuleStatus ms){ pcfg = ms.pathConfig; - imports = ms.strPaths[qualifiedModuleName,importPath()]; - extends = ms.strPaths[qualifiedModuleName, extendPath()]; - return { < m, getLastModified(m, moduleLastModified, pcfg), importPath() > | m <- imports } - + { < m, getLastModified(m, moduleLastModified, pcfg), extendPath() > | m <- extends } - + { }; + qualifiedModuleName = moduleId2moduleName(moduleId); + imports = ms.paths[moduleId,importPath()]; + extends = ms.paths[moduleId, extendPath()]; + return { < mname, getLastModified(m, ms), importPath() > | m <- imports, mname := moduleId2moduleName(m) } + + { < mname, getLastModified(m, ms), extendPath() > | m <- extends, mname := moduleId2moduleName(m) } + + { }; } -ModuleStatus updateBOM(str qualifiedModuleName, ModuleStatus ms){ - if(rsc_not_found() in ms.status[qualifiedModuleName]){ +ModuleStatus updateBOM(MODID moduleId, ModuleStatus ms){ + if(hasAnyProperty(moduleId, ms, rsc_not_found(), tpl_from_library())){ return ms; } - = getTModelForModule(qualifiedModuleName, ms); + = getTModelForModule(moduleId, ms); if(found){ - newBom = makeBom(qualifiedModuleName, - ms); + newBom = makeBom(moduleId, ms); if(newBom != tm.store[key_bom]){ tm.store[key_bom] = newBom; - ms.status[qualifiedModuleName] -= tpl_saved(); - ms = addTModel(qualifiedModuleName, tm, ms); + ms = deleteProperty(moduleId, ms, tpl_saved(), bom_update_needed()); + ms = addTModel(moduleId, tm, ms); - if(ms.compilerConfig.logWrittenFiles) println("Updated BOM: "); + if(ms.compilerConfig.logWrittenFiles) println("Updated BOM: "); } } else{ - println("Could not update BOM of "); + println("Could not update BOM of "); } return ms; } -ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded = false){ - if(ms.status[candidate]? && tpl_saved() notin ms.status[candidate] && rsc_not_found() notin ms.status[candidate]){ +ModuleStatus removeTModel(MODID candidate, ModuleStatus ms, bool updateBOMneeded = false){ + assert isModuleId(candidate) : "removeTModel: "; + if( updateBOMneeded + || candidate in ms.tmodels + && !hasAnyProperty(candidate, ms, tpl_saved(), rsc_not_found(), tpl_from_library()) + ){ pcfg = ms.pathConfig; if(updateBOMneeded){ ms = updateBOM(candidate, ms); - } else { - ms.status[candidate] += bom_update_needed(); - } + } + ms = deleteProperty(candidate, ms, bom_update_needed()); = getTPLWriteLoc(candidate, pcfg); tm = ms.tmodels[candidate]; - tm = convertTModel2LogicalLocs(tm, ms.tmodels); - ms.status[candidate] += tpl_saved(); - if(ms.compilerConfig.verbose) println("Save before removing from cache "); + //tm.messages = toList(toSet(tm.messages) + ms.messages[candidate]); // TODO needed ? + ms = addProperty(candidate, ms, tpl_saved()); + if(ms.compilerConfig.verbose) println("Saving tmodel for before removing from cache"); try { writeBinaryValueFile(tplLoc, tm); if(traceTPL) println("Written "); @@ -323,13 +419,13 @@ ModuleStatus removeOldestTModelFromCache(ModuleStatus ms, bool updateBOMneeded = return ms; } -ModuleStatus addTModel (str qualifiedModuleName, TModel tm, ModuleStatus ms){ - if(traceTModelCache) println("addTModel: "); +ModuleStatus addTModel (MODID moduleId, TModel tm, ModuleStatus ms){ + if(traceTModelCache) println("addTModel: "); if(tmodelCacheSize > 0){ - ms.tmodels[qualifiedModuleName] = tm; - if(qualifiedModuleName notin ms.tmodelLIFO){ - ms.tmodelLIFO = [qualifiedModuleName, *ms.tmodelLIFO]; - while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != qualifiedModuleName){ + ms.tmodels[moduleId] = tm; + if(moduleId notin ms.tmodelLIFO){ + ms.tmodelLIFO = [moduleId, *ms.tmodelLIFO]; + while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != moduleId){ ms = removeOldestTModelFromCache(ms); } } @@ -339,47 +435,62 @@ ModuleStatus addTModel (str qualifiedModuleName, TModel tm, ModuleStatus ms){ private type[TModel] ReifiedTModel = #TModel; // precomputed for efficiency -tuple[bool, TModel, ModuleStatus] getTModelForModule(str qualifiedModuleName, ModuleStatus ms){ - if(traceTModelCache) println("getTModelForModule: "); - // if(qualifiedModuleName == "analysis::grammars::Ambiguity"){ - // println("getTModelForModule: analysis::grammars::Ambiguity"); - // } +tuple[bool, TModel, ModuleStatus] getTModelForModule(str moduleName, ModuleStatus ms) + = getTModelForModule(moduleName2moduleId(moduleName), ms); + +tuple[bool, TModel, ModuleStatus] getTModelForModule(MODID moduleId, ModuleStatus ms){ + assert isModuleId(moduleId) : "getTModelForModule: "; + if(traceTModelCache) println("getTModelForModule: "); pcfg = ms.pathConfig; - if(ms.tmodels[qualifiedModuleName]?){ - tm = convertTModel2PhysicalLocs(ms.tmodels[qualifiedModuleName]); - ms.tmodels[qualifiedModuleName] = tm; + if(moduleId in ms.tmodels){ + tm = ms.tmodels[moduleId]; return ; } - while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != qualifiedModuleName){ + while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != moduleId){ ms = removeOldestTModelFromCache(ms); } - - = getTPLReadLoc(qualifiedModuleName, pcfg); + qualifiedModuleName = moduleId2moduleName(moduleId); + = getTPLReadLoc(moduleId, pcfg); if(found){ if(traceTPL) println("*** reading tmodel "); + tmVersion = "0.0.0"; try { tm = readBinaryValueFile(ReifiedTModel, tplLoc); - if(tm.rascalTplVersion? && isValidRascalTplVersion(tm.rascalTplVersion)){ - tm.usesPhysicalLocs = false; // temporary - tm = convertTModel2PhysicalLocs(tm); - ms.tmodels[qualifiedModuleName] = tm; - mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); - if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)){ - ms.status[qualifiedModuleName] ? {} += {rsc_not_found()}; + tmVersion = tm.rascalTplVersion; + if(isValidRascalTplVersion(tmVersion)){ + ms.tmodels[moduleId] = tm; + mloc = getRascalModuleLocation(moduleId, ms); + if(isModuleLocationInLibs(mloc, pcfg)){ + ms = addProperty(moduleId, ms, tpl_from_library()); } - ms.status[qualifiedModuleName] ? {} += {tpl_uptodate(), tpl_saved()}; - ms.messages[qualifiedModuleName] = toSet(tm.messages); - ms.tmodelLIFO = [qualifiedModuleName, *ms.tmodelLIFO]; + ms = addProperty(moduleId, ms, tpl_uptodate(), tpl_saved()); + //do not include errors from tm in ModuleStatus to avoid that they become persistent + ms.tmodelLIFO = [moduleId, *ms.tmodelLIFO]; return ; } } catch e: { - return : ", tplLoc)]), ms>; + return : ", tplLoc)]), ms>; } - msg = " has outdated or missing Rascal TPL version (required: )"; - println("INFO: )"); - throw rascalTplVersionError(msg); + msg = "outdated Rascal TPL version (required: )"; + throw rascalTplVersionError(qualifiedModuleName, tplLoc, tmVersion, msg); + } + mloc = tplLoc; + try { + mloc = getRascalModuleLocation(moduleId, ms); + } catch _: /* ignore when this fails */; + return ", mloc)]), ms>; +} + +rel[loc from, PathRole r, loc to] getPaths(rel[MODID from, PathRole r, MODID to] paths, ModuleStatus ms){ + paths = {}; + for( <- paths){ + try { + mfrom = getRascalModuleLocation(from, ms); + mto = getRascalModuleLocation(to, ms); + paths += ; + } catch _: ;/* ignore non-existing module */ } - return ", |unknown:///|)]), ms>; + return paths; } int closureCounter = 0; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDataDeclaration.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDataDeclaration.rsc index 7386ed50c39..15e75acc00a 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDataDeclaration.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDataDeclaration.rsc @@ -35,7 +35,6 @@ extend lang::rascalcore::check::CheckerCommon; import lang::rascalcore::compile::util::Names; import lang::rascalcore::agrammar::definition::Attributes; -import lang::rascal::\syntax::Rascal; import IO; import Map; @@ -58,8 +57,8 @@ void dataDeclaration(Tags tags, Declaration current, list[Variant] variants, Col adtName = prettyPrintName(userType.name); tagsMap = getTags(tags); - if(ignoreCompiler(tagsMap)) { - c.report(info(current, "Ignoring declaration of ``")); + if(hasIgnoreCompilerTag(tagsMap)) { + c.report(info(adtName, "Ignoring declaration of ``")); return; } @@ -70,7 +69,7 @@ void dataDeclaration(Tags tags, Declaration current, list[Variant] variants, Col dt = isEmpty(typeParameters) ? defType(aadt(adtName, [], dataSyntax())) : defType(typeParameters, AType(Solver s) { return aadt(adtName, [ s.getType(tp)[closed=true] | tp <- typeParameters], dataSyntax()); }); - dt.md5 = md5Hash(""); + dt.md5 = normalizedMD5Hash(adtName, dataCounter); dataCounter += 1; if(!isEmpty(commonKeywordParameterList)) dt.commonKeywordFields = commonKeywordParameterList; c.define(adtName, dataId(), current, dt); @@ -119,8 +118,6 @@ AType(Solver) makeKeywordFieldType(str fieldName, KeywordFormal kwf) return fldType[alabel=fieldName]; }; - -int variantCounter = 0; void collect(current:(Variant) ` ( <{TypeArg ","}* arguments> )`, Collector c){ @@ -144,7 +141,7 @@ void collect(current:(Variant) ` ( <{TypeArg ","}* arguments> "); + dt.md5 = normalizedMD5Hash(currentModuleName, adtName, name, current); c.define(fieldName, fieldId(), ta.name, dt); } } @@ -155,22 +152,20 @@ void collect(current:(Variant) ` ( <{TypeArg ","}* arguments> "); + dt.md5 = normalizedMD5Hash(currentModuleName, adtName, dataCounter, name, consArity, kwfType, fieldName); c.define(fieldName, keywordFieldId(), kwf.name, dt); } scope = c.getScope(); c.enterScope(current); args = " " : ""> <}>"; - md5Contrib = "( )"; c.defineInScope(adtParentScope, prettyPrintName(name), constructorId(), name, defType(adt + formals + kwFormals + commonKwFormals, AType(Solver s){ adtType = s.getType(adt); kwFormalTypes = [kwField(s.getType(kwf.\type)[alabel=prettyPrintName(kwf.name)], prettyPrintName(kwf.name), currentModuleName, kwf.expression) | kwf <- kwFormals /*+ commonKwFormals*/]; formalTypes = [f is named ? s.getType(f)[alabel=prettyPrintName(f.name)] : s.getType(f) | f <- formals]; return acons(adtType, formalTypes, kwFormalTypes)[alabel=asUnqualifiedName(prettyPrintName(name))]; - })[md5 = md5Hash(md5Contrib)]); - variantCounter += 1; + })[md5 = normalizedMD5Hash(currentModuleName, adtName, dataCounter, name, args)]); c.fact(current, name); beginUseTypeParameters(c, closed=false); // The standard rules would declare arguments and kwFormals as variableId(); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc index 7d875e08ac5..d71b84ca302 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc @@ -31,23 +31,18 @@ module lang::rascalcore::check::CollectDeclaration Check all declarations in a module */ -extend lang::rascalcore::check::CheckerCommon; -extend lang::rascalcore::check::CollectDataDeclaration; -extend lang::rascalcore::check::CollectSyntaxDeclaration; - -extend lang::rascalcore::check::Fingerprint; import lang::rascalcore::check::PathAnalysis; //import lang::rascalcore::check::ScopeInfo; import lang::rascalcore::check::CollectOperators; import lang::rascalcore::check::CollectExpression; import lang::rascalcore::check::CollectPattern; - -import lang::rascal::\syntax::Rascal; import lang::rascalcore::agrammar::definition::Symbols; import lang::rascalcore::agrammar::definition::Attributes; import lang::rascalcore::check::SyntaxGetters; +import lang::rascalcore::check::ATypeBase; // seemingly redundant + import IO; import List; import Map; @@ -58,6 +53,12 @@ import String; import util::Reflective; +extend lang::rascalcore::check::CheckerCommon; +extend lang::rascalcore::check::CollectDataDeclaration; +extend lang::rascalcore::check::CollectSyntaxDeclaration; + +extend lang::rascalcore::check::Fingerprint; + // ---- Utilities ------------------------------------------------------------- @@ -65,22 +66,24 @@ import util::Reflective; int localFunctionCounter = 0; -void collect(Module current: (Module) `
`, Collector c){ +void collect(Module current, Collector c){ dataCounter = 0; - variantCounter = 0; nalternatives = 0; syndefCounter = 0; localFunctionCounter = 0; + header = current.header; + body = current.body; + mloc = getLoc(current); mname = prettyPrintName(header.name); checkModuleName(getLoc(current), header.name, c); tagsMap = getTags(header.tags); - if(ignoreCompiler(tagsMap)) { - c.report(info(current, "Ignoring module ")); + if(hasIgnoreCompilerTag(tagsMap)) { + c.report(info(header.name, "Ignoring module ")); return; } = getDeprecated(tagsMap); @@ -120,7 +123,7 @@ void collect(Header header, Collector c){ collect(header.imports, c); } -void collect(Body body, Collector c){ +void collect(lang::rascal::\syntax::Rascal::Body body, Collector c){ // First collect all variable declarations to ensure that forward references to // variables are available during type unference inside function bodies for(toplevel <- body.toplevels){ @@ -156,7 +159,7 @@ void collect(current: (Import) `extend ;`, Collector c){ void collect(current: (Declaration) ` <{Variable ","}+ variables> ;`, Collector c){ tagsMap = getTags(tags); - if(ignoreCompiler(tagsMap)) { + if(hasIgnoreCompilerTag(tagsMap)) { c.report(info(current, "Ignoring variable declaration")); return; } @@ -166,7 +169,7 @@ void collect(current: (Declaration) ` "); + dt.md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, varType, var.name); if(!isEmpty(tagsMap)) dt.tags = tagsMap; vname = prettyPrintName(var.name); if(isWildCard(vname)){ @@ -207,14 +210,14 @@ void collect(current: (Declaration) ` anno `")); return; } dt = defType([annoType, onType], AType(Solver s) { return aanno(pname, s.getType(onType), s.getType(annoType)); }); dt.vis = getVis(current.visibility, publicVis()); - dt.md5 = md5Hash(""); + dt.md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, annoType, onType, name); if(!isEmpty(tagsMap)) dt.tags = tagsMap; // if(isWildCard(pname)){ // c.report(error(name, "Annotation names starting with `_` are deprecated; only allowed to suppress warning on unused variables")); @@ -233,7 +236,7 @@ void collect(current: (KeywordFormal) ` = `, Collec ppfname = prettyPrintName(fname); modifiers = ["" | m <- signature.modifiers.modifiers]; tagsMap = getTags(decl.tags); - if(ignoreCompiler(tagsMap)) { - c.report(info(current, "Ignoring function declaration for ``")); + if(hasIgnoreCompilerTag(tagsMap)) { + c.report(info(fname, "Ignoring function declaration for ``")); return; } // Make md5hash of nested functions unique by using all surrounding signatures @@ -274,7 +277,7 @@ void collect(current: (FunctionDeclaration) ``, Collec for(FunctionDeclaration outerFun <- fstk){ allSignatures += md5Contrib4signature(outerFun.signature); } - md5Contrib = ""; + md5Contrib = [md5Contrib4Tags(decl.tags), decl.visibility, allSignatures]; if(size(fstk) > 1){ localFunctionCounter += 1; md5Contrib += "-"; @@ -287,7 +290,9 @@ void collect(current: (FunctionDeclaration) ``, Collec c.report(warning(signature, "Modifier `test` is missing")); } c.use(expectedName, {dataId(), constructorId()}); - c.requireSubType(expectedName, aadt("RuntimeException", [], dataSyntax()), error(expectedName, "Expected `RuntimeException`, found %t", expectedName)); + //c.requireSubType(expectedName, anode([]), error(expectedName, "Expected `RuntimeException`, found %t", expectedName)); + + //c.requireSubType(expectedName, aadt("RuntimeException", [], dataSyntax()), error(expectedName, "Expected `RuntimeException`, found %t", expectedName)); } = getDeprecated(tagsMap); @@ -414,7 +419,7 @@ void collect(current: (FunctionDeclaration) ``, Collec endUseBoundedTypeParameters(c); - dt.md5 = md5Hash(md5Contrib); + dt.md5 = normalizedMD5Hash(md5Contrib); c.defineInScope(parentScope, prettyPrintName(fname), functionId(), current, dt); c.leaveScope(decl); c.pop(currentFunction); @@ -652,9 +657,9 @@ void(Solver) makeReturnRequirement(Tree returnExpr, AType returnAType) void returnRequirement(Tree returnExpr, AType declaredReturnType, Solver s){ returnExprType = s.getType(returnExpr); - msg = p:/aparameter(_,_) := declaredReturnType - ? error(returnExpr, "Returned type %t is not always a subtype of expected return type %t", returnExprType, declaredReturnType) - : error(returnExpr, "Return type %t expected, found %t", declaredReturnType, returnExprType); + FailMessage msg = p:/aparameter(_,_) := declaredReturnType + ? error(returnExpr, "Returned type %t is not always a subtype of expected return type %t", returnExprType, declaredReturnType) + : error(returnExpr, "Return type %t expected, found %t", declaredReturnType, returnExprType); bindings = (); rsuffix = "r"; @@ -669,13 +674,18 @@ void returnRequirement(Tree returnExpr, AType declaredReturnType, Solver s){ try { returnExprTypeU = instantiateRascalTypeParameters(returnExpr, returnExprTypeU, bindings, s); } catch invalidInstantiation(str msg): { - s.report(error(returnExpr, "Cannot instantiate return type ``: " + msg)); + s.report(error(returnExpr, "Cannot instantiate return type ``: ")); } - - s.requireSubType(deUnique(returnExprTypeU), deUnique(declaredReturnTypeU), msg); + returnExprTypeDU = deUnique(returnExprTypeU); + declaredReturnTypeDU = deUnique(declaredReturnTypeU); + s.requireSubType(returnExprTypeDU, declaredReturnTypeDU, msg); if(!isVoidAType(declaredReturnTypeU)){ checkNonVoid(returnExpr, returnExprTypeU, s, "Return value"); } + if(overloadedAType(overloads) := returnExprTypeDU){ + filteredOverloads = checkAndFilterOverloads(returnExpr, overloads, declaredReturnTypeDU, s); + s.specializedFact(returnExpr, overloadedAType(filteredOverloads)); + } } // ---- return statement (closely interacts with function declaration) -------- @@ -701,15 +711,15 @@ void collect(current: (Statement) `return `, Collector c){ void collect (current: (Declaration) ` alias = ;`, Collector c){ aliasName = prettyPrintName(name); tagsMap = getTags(tags); - if(ignoreCompiler(tagsMap)) { - c.report(info(current, "Ignoring alias declaration for ``")); + if(hasIgnoreCompilerTag(tagsMap)) { + c.report(info(name, "Ignoring alias declaration for ``")); return; } // if(isWildCard(aliasName)){ // c.report(warning(name, "Alias names starting with `_` are deprecated; only allowed to suppress warning on unused variables")); // } - c.define(aliasName, aliasId(), current, defType([base], AType(Solver s) { return s.getType(base); })[md5 = md5Hash("")]); + c.define(aliasName, aliasId(), current, defType([base], AType(Solver s) { return s.getType(base); })[md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, name, base)]); c.enterScope(current); collect(tags, base, c); c.leaveScope(current); @@ -719,8 +729,8 @@ void collect (current: (Declaration) ` alias aliasName = prettyPrintName(name); tagsMap = getTags(tags); - if(ignoreCompiler(tagsMap)) { - c.report(info(current, "Ignoring alias declaration for ``")); + if(hasIgnoreCompilerTag(tagsMap)) { + c.report(info(name, "Ignoring alias declaration for ``")); return; } @@ -744,7 +754,7 @@ void collect (current: (Declaration) ` alias } return aalias(aliasName, params, s.getType(base)); - })[md5 = md5Hash("")]); + })[md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, name, parameters, base)]); collect(tags, c); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc index c9d91b76d1b..7403133a2cb 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc @@ -31,15 +31,9 @@ module lang::rascalcore::check::CollectExpression Check all expressions */ -extend lang::rascalcore::check::CheckerCommon; -extend lang::rascalcore::check::PathAnalysis; -extend lang::rascalcore::check::CollectLiteral; - import lang::rascalcore::check::CollectOperators; import lang::rascalcore::check::CollectStatement; -import lang::rascal::\syntax::Rascal; - import Map; import Node; import Set; @@ -47,6 +41,10 @@ import String; import util::Math; import IO; +extend lang::rascalcore::check::CheckerCommon; +extend lang::rascalcore::check::PathAnalysis; +extend lang::rascalcore::check::CollectLiteral; + // ---- Rascal literals, also see CollectLiteral void collect(current: (StringLiteral) ``, Collector c){ @@ -575,7 +573,7 @@ void collect(current: (Expression) ` ( <{Expression ","}* checkNonVoid(x, s, "Argument"); } - texp = s.getType(expression); + AType texp = s.getType(expression); if(isStrAType(texp)){ return computeExpressionNodeType(scope, actuals, keywordArguments, s); } @@ -621,13 +619,12 @@ void collect(current: (Expression) ` ( <{Expression ","}* for(ovl: <- overloads){ if(ft:afunc(AType ret, list[AType] formals, list[Keyword] kwFormals) := tp){ try { + validReturnTypeOverloads += ; + validOverloads += ovl; // TODO: turn this on after review of all @deprecated uses in the Rascal library library if(ft.deprecationMessage?){ s.report(warning(expression, "Deprecated function%v", isEmpty(ft.deprecationMessage) ? "" : ": " + ft.deprecationMessage)); } - - validReturnTypeOverloads += ; - validOverloads += ovl; } catch checkFailed(list[FailMessage] _): continue next_fun; catch NoBinding(): @@ -656,21 +653,22 @@ void collect(current: (Expression) ` ( <{Expression ","}* reportCallError(current, expression, actuals, keywordArguments, s); return avalue(); } else { - checkOverloadedConstructors(expression, validOverloads, s); + //checkOverloadedConstructors(expression, validOverloads, s); stexp = overloadedAType(validOverloads); if(texp != stexp) s.specializedFact(expression, stexp); - //s.report(error(current, "Unresolved call to overloaded function defined as %t", expression)); + // overloading of constructors is checked afterwards by checkOverloadedConstructors, + // maybe introduce a list of these overloaded cases for efficiency? return overloadedAType(validReturnTypeOverloads); } } } if(ft:afunc(AType ret, list[AType] formals, list[Keyword] kwFormals) := texp){ - // TODO; texp can get type value and then texp.deprecationMessage does not exist - if(texp.deprecationMessage?){ - s.report(warning(expression, "Deprecated function%v", isEmpty(texp.deprecationMessage) ? "": ": " + texp.deprecationMessage)); + res = checkArgsAndComputeReturnType(expression, scope, ret, formals, kwFormals, ft.varArgs, actuals, keywordArguments, [true | int _ <- index(formals)], s); + if(ft.deprecationMessage?){ + s.report(warning(expression, "Deprecated function%v", isEmpty(ft.deprecationMessage) ? "": ": " + ft.deprecationMessage)); } - return checkArgsAndComputeReturnType(expression, scope, ret, formals, kwFormals, ft.varArgs, actuals, keywordArguments, [true | int _ <- index(formals)], s); + return res; } if(acons(ret:aadt(adtName, list[AType] _,_), list[AType] fields, list[Keyword] kwFields) := texp){ res = computeADTType(expression, adtName, scope, ret, fields, kwFields, actuals, keywordArguments, [true | int _ <- index(fields)], s); @@ -733,28 +731,46 @@ void reportMissingNonTerminalCases(Expression current, rel[loc def, IdRole idRol } } -private void checkOverloadedConstructors(Expression current, rel[loc defined, IdRole role, AType atype] overloads, Solver s){ - if(current is qualifiedName){ - return; - } - coverloads = [ ovl | ovl <- overloads, isConstructorAType(ovl.atype) ]; - if(size(coverloads) > 1){ - ovl1 = coverloads[0]; - adtNames = { adtName | <- overloads, acons(ret:aadt(adtName, list[AType] _, _), list[AType] fields, list[Keyword] kwFields) := tp }; - qualifyHint = size(adtNames) > 1 ? "you may use as qualifier" : ""; - argHint = "make argument type(s) more precise"; - s.report(error(current, "Constructor %q is overloaded, to resolve it %v%v", - ovl1.atype.alabel, - qualifyHint, - argHint)); - } -} +// private void checkOverloadedConstructors(Expression current, rel[loc defined, IdRole role, AType atype] overloads, Solver s){ +// return; +// if((Expression) `` := current, size([nm | nm <- qn.names]) > 1){ +// return; +// } +// coverloads = [ ovl | ovl <- overloads, isConstructorAType(ovl.atype) ]; +// if(size(coverloads) > 1){ +// ovl1 = coverloads[0]; +// adtNames = { adtName | <- overloads, acons(ret:aadt(adtName, list[AType] _, _), list[AType] fields, list[Keyword] kwFields) := tp }; +// qualifyHint = size(adtNames) > 1 ? "you may use as qualifier" : ""; +// argHint = "make argument type(s) more precise"; +// s.report(error(current, "Constructor %q is overloaded, to resolve it %v%v", +// ovl1.atype.alabel, +// qualifyHint, +// argHint)); +// } +// } private tuple[rel[loc, IdRole, AType], list[bool]] filterOverloads(rel[loc, IdRole, AType] overloads, int arity){ + // println("filterOverloads: , "); rel[loc, IdRole, AType] filteredOverloads = {}; - prevFormals = []; + list[AType] prevFormals = []; list[bool] identicalFormals = [true | int _ <- [0 .. arity]]; + // Filter constructors first to avoid issues with vararg functions + for(ovl:<_, _, tp> <- overloads){ + if(acons(aadt(_, list[AType] _,_), list[AType] fields, list[Keyword] _) := tp){ + if(size(fields) == arity){ + filteredOverloads += ovl; + if(isEmpty(prevFormals)){ + prevFormals = fields; //<1>; + } else { + for(int i <- index(fields)) { + identicalFormals[i] = identicalFormals[i] && (comparable(prevFormals[i], fields[i]/*.fieldType*/)); + } + } + } + } + } + for(ovl:<_, _, tp> <- overloads){ if(ft:afunc(AType _, list[AType] formals, list[Keyword] _) := tp){ if(ft.varArgs ? (arity >= size(formals) - 1) : (arity == size(formals))) { @@ -770,18 +786,7 @@ private tuple[rel[loc, IdRole, AType], list[bool]] filterOverloads(rel[loc, IdRo } } } - else if(acons(aadt(_, list[AType] _,_), list[AType] fields, list[Keyword] _) := tp){ - if(size(fields) == arity){ - filteredOverloads += ovl; - if(isEmpty(prevFormals)){ - prevFormals = fields; //<1>; - } else { - for(int i <- index(fields)) { - identicalFormals[i] = identicalFormals[i] && (comparable(prevFormals[i], fields[i]/*.fieldType*/)); - } - } - } - } + } return ; } @@ -926,7 +931,7 @@ void collect(current: (Expression) `\< <{Expression ","}+ elements1> \>`, Collec elms = [ e | Expression e <- elements1 ]; c.calculate("tuple expression", current, elms, AType(Solver s) { - for(elm <- elms) checkNonVoid(elm, s, "Element of tuple"); + for(Expression elm <- elms) checkNonVoid(elm, s, "Element of tuple"); return atuple(atypeList([ s.getType(elm) | elm <- elms ])); }); collect(elements1, c); @@ -1001,7 +1006,7 @@ void collect(current: (QualifiedName) ``, Collector c){ if(!isEmpty(qualifier)){ c.useQualified([qualifier, base], name, {moduleVariableId(), functionId(), constructorId()}, dataOrSyntaxRoles + {moduleId()} ); } else { - if(!isEmpty(c.getStack(currentAdt))){ + if(c.isAlreadyDefined("", name) || !isEmpty(c.getStack(currentAdt))){ c.use(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), keywordFormalId(), fieldId(), keywordFieldId(), functionId(), constructorId()}); } else { c.useLub(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), keywordFormalId(), fieldId(), keywordFieldId(), functionId(), constructorId()}); @@ -1071,7 +1076,7 @@ void collect(current: (Expression) ` [ void collect(current: (Expression) ` . `, Collector c){ c.useViaType(expression, field, {fieldId(), keywordFieldId(), annoId()}); // DURING TRANSITION: allow annoIds - c.require("non void", expression, [], makeNonVoidRequirement(expression, "Base expression of field selection")); + c.require("non void or overloaded", expression, [], makeNonVoidNonOverloadedRequirement(expression, "Base expression of field selection")); c.fact(current, field); collect(expression, c); } @@ -1170,7 +1175,7 @@ private AType computeFieldProjectionType(Expression current, AType base, list[la list[str] fieldNames = [ ]; bool maintainFieldNames = tupleHasFieldNames(rt); - for (f <- fields) { + for (Field f <- fields) { if ((Field)`` := f) { int offset = toInt(""); if (!tupleHasField(rt, offset)) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectLiteral.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectLiteral.rsc index 74466451b1e..efd645e7657 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectLiteral.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectLiteral.rsc @@ -27,8 +27,6 @@ POSSIBILITY OF SUCH DAMAGE. module lang::rascalcore::check::CollectLiteral extend lang::rascalcore::check::CheckerCommon; -//extend lang::rascalcore::check::PathAnalysis; -import lang::rascal::\syntax::Rascal; import Exception; import ValueIO; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectOperators.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectOperators.rsc index 86c8294a2c7..7c00a508086 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectOperators.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectOperators.rsc @@ -26,18 +26,17 @@ POSSIBILITY OF SUCH DAMAGE. } @bootstrapParser module lang::rascalcore::check::CollectOperators - -extend lang::rascalcore::check::CheckerCommon; + import lang::rascalcore::check::BacktrackFree; import lang::rascalcore::check::CollectPattern; import lang::rascalcore::check::CollectExpression; -import lang::rascal::\syntax::Rascal; - import Node; import Set; +extend lang::rascalcore::check::CheckerCommon; + // ---- is void collect(current: (Expression) ` is `, Collector c){ @@ -151,7 +150,7 @@ void collect(current: (Expression) ` ?`, Collector c){ c.fact(current, abool()); checkIsDefinedArg(arg, c); collect(arg, c); - c.require("non void", arg, [], makeNonVoidRequirement(arg, "Argument of is-defined operator _ ?)")); + c.require("non void", arg, [], makeNonVoidRequirement(arg, "Argument of is-defined operator _ ?")); } // ---- negation diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectPattern.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectPattern.rsc index 9f7e84e4ce6..230d1f5f359 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectPattern.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectPattern.rsc @@ -34,8 +34,6 @@ module lang::rascalcore::check::CollectPattern extend lang::rascalcore::check::CheckerCommon; extend lang::rascalcore::check::CollectLiteral; - -import lang::rascal::\syntax::Rascal; import String; void collect(current: (Literal)``, Collector c){ @@ -72,7 +70,7 @@ void collect(current: (Pattern) `{ <{Pattern ","}* elements0> }`, Collector c){ c.fact(current, aset(avoid())); } c.push(patternContainer, "set"); - collect(elements0, c); + collect(elements0, c); c.pop(patternContainer); } @@ -148,7 +146,7 @@ void collect(current: (Pattern) ``, Collector c){ = splitQualifiedName(name); if(!isWildCard(base)){ if(inPatternNames(base, c)){ - c.useLub(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId()}); + c.useLub(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), constructorId()}); return; } c.push(patternNames, ); @@ -158,7 +156,7 @@ void collect(current: (Pattern) ``, Collector c){ c.define(base, formalId(), name, defLub([], AType(Solver _) { return avalue(alabel=unescape(prettyPrintBaseName(name))); })); } else { if(c.isAlreadyDefined(base, name)){ - c.use(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId()}); + c.use(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), constructorId()}); c.report(info(name, "Pattern variable %q has been declared outside pattern and its value will be used, add explicit declaration here if you want a new variable", name)); } else { tau = c.newTypeVar(name); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectStatement.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectStatement.rsc index bbba46ebaa6..8877c85fef6 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectStatement.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectStatement.rsc @@ -30,20 +30,20 @@ module lang::rascalcore::check::CollectStatement /* Check all statements */ -extend lang::rascalcore::check::CheckerCommon; import lang::rascalcore::check::CollectExpression; import lang::rascalcore::check::CollectPattern; import lang::rascalcore::check::CollectDeclaration; import lang::rascalcore::check::PathAnalysis; -import lang::rascal::\syntax::Rascal; - import List; import Set; import String; import Map; +extend lang::rascalcore::check::CheckerCommon; + + // Rascal statements // ---- assert ---------------------------------------------------------------- @@ -165,7 +165,7 @@ void collect(current: (PatternWithAction) ` =\> )` := c ? e : c | Expression c <- replacement.conditions]; } @@ -712,18 +712,26 @@ private void checkAssignment(Statement current, (Assignable) `", name)){ + c.use(name, variableRoles); + } else { + c.define(base, variableId(), name, defLub([statement], + AType(Solver s){ + // TODO: this seemingly redundant call is needed; suspicion: the interpreter does not + // handle the combination of return and possible exception thrown by s.getType properly + // It does work in other places though + AType x = s.getType(statement); + return s.getType(statement); + })); + } } else { - c.define(base, variableId(), name, defLub([statement, name], AType(Solver s){ - return computeAssignmentRhsType(statement, s.getType(name), operator, s.getType(statement), s); - })); + if(c.isAlreadyDefined("", name)){ + c.use(name, variableRoles); + } else { + c.define(base, variableId(), name, defLub([statement, name], AType(Solver s){ + return computeAssignmentRhsType(statement, s.getType(name), operator, s.getType(statement), s); + })); + } } } c.calculate("assignment to ``", current, [name, statement], // TODO: add name to dependencies? @@ -1036,6 +1044,11 @@ private AType computeDefaultAssignableType(Statement current, AType receiverType set[str] getNames(Statement s) = {"" | /QualifiedName nm := s}; +private void checkAssignment(Statement current, constructor: (Assignable) ` ( <{Assignable ","}+ arguments> )` , str operator, Statement rhs, Collector c){ + c.report(error(current, "Constructor assignable is not supported by the compiler")); + collect(name, arguments, c); +} + private void checkAssignment(Statement current, receiver: (Assignable) `\< <{Assignable ","}+ elements> \>`, str operator, Statement rhs, Collector c){ // Note we will use a list `taus` of type variables that is accessible in `makeDef` and `checkTupleElemAssignment` in order to make @@ -1168,7 +1181,7 @@ private list[QualifiedName] getReceiver((Assignable) `\< <{Assignable ","}+ elem private default list[QualifiedName] getReceiver(Assignable asg, Collector c) { throw rascalCheckerInternalError(getLoc(asg), "Unsupported assignable "); } -// ---- return, defined in Declarations, close to function declarations ------- +// ---- return, is defined in Declarations, close to function declarations ------- // ---- throw ----------------------------------------------------------------- diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc index 6ea46c9995d..eeeff2b1d47 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc @@ -39,8 +39,7 @@ import util::Maybe; import lang::rascalcore::agrammar::definition::Symbols; import lang::rascalcore::agrammar::definition::Attributes; - -import lang::rascal::\syntax::Rascal; +import lang::rascalcore::check::ATypeBase; // seemingly redundant // ---- syntax definition ----------------------------------------------------- @@ -77,9 +76,9 @@ void declareSyntax(SyntaxDefinition current, SyntaxRole syntaxRole, IdRole idRol nonterminalType = nonterminalType[parameters=[ aparameter("", treeType,closed=true)| tp <- typeParameters ]]; } - dt = defType(current is language && current.\start is present ? \start(nonterminalType) : nonterminalType); + dt = defType(/*current is language && current.\start is present ? \start(nonterminalType) : */nonterminalType); dt.vis = vis; - dt.md5 = md5Hash("" : "">"); + dt.md5 = normalizedMD5Hash(current is language ? "" : "", adtName, syndefCounter, defined); syndefCounter += 1; // Define the syntax symbol itself and all labelled alternatives as constructors @@ -121,7 +120,7 @@ void requireNonLayout(Tree current, AType u, str msg, Solver s){ } AProduction computeProd(Tree current, str name, AType adtType, ProdModifier* modifiers, list[Sym] symbols, Solver s) { - args = [s.getType(sym) | sym <- symbols]; + args = [s.getType(sym) | sym <- symbols, !(sym is empty)]; m2a = mods2attrs(modifiers); src = getLoc(current); p = isEmpty(m2a) ? prod(adtType, args/*, src=src*/) : prod(adtType, args, attributes=m2a/*, src=src*/); @@ -141,6 +140,16 @@ private bool isTerminalSym((Sym) ` @ `) = isTermin private bool isTerminalSym((Sym) ` $`) = isTerminalSym(symbol); private bool isTerminalSym((Sym) `^ `) = isTerminalSym(symbol); private bool isTerminalSym((Sym) ` ! `) = isTerminalSym(symbol); +private bool isTerminalSym((Sym) ` \>\> `) = isTerminalSym(symbol); +private bool isTerminalSym((Sym) ` !\>\> `) = isTerminalSym(symbol); +private bool isTerminalSym((Sym) ` \<\< `) = isTerminalSym(symbol); +private bool isTerminalSym((Sym) ` !\<\< `) = isTerminalSym(symbol); + +private bool isTerminalSym((Sym) `?`) = isTerminalSym(symbol); +private bool isTerminalSym((Sym) `( | <{Sym "|"}+ alternatives> )`) + = isTerminalSym(first) && all(alt <- alternatives, isTerminalSym(alt)); +private bool isTerminalSym((Sym) `( )`) = isTerminalSym(symbol1) && isTerminalSym(symbol2); + private bool isTerminalSym((Sym) `()`) = true; private default bool isTerminalSym(Sym s) = s is characterClass || s is literal || s is caseInsensitiveLiteral; @@ -148,7 +157,7 @@ private AType removeChainRule(aprod(prod(AType adt1,[AType adt2]))) = adt2 when private default AType removeChainRule(AType t) = t; void collect(current: (Prod) ` : `, Collector c){ - symbols = [sym | sym <- syms]; + symbols = [sym | sym <- syms, !(sym is empty)]; if( := c.top(currentAdt)){ // Compute the production type @@ -178,9 +187,8 @@ void collect(current: (Prod) ` : ")>"] + | sym <- symbols, !isTerminalSym(sym), tsym := s.getType(sym), isNonTerminalAType(tsym), @@ -191,7 +199,7 @@ void collect(current: (Prod) ` : ")); } else throw "Unexpected type of production: "; - })[md5=md5Hash("")]); + })[md5=normalizedMD5Hash(adt, current)]); beginUseTypeParameters(c,closed=true); c.push(currentAlternative, ", syms>); collect(symbols, c); @@ -203,7 +211,7 @@ void collect(current: (Prod) ` : `, Collector c){ - symbols = [sym | sym <- syms]; + symbols = [sym | sym <- syms, !(sym is empty)]; if( := c.top(currentAdt)){ c.calculate("unnamed production", current, adt + symbols, @@ -225,12 +233,12 @@ private AProduction associativity(AType nt, nothing(), AProduction p) = p; private default AProduction associativity(AType nt, just(AAssociativity a), AProduction p) = associativity(nt, a, {p}); void collect(current: (Prod) ` ( )`, Collector c){ - asc = AAssociativity::aleft(); + asc = aleft(); switch(""){ - case "assoc": asc = AAssociativity::aleft(); - case "left": asc = AAssociativity::aleft(); - case "non-assoc": asc = AAssociativity::\a-non-assoc(); - case "right": asc = AAssociativity::aright(); + case "assoc": asc = aleft(); + case "left": asc = aleft(); + case "non-assoc": asc = \a-non-assoc(); + case "right": asc = aright(); } if( := c.top(currentAdt)){ @@ -263,7 +271,7 @@ void collect(current: (Prod) ` | `, Collector c){ c.pop(inAlternative); if(isEmpty(c.getStack(inAlternative))){ nalternatives += 1; - c.define("alternative-", nonterminalId(), current, defType(current)[md5=md5Hash(unparseNoLayout(current))]); + c.define("alternative-", nonterminalId(), current, defType(current)[md5=normalizedMD5Hash(current)]); } } else { throw "collect alt: currentAdt not found"; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc index 557defab372..06fe3f669a4 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc @@ -33,7 +33,9 @@ module lang::rascalcore::check::CollectType Check type declarations */ -extend lang::rascalcore::check::ATypeInstantiation; + + +import lang::rascalcore::check::BasicRascalConfig; import lang::rascal::\syntax::Rascal; import lang::rascalcore::agrammar::definition::Symbols; @@ -47,6 +49,8 @@ import Node; import Set; import String; +extend lang::rascalcore::check::ATypeInstantiation; + void collect(current: (Type) `( )`, Collector c){ c.fact(current, tp); collect(tp, c); @@ -506,8 +510,6 @@ void collect(current:(Sym) ``, Collector c){ //c.fact(current, n); } -str md5ContribSym(Nonterminal n) = ""; - void collect(current:(Sym) `& `, Collector c){ pname = prettyPrintName(""); @@ -532,9 +534,6 @@ void collect(current:(Sym) `& `, Collector c){ c.fact(current, aparameter(prettyPrintName(""),treeType,closed=true)); } -str md5ContribSym((Sym) `& `) - = "R"; - void collect(current:(Sym) `[ <{Sym ","}+ parameters> ]`, Collector c){ params = [p | p <- parameters]; c.use(n, syntaxRoles); @@ -552,9 +551,6 @@ void collect(current:(Sym) `[ <{Sym ","}+ parameters> ]`, Collect endDefineOrReuseTypeParameters(c); } -str md5ContribSym((Sym) `[ <{Sym ","}+ parameters> ]`) - = "<}>"; - void collect(current:(Sym) `start [ ]`, Collector c){ c.use(n, syntaxRoles); c.calculate("start ", current, [n], @@ -566,16 +562,11 @@ void collect(current:(Sym) `start [ ]`, Collector c){ collect(n, c); } -str unparseNoLayout(Tree t){ - s = ""; - return "<}>"; -} - void collect(current:(Sym) ` `, Collector c){ un = unescape(""); - md5Contrib = ""; + md5Contrib = []; if(!isEmpty(c.getStack(currentAlternative)) && := c.top(currentAlternative)){ - md5Contrib += ""; + md5Contrib += [adt.defined, cname, syms]; } else { throw "Cannot compute md5 for "; } @@ -585,15 +576,12 @@ void collect(current:(Sym) ` `, Collector c){ AType(Solver s){ res = s.getType(symbol)[alabel=un]; return res; - })[md5=md5Hash("")]); + })[md5=normalizedMD5Hash([*md5Contrib, current])]); c.fact(current, n); collect(symbol, c); } -str md5ContribSym((Sym) ` `) - = "")>"; - // ---- literals void collect(current:(Sym) ``, Collector c){ @@ -640,9 +628,6 @@ void collect(current:(Sym) `+`, Collector c){ collect(symbol, c); } -str md5ContribSym((Sym) `+`) - = "PLUS"; - void collect(current:(Sym) `*`, Collector c) { if(isIterSym(symbol)) c.report(warning(current, "Nested iteration")); isLexical = isLexicalContext(c); @@ -654,9 +639,6 @@ void collect(current:(Sym) `*`, Collector c) { collect(symbol, c); } -str md5ContribSym((Sym) `*`) - = "STAR"; - void collect(current:(Sym) `{ }+`, Collector c){ if(isIterSym(symbol)) c.report(warning(current, "Nested iteration")); isLexical = isLexicalContext(c); @@ -671,11 +653,6 @@ void collect(current:(Sym) `{ }+`, Collector c){ collect(symbol, sep, c); } -str md5ContribSym((Sym) `{ }+`){ - res = "LCRCPLUS"; - return res; -} - void collect(current:(Sym) `{ }*`, Collector c){ if(isIterSym(symbol)) c.report(warning(current, "Nested iteration")); isLexical = isLexicalContext(c); @@ -690,11 +667,6 @@ void collect(current:(Sym) `{ }*`, Collector c){ collect(symbol, sep, c); } -str md5ContribSym((Sym) `{ }*`){ - res = "LCRCSTAR"; - return res; -} - void validateSeparators(Tree current, list[AType] separators, Solver s){ if(all(sep <- separators, isLayoutAType(sep))) s.report(warning(current, "At least one element of separators should be non-layout")); // TODO make error @@ -712,18 +684,12 @@ void collect(current:(Sym) `?`, Collector c){ collect(symbol, c); } -str md5ContribSym((Sym) `?`) - = "QUEST"; - void collect(current:(Sym) `( | <{Sym "|"}+ alternatives> )`, Collector c){ alts = first + [alt | alt <- alternatives]; c.calculate("alternative", current, alts, AType(Solver s) { return AType::alt({s.getType(alt) | alt <- alts}); }); collect(alts, c); } -str md5ContribSym((Sym) `( | <{Sym "|"}+ alternatives> )`) - = "L<}>R"; - void collect(current:(Sym) `( )`, Collector c){ seqs = first + [seq | seq <- sequence]; c.calculate("sequence", current, seqs, @@ -735,16 +701,10 @@ void collect(current:(Sym) `( )`, Collector c){ collect(seqs, c); } -str md5ContribSym((Sym) `( )`) - = "L<}>R"; - void collect(current:(Sym) `()`, Collector c){ c.fact(current, AType::aempty()); } -str md5ContribSym((Sym) `()`) - = "LR"; - // ---- conditionals void collect(current:(Sym) ` @ `, Collector c){ @@ -752,25 +712,16 @@ void collect(current:(Sym) ` @ `, Collector c collect(symbol, c); } -str md5ContribSym((Sym) ` @ `) - = "COL"; - void collect(current:(Sym) ` $`, Collector c){ c.calculate("end-of-line", current, [symbol], AType(Solver s) { return AType::conditional(s.getType(symbol), {ACondition::\a-end-of-line() }); }); collect(symbol, c); } -str md5ContribSym((Sym) ` $`) - = "END"; - void collect(current:(Sym) `^ `, Collector c){ c.calculate("begin-of-line", current, [symbol], AType(Solver s) { return AType::conditional(s.getType(symbol), {ACondition::\a-begin-of-line() }); }); collect(symbol, c); } -str md5ContribSym((Sym) `^ `) - = "BEGIN"; - void collect(current:(Sym) ` ! `, Collector c){ // TODO: c.use(n, {productionId()}); un = unescape(""); @@ -781,9 +732,6 @@ void collect(current:(Sym) ` ! `, Collector c){ collect(symbol, c); } -str md5ContribSym((Sym) ` ! `) - = "EXCEPT")>"; - bool isTerminal((Sym) ` @ `) = isTerminal(symbol); bool isTerminal((Sym) ` $`) = isTerminal(symbol); bool isTerminal((Sym) `^ `) = isTerminal(symbol); @@ -801,9 +749,6 @@ void collect(current:(Sym) ` \>\> `, Collector c){ collect(symbol, match, c); } -str md5ContribSym((Sym) ` \>\> `) - = "FOLLOW"; - void collect(current:(Sym) ` !\>\> `, Collector c){ c.calculate("notFollow", current, [symbol, match], AType(Solver s) { @@ -814,9 +759,6 @@ void collect(current:(Sym) ` !\>\> `, Collector c){ collect(symbol, match, c); } -str md5ContribSym((Sym) ` !\>\> `) - = "NOTFOLLOW"; - void collect(current:(Sym) ` \<\< `, Collector c){ c.calculate("precede", current, [match, symbol], AType(Solver s) { @@ -826,9 +768,6 @@ void collect(current:(Sym) ` \<\< `, Collector c){ collect(match, symbol, c); } -str md5ContribSym((Sym) ` \<\< `) - = "PRECEDE"; - void collect(current:(Sym) ` !\<\< `, Collector c){ c.calculate("notPrecede", current, [match, symbol], AType(Solver s) { @@ -838,9 +777,6 @@ void collect(current:(Sym) ` !\<\< `, Collector c){ collect(match, symbol, c); } -str md5ContribSym((Sym) ` !\<\< `) - = "NOTPRECEDE"; - void collect(current:(Sym) ` \\ `, Collector c){ c.calculate("exclude", current, [symbol, match], AType(Solver s) { @@ -853,9 +789,6 @@ void collect(current:(Sym) ` \\ `, Collector c){ collect(symbol, match, c); } -str md5ContribSym((Sym) ` \\ `) - = "NOTEQUAL"; - void collect(Sym current, Collector c){ throw "collect Sym, missed case "; } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ComputeType.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ComputeType.rsc index a7b41651656..b873af3163f 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ComputeType.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ComputeType.rsc @@ -36,9 +36,6 @@ extend lang::rascalcore::check::BuiltinFields; extend lang::rascalcore::check::ScopeInfo; import lang::rascalcore::check::ATypeUtils; -import lang::rascal::\syntax::Rascal; - -//import IO; import Map; import Set; import List; @@ -81,6 +78,33 @@ void checkNonVoid(Tree e, AType t, Solver s, str msg){ AType(Solver) makeGetSyntaxType(Type varType) = AType(Solver s) { Tree t = varType; return getSyntaxType(t, s); }; +rel[loc key, IdRole idRole, AType atype] + checkAndFilterOverloads(Tree expr, rel[loc key, IdRole idRole, AType atype] overloads, AType expected, Solver s){ + + rel[loc key, IdRole idRole, AType atype] filteredOverloads = {}; + rel[loc key, IdRole idRole, AType atype] unResolvedConstructorOverloads = {}; + for(tup:<_, _, tp> <- overloads){ + if(isValueAType(expected)){ + filteredOverloads += tup; + if(isConstructorAType(tp) || isADTAType(tp)){ + unResolvedConstructorOverloads += tup; + } + } else if(asubtype(tp, expected)){ + filteredOverloads += tup; + } else if(isConstructorAType(tp) || isADTAType(tp)){ + unResolvedConstructorOverloads += tup; + } + } + if(size(unResolvedConstructorOverloads) > 1){ + adtNames = { getADTName(tp) | <_, _, tp> <- unResolvedConstructorOverloads }; + qualifyHint = size(adtNames) > 1 ? "you may use as qualifier" : ""; + argHint = "make argument type(s) more precise"; + msg = error(expr, "Expression `` is overloaded, to resolve it "); + s.report(msg); + } + return filteredOverloads; +} + void(Solver) makeVarInitRequirement(Variable var) = void(Solver s){ Bindings bindings = (); @@ -97,7 +121,14 @@ void(Solver) makeVarInitRequirement(Variable var) initialTypeU = instantiateRascalTypeParameters(var, initialTypeU, bindings, s); if(s.isFullyInstantiated(initialTypeU)){ - s.requireSubType(initialTypeU, varTypeU, error(var, "Initialization of %q should be subtype of %t, found %t", "", var.name, deUnique(initialTypeU))); + if(overloadedAType(overloads) := initialTypeU){ + filteredOverloads = checkAndFilterOverloads(var.initial, overloads, varTypeU, s); + for(<_, _, tp> <- filteredOverloads){ + s.requireSubType(tp, varTypeU, error(var, "Initialization of %q should be subtype of %t, found overloaded type %t", "", var.name, deUnique(initialTypeU))); + } + } else { + s.requireSubType(initialTypeU, varTypeU, error(var, "Initialization of %q should be subtype of %t, found %t", "", var.name, deUnique(initialTypeU))); + } } else if(!s.unify(initialType, varType)){ s.requireSubType(initialTypeU, varTypeU, error(var, "Initialization of %q should be subtype of %t, found %t", "", var.name, deUnique(initialTypeU))); } @@ -108,6 +139,12 @@ void(Solver) makeVarInitRequirement(Variable var) void(Solver) makeNonVoidRequirement(Tree t, str msg) = void(Solver s) { checkNonVoid(t, s, msg ); }; +void(Solver) makeNonVoidNonOverloadedRequirement(Tree t, str msg) + = void(Solver s) { + checkNonVoid(t, s, msg ); + if(isOverloadedAType(s.getType(t))) s.report(error(t, msg + " is ambiguous and should be resolved")); + }; + AType unaryOp(str op, AType(Tree, AType, Solver) computeType, Tree current, AType t1, Solver s, bool maybeVoid=false){ requireFullyInstantiated(s, t1); @@ -310,10 +347,11 @@ AType computeADTReturnType(Tree current, str adtName, loc scope, list[AType] for } for(p <- parameters){ if(!bindings[p.pname]?){ - bindings[p.pname] = avalue(); // was: avoid() + bindings[p.pname] = avoid(); } } - if(!isEmpty(bindings)){ + if(!isEmpty(index_formals)){ + if(!isEmpty(bindings)){ try { ctype_old = makeUniqueTypeParams(s.getType(current), fsuffix); ctype_new = instantiateRascalTypeParameters(current, ctype_old, bindings, s); // changed @@ -328,11 +366,14 @@ AType computeADTReturnType(Tree current, str adtName, loc scope, list[AType] for return res; } catch invalidInstantiation(str msg): s.report(error(current, msg)); - } - try { + } + try { return deUnique(instantiateRascalTypeParameters(current, makeUniqueTypeParams(adtType, fsuffix), bindings, s)); - } catch invalidInstantiation(str msg): + } catch invalidInstantiation(str msg): s.report(error(current, msg)); + } else { + return instantiateRascalTypeParameters(current, adtType, bindings, s); + } return adtType; } @@ -359,15 +400,8 @@ void checkExpressionKwArgs(list[Keyword] kwFormals, (KeywordArguments[Expression continue next_arg; } } - availableKws = intercalateOr(["` `" | Keyword kw <- kwFormals]); - switch(size(kwFormals)){ - case 0: availableKws ="; no other keyword parameters available"; - case 1: availableKws = "; available keyword parameter: "; - default: - availableKws = "; available keyword parameters: "; - } - - msgs += error(kwa, "Undefined keyword argument %q%v", kwName, availableKws); + availableKws = [ info("Available keyword parameter: ` ` in ``", |unknown:///|) | Keyword kw <- kwFormals ]; + msgs += error(kwa, "Undefined keyword argument %q", kwName, causes=availableKws); } s.reports(msgs); } @@ -418,7 +452,10 @@ list[Keyword] computeKwFormals(list[KeywordFormal] kwFormals, Solver s){ list[Keyword] getCommonKeywords(aadt(str adtName, list[AType] parameters, _), loc scope, Solver s) { if(str currentModuleName := s.top(key_current_module)){ - return [ kwField(s.getType(kwf.\type)[alabel=prettyPrintName(kwf.name)], prettyPrintName(kwf.name), currentModuleName, kwf.expression) | d <- s.getDefinitions(adtName, scope, dataOrSyntaxRoles), kwf <- d.defInfo.commonKeywordFields ]; + return [ kwField(s.getType(kwf.\type)[alabel=prettyPrintName(kwf.name)], prettyPrintName(kwf.name), currentModuleName, kwf.expression) + | d <- s.getDefinitions(adtName, scope, dataOrSyntaxRoles), + kwf <- d.defInfo.commonKeywordFields + ]; } else { throw "getCommonKeywords: key_current_module not found"; } @@ -984,8 +1021,13 @@ private default AType getPatternType0(Pattern p, AType subjectType, loc scope, S // ---- set pattern private AType getPatternType0(current: (Pattern) `{ <{Pattern ","}* elements0> }`, AType subjectType, loc scope, Solver s){ - elmType = isSetAType(subjectType) ? getSetElementType(subjectType) : avalue(); - setType = aset(s.lubList([getPatternType(p, elmType, scope,s) | p <- elements0])); + subjectElmType = isSetAType(subjectType) ? getSetElementType(subjectType) : avalue(); + patElems = [p | p <- elements0]; + patElemTypes = [ getPatternType(p, subjectElmType, scope,s) | p <- patElems ]; + for(int i <- index(patElems)){ + s.requireComparable(patElemTypes[i], subjectElmType, error(patElems[i], "Pattern element should be comparable with %t, found %t", subjectElmType, patElemTypes[i])); + } + setType = aset(s.lubList(patElemTypes)); s.fact(current, setType); return setType; } @@ -993,10 +1035,15 @@ private AType getPatternType0(current: (Pattern) `{ <{Pattern ","}* elements0> } // ---- list pattern private AType getPatternType0(current: (Pattern) `[ <{Pattern ","}* elements0> ]`, AType subjectType, loc scope, Solver s){ - elmType = isListAType(subjectType) ? getListElementType(subjectType) : avalue(); - res = alist(s.lubList([getPatternType(p, elmType, scope, s) | p <- elements0])); - s.fact(current, res); - return res; + subjectElmType = isListAType(subjectType) ? getListElementType(subjectType) : avalue(); + patElems = [p | p <- elements0]; + patElemTypes = [ getPatternType(p, subjectElmType, scope,s) | p <- patElems ]; + for(int i <- index(patElems)){ + s.requireComparable(patElemTypes[i], subjectElmType, error(patElems[i], "Pattern element should be comparable with %t, found %t", subjectElmType, patElemTypes[i])); + } + listType = alist(s.lubList(patElemTypes)); + s.fact(current, listType); + return listType; } // ---- typed variable pattern @@ -1011,7 +1058,12 @@ private AType getPatternType0(current: (Pattern) ``, AType s base = prettyPrintBaseName(name); if(!isWildCard(base)){ nameType = s.getType(name); - nameType = instantiateAndCompare(current, nameType, subjectType, s); + if(isConstructorAType(nameType)){ + ; // complete constructor with arguments will be checked later on + } else { + // a name of a non-constructor type needs a check here + nameType = instantiateAndCompare(current, nameType, subjectType, s); + } return nameType[alabel=unescape("")]; } else return subjectType[alabel=unescape("")]; @@ -1077,6 +1129,7 @@ private AType getSplicePatternType(Pattern current, Pattern argument, AType sub } AType instantiateAndCompare(Tree current, AType patType, AType subjectType, Solver s){ + // println("instantiateAndCompare: , , "); if(!s.isFullyInstantiated(patType) || !s.isFullyInstantiated(subjectType)){ s.requireUnify(patType, subjectType, error(current, "Type of pattern could not be computed")); s.fact(current, patType); // <==== @@ -1100,7 +1153,7 @@ AType instantiateAndCompare(Tree current, AType patType, AType subjectType, Solv } patType = deUnique(patTypeU); subjectType = deUnique(subjectTypeU); - s.requireComparable(patType, subjectType, error(current, "Pattern should be comparable with %t, found %t", subjectType, patTypeU)); + s.requireComparable(patType, subjectType, error(current, "Pattern should be comparable with %t, found %t", subjectType, patType)); return patType; } @@ -1312,6 +1365,7 @@ private AType getPatternType0(current: (Pattern) `type ( , ] `, AType subjectType, loc scope, Solver s){ + getPatternType(p, avalue(), scope, s); // to force nested type calculations return s.getType(tp); } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Fingerprint.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Fingerprint.rsc index 043b3e6f473..2048d87deb2 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Fingerprint.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Fingerprint.rsc @@ -34,8 +34,6 @@ module lang::rascalcore::check::Fingerprint extend lang::rascalcore::check::CheckerCommon; -import lang::rascal::\syntax::Rascal; - import util::Reflective; import ValueIO; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc index ac102ab720f..9c1e54df3f9 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc @@ -34,10 +34,9 @@ module lang::rascalcore::check::Import extend lang::rascalcore::check::CheckerCommon; import lang::rascalcore::check::RascalConfig; - -import lang::rascal::\syntax::Rascal; import lang::rascalcore::check::ADTandGrammar; import lang::rascalcore::compile::CompileTimeError; +import lang::rascalcore::check::ModuleLocations; import DateTime; import IO; @@ -48,141 +47,171 @@ import Map; import Set; import Relation; import String; -import ValueIO; import analysis::graphs::Graph; import util::Reflective; import util::Benchmark; import lang::rascalcore::compile::util::Names; // TODO: refactor, this is an undesired dependency on compile -private str getRascalModuleName(loc mloc, map[loc,str] moduleStrs, PathConfig pcfg){ - if(moduleStrs[mloc]? ){ - return moduleStrs[mloc]; +ModuleStatus reportSelfImport(rel[loc, PathRole, loc] paths, ModuleStatus ms){ + for( <- paths){ + // mname = getRascalModuleName(from, ms.pathConfig); + ms.messages[from] ? {} += {error("Self import not allowed", from)}; + ms = addProperty(from, ms, check_error()); + } + return ms; +} + +ModuleStatus reportCycles(rel[MODID, PathRole, MODID]paths, rel[MODID,MODID] extendPlus, ModuleStatus ms){ + extendCycle = { m | <- extendPlus }; + if(size(extendCycle) > 0){ + for(mid <- extendCycle){ + mname = getRascalModuleName(mid, ms.pathConfig); + causes = [ info("Part of extend cycle ", emid) | emid <- extendCycle ]; + ms.messages[mid] ? {} += {error("Extend cycle not allowed", mid, causes=causes)}; + ms = addProperty(mid, ms, check_error()); + } + } + pathsPlus = { | <- paths}+; + + cyclicMixed = { mid1, mid2 + | <- pathsPlus, mid1 != mid2, + ( in paths && in paths + || in paths && in paths + ) + }; + + for(mid <- cyclicMixed){ + set[loc] cycle = { mid2 | <- pathsPlus, mid1 == mid, mid2 in cyclicMixed } + + { mid1 | <- pathsPlus, mid2 == mid , mid1 in cyclicMixed }; + if(size(cycle) > 0){ + causes = [ info("Part of mixed import/extend cycle ", eloc) | eloc <- cycle ]; + + ms.messages[mid] ? {} += { error("Mixed import/extend cycle not allowed", mid, causes=causes) }; + ms = addProperty(mid, ms, check_error()); + } } - return getRascalModuleName(mloc, pcfg); + return ms; } -// Complete a ModuleStatus by adding a contains relation that adds transitive edges for extend +// Complete a ModuleStatus +//- by adding transitive edges for extend paths +//- by checking circular dependencies +// TODO: reuse enhancePathRelation from RascalConfig here ModuleStatus completeModuleStatus(ModuleStatus ms){ pcfg = ms.pathConfig; - moduleStrs = invertUnique(ms.moduleLocs); - paths = ms.paths + { | <- ms.strPaths, ms.moduleLocs[a]?, ms.moduleLocs[b]? }; - extendPlus = { | <- paths}+; + paths = ms.paths; + ms = reportSelfImport(paths, ms); + + imports = { | <- paths}; + extendPlus = { | <- paths}+; + paths += { | <- extendPlus }; - paths += { | <- extendPlus }; + ms = reportCycles(paths, extendPlus, ms); - pathsPlus = { | <- paths}+; - - cyclicMixed = {mloc1, mloc2 | <- pathsPlus, mloc1 != mloc2, - in paths && in paths - || in paths && in paths }; + paths += { *{ | a <- extendPlus[b], c != a} + | < MODID c, MODID b> <- imports + }; - for(mloc <- cyclicMixed){ - mname = getRascalModuleName(mloc, moduleStrs, pcfg); - set[str] cycle = { getRascalModuleName(mloc2, moduleStrs, pcfg) | <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } + - { getRascalModuleName(mloc1, moduleStrs, pcfg) | <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed }; - if(size(cycle) > 1){ - ms.messages[mname] = (ms.messages[mname] ? {}) + error("Mixed import/extend cycle not allowed: {}", mloc); - } - } - paths += { *{| a <- extendPlus[b]} | < c, importPath(), b> <- paths }; - //paths += { | < c, importPath(), b> <- paths, <- paths}; - - ms.paths = paths; - - strPaths = {}; - for( <- paths){ - try { - mfrom = getRascalModuleName(from, moduleStrs, pcfg); - mto = getRascalModuleName(to, moduleStrs, pcfg); - strPaths += ; - } catch _: ;/* ignore non-existing module */ - } - ms.strPaths = strPaths; + ms.paths = paths; return ms; } -ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, RascalCompilerConfig ccfg){ - return completeModuleStatus((newModuleStatus(ccfg) | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames)); +ModuleStatus getImportAndExtendGraph(set[MODID] moduleIds, RascalCompilerConfig ccfg){ + return completeModuleStatus((newModuleStatus(ccfg) | getImportAndExtendGraph(moduleId, it) | moduleId <- moduleIds)); } -ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, ModuleStatus ms){ - return completeModuleStatus((ms | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames)); +ModuleStatus getImportAndExtendGraph(set[MODID] moduleIds, ModuleStatus ms){ + return completeModuleStatus((ms | getImportAndExtendGraph(moduleId, it) | moduleId <- moduleIds)); } -ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, RascalCompilerConfig ccfg){ - return completeModuleStatus(getImportAndExtendGraph(qualifiedModuleName, newModuleStatus(ccfg))); +ModuleStatus getImportAndExtendGraph(MODID moduleId, RascalCompilerConfig ccfg){ + return completeModuleStatus(getImportAndExtendGraph(moduleId, newModuleStatus(ccfg))); } -ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){ -//println("getImportAndExtendGraph: "); +ModuleStatus getImportAndExtendGraph(MODID moduleId, ModuleStatus ms){ + assert isModuleId(moduleId): "getImportAndExtendGraph: "; pcfg = ms.pathConfig; - qualifiedModuleName = unescape(qualifiedModuleName); + qualifiedModuleName = moduleId2moduleName(moduleId); - if(!ms.status[qualifiedModuleName]?){ - ms.status[qualifiedModuleName] = {}; - } - - if(module_dependencies_extracted() in ms.status[qualifiedModuleName]){ + if(hasProperty(moduleId, ms, module_dependencies_extracted())){ return ms; } - ms.status[qualifiedModuleName] += module_dependencies_extracted(); + ms = addProperty(moduleId, ms, module_dependencies_extracted()); - = getTModelForModule(qualifiedModuleName, ms); - if(found){ - ms.paths = tm.paths; + try { + = getTModelForModule(moduleId, ms); + if(found){ allImportsAndExtendsValid = true; - rel[str, PathRole] localImportsAndExtends = {}; + rel[loc, PathRole] localImportsAndExtends = {}; - if(!ms.moduleLastModified[qualifiedModuleName]?){ - ms.moduleLastModified[qualifiedModuleName] = getLastModified(qualifiedModuleName, ms.moduleLastModified, pcfg); + if(!ms.moduleLastModified[moduleId]?){ + ms.moduleLastModified[moduleId] = getLastModified(moduleId, ms); } if(tm.store[key_bom]? && rel[str,datetime,PathRole] bom := tm.store[key_bom]){ for( <- bom){ - if(!ms.status[m]?){ - ms.status[m] = {}; - } - if(m != qualifiedModuleName){ - localImportsAndExtends += ; + mid = moduleName2moduleId(m); + if(mid != moduleId){ + localImportsAndExtends += ; } - if(isModuleModified(m, timestampInBom, pcfg)){ + + dependencyChanged = (mid != moduleId) && !isEmpty(ms.changedModules & range(ms.paths[mid])); + //if(dependencyChanged) println("processing BOM of and consider , dependencyChanged: "); + = isModuleModified(mid, timestampInBom, pathRole, ms); + if(dependencyChanged || mchanged){ allImportsAndExtendsValid = false; - ms.status[m] += rsc_changed(); - ms.status[m] -= {tpl_uptodate(), checked()}; - ms.status[qualifiedModuleName] -= tpl_saved(); + ms = addProperty(mid, ms, rsc_changed()); + ms = deleteProperty(mid, ms, tpl_uptodate(), checked()); + ms = deleteProperty(moduleId, ms, tpl_saved()); + ms.messages[moduleId] = {}; if(ms.compilerConfig.verbose){ - println("--- using (most recent) version of , + println("--- using (most recent) version of , ' older version was used in previous check of "); } } } } else { - throw "No bill-of-materials found for "; + throw "No bill-of-materials found for "; } if(!allImportsAndExtendsValid){ // Check that the source code of qualifiedModuleName is available mloc = |unknown:///|(0,0,<0,0>,<0,0>); try { try { - mloc = getRascalModuleLocation(qualifiedModuleName, pcfg); - } catch e: { - err = error("Cannot get location for : ", mloc); - ms.messages[qualifiedModuleName] = { err }; - tm = tmodel(modelName=qualifiedModuleName, messages=[ err ]); - ms = addTModel(qualifiedModuleName, tm, ms); - ms.status[qualifiedModuleName] += { rsc_not_found() }; + mloc = getRascalModuleLocation(moduleId, ms); + if(endsWith(mloc.path, "tpl")){ + ms = addProperty(moduleId, ms, tpl_from_library()); + } + } catch Message err: { + ms.messages[moduleId] = { err }; + tm = tmodel(modelName=moduleId2moduleName(moduleId), messages=[ err ]); + ms = addTModel(moduleId, tm, ms); + ms = addProperty(moduleId, ms, rsc_not_found()); return ms; } - if(mloc.extension != "rsc" || isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) throw "No src or library module 1"; //There is only a tpl file available + if(!isRascalLogicalLoc(mloc) && (mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg))) throw "No src or library module 1"; //There is only a tpl file available } catch value _:{ = isCompatibleBinaryLibrary(tm, ms); + incompatibleNames = [ getModuleNameFromAnyLogical(imod) | MODID imod <- incompatible ]; if(!isEmpty(incompatible)){ - txt = "Recompilation or reconfiguration needed: binary module `` uses incompatible module(s) "; - msg = error(txt, mloc); + causes = [ info("Module is incompatible with ", incomp) | incomp <- incompatible ]; + txt = "Review of dependencies, reconfiguration or recompilation needed: binary module `` depends (indirectly) on incompatible module(s) "; + msg = error(txt, mloc, causes=causes); + tm.messages += [msg]; - ms.messages[qualifiedModuleName] ? {} += { msg }; - throw rascalBinaryNeedsRecompilation(qualifiedModuleName, msg); + ms.messages[moduleId] ? {} += { msg }; + + txt2 = "Review of dependencies, reconfiguration or recompilation needed: imported/extended binary module `` depends (indirectly) on incompatible module(s)"; + + usingModules = {user | <- ms.paths<0,2>*}; + for(user <- usingModules){ + mloc = getRascalModuleLocation(user, ms); + if(!isModuleLocationInLibs(mloc, pcfg)){ + msg2 = error(txt2, mloc, causes=causes); + ms.messages[user] ? {} += { msg2 }; + } + } } else { allImportsAndExtendsValid = true; if(ms.compilerConfig.verbose){ @@ -192,58 +221,67 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){ } } if(allImportsAndExtendsValid){ - ms.status[qualifiedModuleName] += {tpl_uptodate(), checked()}; //TODO: maybe check existence of generated java files - ms.moduleLocs += tm.moduleLocs; + ms = addProperty(moduleId, ms, tpl_uptodate(), checked(), tpl_saved(), module_dependencies_extracted()); //TODO: maybe check existence of generated java files + ms.moduleLocs += (moduleName2moduleId(mname) : tm.moduleLocs[mname] | mname <- tm.moduleLocs); // TODO: or not? ms.paths += tm.paths; - ms.strPaths += { | <- localImportsAndExtends }; - ms.status[qualifiedModuleName] += module_dependencies_extracted(); - ms.messages[qualifiedModuleName] ? {} += toSet(tm.messages); - for( <- localImportsAndExtends, isEmpty({module_dependencies_extracted()} & ms.status[imp]) ){ - ms.status[imp] -= tpl_saved(); + ms.messages[moduleId] ? {} += toSet(tm.messages); + for( <- localImportsAndExtends, hasNotProperty(imp, ms, module_dependencies_extracted()) ){ + ms = deleteProperty(imp, ms, tpl_saved()); ms = getImportAndExtendGraph(imp, ms); } - return ms; + return completeModuleStatus(ms); } + } + } catch rascalTplVersionError(str moduleName, loc tplLoc, str version, str txt):{ + ms = addProperty(moduleName2moduleId(moduleName), ms, tpl_version_error()); + // Need to recheck since TModel uses incompatible TPL version } - - if(rsc_not_found() in ms.status[qualifiedModuleName]){ + if(hasAnyProperty(moduleId, ms, rsc_not_found(), tpl_from_library())){ + if(hasProperty(moduleId, ms, tpl_version_error())){ + iName = moduleId2moduleName(moduleId); + for( <- ms.paths){ + mName = moduleId2moduleName(m); + ms.messages[m] ? {} += { error("For import/extend `` of `` is no source available and TPL has wrong version", m) }; + } + } return ms; } - = getModuleParseTree(qualifiedModuleName, ms); + = getModuleParseTree(moduleId, ms); if(success){ - = getModulePathsAsStr(pt, ms); + = getModulePaths(pt, ms); - for(<_, kind, imp> <- imports_and_extends, rsc_not_found() notin ms.status[imp]){ - ms.strPaths += {}; + for(<_, _, imp> <- imports_and_extends, hasNotProperty(imp, ms, rsc_not_found())){ ms = getImportAndExtendGraph(imp, ms); } } else { - ms.status[qualifiedModuleName] += rsc_not_found(); + ms = addProperty(moduleId, ms, rsc_not_found()); } - return ms; + return completeModuleStatus(ms); } ModuleStatus getInlineImportAndExtendGraph(Tree pt, RascalCompilerConfig ccfg){ ms = newModuleStatus(ccfg); visit(pt){ - case m: (Module) `
`: { + case Module m: { + header = m.header; + body = m.body; qualifiedModuleName = prettyPrintName(header.name); - ms.moduleLocs[qualifiedModuleName] = getLoc(m); - = getModulePathsAsStr(m, ms); + ms.moduleLocs[moduleName2moduleId(qualifiedModuleName)] = getLoc(m); + = getModulePaths(m, ms); } } return completeModuleStatus(ms); } // Is binary library module compatible with its dependencies (originating from imports and extends)? -tuple[list[str], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatus ms){ +tuple[list[MODID], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatus ms){ libName = lib.modelName; set[loc] libLogical = domain(lib.logical2physical); - set[loc] libDefines = { l | l <- libLogical, getModuleFromLogical(l) == libName }; + set[loc] libDefines = { l | l <- libLogical, getModuleNameFromAnyLogical(l) == libName }; set[loc] libDependsOn = libLogical - libDefines; - set[str] libDependsOnModules = { getModuleFromLogical(l) | l <- libDependsOn }; + set[str] libDependsOnModules = { getModuleNameFromAnyLogical(l) | l <- libDependsOn }; set[loc] dependentsProvide = {}; for(m <- libDependsOnModules){ = getTModelForModule(m, ms); @@ -251,35 +289,44 @@ tuple[list[str], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatu dependentsProvide += domain(tm.logical2physical); } } + unsatisfied = libDependsOn - dependentsProvide; + if(isEmpty(unsatisfied)){ //println("isCompatibleBinaryLibrary : satisfied"); return <[], ms>; } else { - //println("isCompatibleBinaryLibrary, unsatisfied: "); - incompatibleModules = { split("/", u.path)[1] | u <- unsatisfied }; - return ; + // println("BOM of :"); iprintln(lib.store[key_bom]); + // println("libDependsOn: + // 'dependentsProvide: + // 'unstatisfied: + // "); + // println("isCompatibleBinaryLibrary, unsatisfied ()"); + + //incompatibleModuleNames = { moduleId2moduleName(u) | u <- unsatisfied }; + return ; } } // Example: |rascal+function:///util/Math/round$d80e373d64c01979| ==> util::Math // Example: |rascal+module:///lang/rascal/syntax/Rascal| -> lang::rascal::syntax::Rascal -str getModuleFromLogical(loc l){ +str getModuleNameFromAnyLogical(loc l){ i = findLast(l.path[1..], "/"); res = (l.scheme == "rascal+module" || i < 0) ? l.path[1..] : l.path[1..i+1]; res = replaceAll(res, "/", "::"); - //println("getModuleFromLogical: -\> "); + //println("getModuleNameFromAnyLogical: -\> "); return res; } -tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[str] importsAndExtends, ModuleStatus ms){ +tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[MODID] importsAndExtends, ModuleStatus ms){ moduleName = tm.modelName; physical2logical = invertUnique(tm.logical2physical); - - modRequires = { lg | l <- range(tm.useDef), - physical2logical[l]?, lg := physical2logical[l], - moduleName !:= getModuleFromLogical(lg) }; + modRequires = {lg | l <- range(tm.useDef), + l in physical2logical, + lg := physical2logical[l], + moduleName != getModuleNameFromAnyLogical(lg) + }; provided = {}; if(!isEmpty(modRequires)){ for(m <- importsAndExtends){ @@ -290,8 +337,6 @@ tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[st } } - //println(" requires "); - if(isEmpty(modRequires - provided)){ //println("importsAndExtendsAreBinaryCompatible : satisfied"); return ; @@ -301,22 +346,16 @@ tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[st } } -tuple[ModuleStatus, rel[str, PathRole, str]] getModulePathsAsStr(Module m, ModuleStatus ms){ +tuple[ModuleStatus, rel[loc, PathRole, loc]] getModulePaths(Module m, ModuleStatus ms){ moduleName = unescape(""); + MODID moduleId = moduleName2moduleId(moduleName); imports_and_extends = {}; for(imod <- m.header.imports, imod has \module){ iname = unescape(""); - imports_and_extends += ; - ms.status[iname] = ms.status[iname] ? {}; - try { - mloc = getRascalModuleLocation(iname, ms.pathConfig); - } catch str msg: { - err = error("Cannot get location for : ", imod@\loc); - ms.messages[moduleName] ? {} += { err }; - ms.status[iname] += { rsc_not_found() }; - } + inameId = moduleName2moduleId(iname); + imports_and_extends += ; } - ms.strPaths += imports_and_extends; + ms.paths += imports_and_extends; return ; } @@ -325,114 +364,112 @@ tuple[ModuleStatus, rel[str, PathRole, str]] getModulePathsAsStr(Module m, Modul map[str, loc] getModuleScopes(TModel tm) = (id: defined | <- tm.defines); -loc getModuleScope(str qualifiedModuleName, map[str, loc] moduleScopes, PathConfig pcfg){ - if(moduleScopes[qualifiedModuleName]?){ - return moduleScopes[qualifiedModuleName]; - } - for(l <- range(moduleScopes)){ - if(getRascalModuleName(l, pcfg) == qualifiedModuleName){ - return l; - } - } - throw "No module scope found for "; -} - -tuple[map[str,TModel], ModuleStatus] prepareForCompilation(set[str] component, map[str,set[str]] m_imports, map[str,set[str]] m_extends, ModuleStatus ms, map[str,loc] moduleScopes, TModel tm){ +// loc getModuleScope(str qualifiedModuleName, map[str, loc] moduleScopes, PathConfig pcfg){ +// if(moduleScopes[qualifiedModuleName]?){ +// return moduleScopes[qualifiedModuleName]; +// } +// for(l <- range(moduleScopes)){ +// if(getRascalModuleName(l, pcfg) == qualifiedModuleName){ +// return l; +// } +// } +// throw "No module scope found for "; +// } + +tuple[map[MODID,TModel], ModuleStatus] prepareForCompilation(set[MODID] component, map[MODID,set[MODID]] m_imports, map[MODID,set[MODID]] m_extends, ModuleStatus ms, TModel tm){ //map[str,TModel] tmodels = (); //ms.tmodels; pcfg = ms.pathConfig; dependencies_ok = true; - for(m <- component, rsc_not_found() notin ms.status[m], MStatus::ignored() notin ms.status[m]){ - if(parse_error() in ms.status[m]){ - return <(m : tmodel(modelName=m,messages=toList(ms.messages[m]))) ,ms>; + for(m <- component, hasNotProperty(m, ms, rsc_not_found(), ModuleProperty::ignored())){ + if(hasProperty(m, ms, parse_error())){ + return <(m : tmodel(modelName=moduleId2moduleName(m),messages=toList(ms.messages[m]))) ,ms>; } - for(imp <- m_imports[m] + m_extends[m], rsc_not_found() notin ms.status[imp], MStatus::ignored() notin ms.status[m]){ - imp_status = ms.status[imp]; - if(parse_error() in imp_status || checked() notin imp_status){ + for(imp <- m_imports[m] + m_extends[m], hasNotProperty(imp, ms, rsc_not_found()), hasNotProperty(m, ms, ModuleProperty::ignored())){ + if(hasProperty(imp, ms, parse_error()) || hasNotProperty(imp, ms, checked())){ dependencies_ok = false; - cause = (rsc_not_found() in imp_status) ? "module not found" : "due to syntax error"; - ms.messages[m] = (ms.messages[imp] ? {}) + error(" module could not be checked ()", moduleScopes[m]); + cause = hasProperty(imp, ms, rsc_not_found()) ? "module not found" : "due to syntax error"; + ms.messages[m] = (ms.messages[imp] ? {}) + error(" module could not be checked ()", m); } } if(!dependencies_ok){ - return <(m: tmodel(modelName=m,messages=toList(ms.messages[m]))), ms>; + return <(m: tmodel(modelName=moduleId2moduleName(m),messages=toList(ms.messages[m]))), ms>; } } transient_tms = (m : tm | m <- component); org_tm = tm; - for(m <- component, rsc_not_found() notin ms.status[m], MStatus::ignored() notin ms.status[m]){ + for(MODID m <- component, hasNotProperty(m, ms, rsc_not_found(), ModuleProperty::ignored())){ tm = org_tm; - tm.modelName = m; - mScope = getModuleScope(m, moduleScopes, pcfg); - tm.moduleLocs = (m : mScope); + mname = moduleId2moduleName(m); + tm.modelName = mname; tm.definitions = ( def.defined : def | Define def <- tm.defines); transient_tms[m] = tm; - = addGrammar(m, m_imports[m], m_extends[m], transient_tms, ms); + = addGrammar(m, m_imports[m], m_extends[m], transient_tms, ms); + if(found) { tm = tm1; } ms.messages[m] = toSet(tm.messages); transient_tms[m] = tm; } return ; } -ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[str,set[str]] m_extends, ModuleStatus ms, map[str,loc] moduleScopes, map[str, TModel] transient_tms, RascalCompilerConfig compilerConfig){ - map[str,datetime] moduleLastModified = ms.moduleLastModified; +ModuleStatus doSaveModule(set[MODID] component, map[MODID,set[MODID]] m_imports, map[MODID,set[MODID]] m_extends, ModuleStatus ms, map[MODID, TModel] transient_tms, RascalCompilerConfig compilerConfig){ pcfg = ms.pathConfig; - if(any(c <- component, !isEmpty({parse_error(), rsc_not_found(), MStatus::ignored()} & ms.status[c]))){ - return ms; - } + component = { m | m <- component, hasNotProperty(m, ms, ModuleProperty::ignored()) }; + if(isEmpty(component)) return ms; - //println("doSaveModule: , , , "); - component_scopes = { getModuleScope(qualifiedModuleName, moduleScopes, pcfg) | qualifiedModuleName <- component }; - set[loc] filteredModuleScopes = {}; + //println("doSaveModule: , , , "); + component_scopes = component; //{ getModuleScope(mid, moduleScopes, pcfg) | MODID mid <- component }; + set[MODID] filteredModuleScopes = {}; loc2moduleName = invertUnique(ms.moduleLocs); - bool isContainedInComponentScopes(loc inner){ - return any(cs <- component_scopes, isContainedIn(inner, cs)); + bool isContainedInComponentScopes(loc inner, map[loc,loc] m){ + return any(cs <- component_scopes, isContainedIn(inner, cs, m)); }; - bool isContainedInFilteredModuleScopes(loc inner){ - return any(cs <- filteredModuleScopes, isContainedIn(inner, cs)); + bool isContainedInFilteredModuleScopes(loc inner, map[loc,loc] m){ + return any(cs <- filteredModuleScopes, isContainedIn(inner, cs, m)); }; - for(qualifiedModuleName <- component){ + for(currentModule <- component){ start_save = cpuTime(); - tm = transient_tms[qualifiedModuleName]; - mscope = getModuleScope(qualifiedModuleName, moduleScopes, pcfg); - = getTPLWriteLoc(qualifiedModuleName, pcfg); + tm = transient_tms[currentModule]; + = getTPLWriteLoc(currentModule, pcfg); - imports = m_imports[qualifiedModuleName]; - extends = m_extends[qualifiedModuleName]; + imports = m_imports[currentModule]; + extends = m_extends[currentModule]; - bom = makeBom(qualifiedModuleName, ms); + bom = makeBom(currentModule, ms); - extendedModuleScopes = {getModuleScope(m, moduleScopes, pcfg) | str m <- extends, checked() in ms.status[m]}; - extendedModuleScopes += {*tm.paths[ems,importPath()] | ems <- extendedModuleScopes}; // add imports of extended modules - filteredModuleScopes = {getModuleScope(m, moduleScopes, pcfg) | str m <- (qualifiedModuleName + imports), checked() in ms.status[m]} + extendedModuleScopes; + extendedModuleScopes = {m | MODID m <- extends, hasProperty(m, ms, checked())}; + extendedModuleScopes += {*tm.paths[ems,importPath()] | MODID ems <- extendedModuleScopes}; // add imports of extended modules + filteredModuleScopes = {m | MODID m <- (currentModule + imports), hasProperty(m, ms, checked())} + extendedModuleScopes; TModel m1 = tmodel(); + m1.version = getCurrentTplVersion(); m1.rascalTplVersion = compilerConfig.rascalTplVersion; - m1.modelName = qualifiedModuleName; - m1.moduleLocs = (qualifiedModuleName : mscope); + m1.modelName = moduleId2moduleName(currentModule); + m1.moduleLocs = (m1.modelName : currentModule); - m1.facts = (key : tm.facts[key] | key <- tm.facts, isContainedInComponentScopes(key)); + m1.facts = (key : tm.facts[key] | key <- tm.facts, isContainedInFilteredModuleScopes(key, tm.logical2physical)); - m1.specializedFacts = (key : tm.specializedFacts[key] | key <- tm.specializedFacts, isContainedInComponentScopes(key), any(fms <- filteredModuleScopes, isContainedIn(key, fms))); + m1.specializedFacts = (key : tm.specializedFacts[key] | key <- tm.specializedFacts, isContainedInComponentScopes(key, tm.logical2physical), any(fms <- filteredModuleScopes, isContainedIn(key, fms))); m1.facts += m1.specializedFacts; - m1.messages = sort( { msg | msg <- tm.messages, msg.at.path == mscope.path}, bool(Message a, Message b){ return a.at.begin.line < b.at.begin.line; }); - ms.messages[qualifiedModuleName] = toSet(m1.messages); + // m1.messages = [ msg | msg <- tm.messages, msg.at.path == currentModule.path || msg is error ]; + m1.messages = tm.messages; + ms.messages[currentModule] = toSet(m1.messages); filteredModuleScopePaths = {ml.path |loc ml <- filteredModuleScopes}; - - m1.scopes - = ( inner : tm.scopes[inner] - | loc inner <- tm.scopes, - inner.path in filteredModuleScopePaths, - isContainedInComponentScopes(inner) - ); + m1.scopes = tm.scopes; + // m1.scopes + // = ( inner : tm.scopes[inner] + // | loc inner <- tm.scopes, + // inner.path in filteredModuleScopePaths, + // (tm.scopes[inner] == |global-scope:///| || isContainedInComponentScopes(inner, tm.logical2physical)) + // ); m1.store = (key_bom : bom); @@ -444,22 +481,23 @@ ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[s m1.store[key_common_keyword_fields] = tm.store[key_common_keyword_fields] ? []; - m1.paths = { tup | tuple[loc from, PathRole pathRole, loc to] tup <- tm.paths, tup.from == mscope || tup.from in filteredModuleScopes /*|| tup.from in filteredModuleScopePaths*/ }; + m1.paths = { tup | tuple[MODID from, PathRole pathRole, MODID to] tup <- tm.paths, tup.from == currentModule || tup.from in filteredModuleScopes /*|| tup.from in filteredModuleScopePaths*/ }; keepRoles = variableRoles + keepInTModelRoles; m1.useDef = { | <- tm.useDef, - isContainedIn(u, mscope) + isContainedIn(u, currentModule, tm.logical2physical) || (tm.definitions[d]? && tm.definitions[d].idRole in keepRoles) }; // Filter model for current module and replace functions in defType by their defined type defs = for(tup: <- tm.defines){ - if( ( idRole in variableRoles ? isContainedInComponentScopes(defined) + if( ( idRole in variableRoles ? ( isContainedInComponentScopes(defined, tm.logical2physical) + ) : ( idRole in keepInTModelRoles - && ( isContainedInComponentScopes(defined) - || isContainedInFilteredModuleScopes(defined) + && ( isContainedInComponentScopes(defined, tm.logical2physical) + || isContainedInFilteredModuleScopes(defined, tm.logical2physical) ) ) ) @@ -476,11 +514,10 @@ ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[s case kwField(AType atype, str fieldName, str definingModule, Expression _defaultExp) => kwField(atype, fieldName, definingModule) case loc l : if(!isEmpty(l.fragment)) insert l[fragment=""]; }; - log2phys = tm.logical2physical; m1.logical2physical = tm.logical2physical; - m1.usesPhysicalLocs = true; - ms.status[qualifiedModuleName] -= {tpl_saved()}; - ms = addTModel(qualifiedModuleName, m1, ms); + ms = deleteProperty(currentModule, ms, tpl_saved()); + ms = addTModel(currentModule, m1, ms); + // println("TModel for :"); iprintln(m1); } return ms; } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/LogicalLocations.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/LogicalLocations.rsc new file mode 100644 index 00000000000..82e07a08255 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/LogicalLocations.rsc @@ -0,0 +1,34 @@ +module lang::rascalcore::check::LogicalLocations + +import String; +import lang::rascalcore::check::ATypeUtils; + +bool isRascalLogicalLoc(loc l) + = startsWith(l.scheme, "rascal+"); + +alias MODID = loc; // module identification + +bool isModuleId(loc l) = l.scheme == "rascal+module"; + +MODID moduleName2moduleId(str mname){ + return |rascal+module:///|; +} + +str moduleId2moduleName(loc mloc){ + assert mloc.scheme == "rascal+module" : "moduleId2moduleName: "; + path = mloc.path; + if(path[0] == "/") path = path[1..]; + return replaceAll(path, "/", "::"); +} + +alias FUNID = loc; // function identification + +bool isFunctionId(loc l) = l.scheme == "rascal+function"; + +alias CONSID = loc; // constructor identification + +bool isConstructorId(loc l) = l.scheme == "rascal+constructor"; + +alias FLDID = loc; // field identification + +bool isFieldId(loc l) = l.scheme == "rascal+field"; \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ModuleLocations.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ModuleLocations.rsc index e345ad768a9..bf72bb487bd 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ModuleLocations.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ModuleLocations.rsc @@ -30,8 +30,11 @@ module lang::rascalcore::check::ModuleLocations import IO; import List; import String; +import Message; import util::Reflective; import util::FileSystem; +import lang::rascalcore::check::BasicRascalConfig; +import lang::rascalcore::check::LogicalLocations; str makeFileName(str qualifiedModuleName, str extension = "rsc") { str qnameSlashes = replaceAll(qualifiedModuleName, "::", "/"); @@ -55,6 +58,7 @@ loc getSearchPathLoc(str filePath, PathConfig pcfg){ @synopsis{Get the location of a named module, search for `src` in srcs and `tpl` in libs} loc getRascalModuleLocation(str qualifiedModuleName, PathConfig pcfg){ + fileName = makeFileName(qualifiedModuleName, extension="rsc"); for(loc dir <- pcfg.srcs){ fileLoc = dir + fileName; @@ -70,7 +74,8 @@ loc getRascalModuleLocation(str qualifiedModuleName, PathConfig pcfg){ return fileLoc; } } - throw "Module `` not found;\n"; + mloc = |unknown:///|; + throw error("Module `` not found", mloc, causes=[info("Using PathConfig: ", mloc)] ); } tuple[str,str] splitFileExtension(str path){ @@ -96,16 +101,22 @@ int commonPrefix(list[str] rdir, list[str] rm){ } return size(rm); } - -@synopsis{Find the module name corresponding to a given module location via its (src or tpl) location} +@memo{expireAfter(minutes=5),maximumSize(500)} +@synopsis{Find the module name corresponding to a given module location via its (src, tpl or logical) location} str getRascalModuleName(loc moduleLoc, PathConfig pcfg){ modulePath = moduleLoc.path; rscFile = endsWith(modulePath, "rsc"); tplFile = endsWith(modulePath, "tpl"); - + if(isRascalLogicalLoc(moduleLoc)){ + path = moduleLoc.path; + if(path[0] == "/"){ + path = path[1..]; + } + return replaceAll(path, "/", "::"); + } if(!( rscFile || tplFile )){ - throw "Not a Rascal .src or .tpl file: "; + throw "Not a Rascal .rsc or .tpl file: "; } // Find matching .rsc file in source directories diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/PathAnalysis.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/PathAnalysis.rsc index e5a16998e71..06e18549e6f 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/PathAnalysis.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/PathAnalysis.rsc @@ -34,8 +34,6 @@ module lang::rascalcore::check::PathAnalysis extend lang::rascalcore::check::CheckerCommon; -import lang::rascal::\syntax::Rascal; - import String; /********************************************************************/ diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index 8496be8c8af..6e1f3894d83 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -34,17 +34,18 @@ module lang::rascalcore::check::RascalConfig //import lang::rascalcore::check::CheckerCommon; import lang::rascalcore::check::ADTandGrammar; - -import lang::rascal::\syntax::Rascal; import lang::rascalcore::compile::muRascal::AST; import lang::rascalcore::check::CheckerCommon; +import lang::rascalcore::check::BasicRascalConfig; +import lang::rascalcore::check::ModuleLocations; import Location; import util::FileSystem; import util::Reflective; import lang::rascalcore::compile::util::Names; import analysis::typepal::StringSimilarity; +import analysis::typepal::LocationChecks; import IO; import List; @@ -55,49 +56,77 @@ import String; str parserPackage = "org.rascalmpl.core.library.lang.rascalcore.grammar.tests.generated_parsers"; -// Define the name overloading that is allowed +//Define the name overloading that is allowed bool rascalMayOverload(set[loc] defs, map[loc, Define] defines){ - bool seenVAR = false; - bool seenNT = false; - bool seenLEX = false; - bool seenLAY = false; - bool seenKEY = false; - bool seenALIAS = false; - bool seenFUNCTION = false; - - for(def <- defs){ - // Forbid: - // - overloading of variables/formals/pattern variables - // - overloading of incompatible syntax definitions - switch(defines[def].idRole){ - case functionId(): - { if(seenVAR) return false; seenFUNCTION = true; } - case variableId(): - { if(seenVAR || seenFUNCTION) return false; seenVAR = true;} - case moduleVariableId(): - { if(seenVAR || seenFUNCTION) return false; seenVAR = true;} - case formalId(): - { if(seenVAR || seenFUNCTION) return false; seenVAR = true;} - case keywordFormalId(): - { if(seenVAR || seenFUNCTION) return false; seenVAR = true;} - case patternVariableId(): - { if(seenVAR || seenFUNCTION) return false; seenVAR = true;} - case nonterminalId(): - { if(seenLEX || seenLAY || seenKEY){ return false; } seenNT = true; } - case lexicalId(): - { if(seenNT || seenLAY || seenKEY) { return false; } seenLEX= true; } - case layoutId(): - { if(seenNT || seenLEX || seenKEY) { return false; } seenLAY = true; } - case keywordId(): - { if(seenNT || seenLAY || seenLEX) { return false; } seenKEY = true; } - case aliasId(): - { if(seenALIAS) return false; seenALIAS = true; } - + set[IdRole] roles = { defines[def].idRole | def <- defs }; + result = true; + if({role} := roles){ + result = role notin (role in forbiddenIdRoleOverloading ? forbiddenIdRoleOverloading[role] : {}); + } else { + for(role <- roles){ + if(any(role2 <- roles, role2 != role, + role2 in (role in forbiddenIdRoleOverloading ? forbiddenIdRoleOverloading[role] : {}))){ + result = false; + break; + } } } - return true; + + // oldResult = rascalMayOverloadOld(defs, defines); + // if(result != oldResult){ + // println("rascalMayOverload, new: , old: , for "); + // for(def <- defs){ + // println(defines[def]); + // } + // throw "rascalMayOverload"; + // } + return result; } +// // Define the name overloading that is allowed +// bool rascalMayOverloadOld(set[loc] defs, map[loc, Define] defines){ +// bool seenVAR = false; +// bool seenNT = false; +// bool seenLEX = false; +// bool seenLAY = false; +// bool seenKEY = false; +// bool seenALIAS = false; +// bool seenFUNCTION = false; + +// for(def <- defs){ +// // Forbid: +// // - overloading of variables/formals/pattern variables +// // - overloading of incompatible syntax definitions +// // - alias and most other names +// switch(defines[def].idRole){ +// case functionId(): +// { if(seenVAR || seenALIAS) return false; seenFUNCTION = true; } +// case variableId(): +// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} +// case moduleVariableId(): +// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} +// case formalId(): +// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} +// case keywordFormalId(): +// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} +// case patternVariableId(): +// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} +// case nonterminalId(): +// { if(seenLEX || seenLAY || seenKEY || seenALIAS){ return false; } seenNT = true; } +// case lexicalId(): +// { if(seenNT || seenLAY || seenKEY || seenALIAS) { return false; } seenLEX= true; } +// case layoutId(): +// { if(seenNT || seenLEX || seenKEY || seenALIAS) { return false; } seenLAY = true; } +// case keywordId(): +// { if(seenNT || seenLAY || seenLEX || seenALIAS) { return false; } seenKEY = true; } +// case aliasId(): +// { if(seenALIAS || seenVAR || seenFUNCTION || seenNT || seenLEX || seenLAY || seenKEY) return false; seenALIAS = true; } +// } +// } +// return true; +// } + + // Name resolution filters set[IdRole] defBeforeUseRoles = {variableId(), moduleVariableId(), formalId(), keywordFormalId(), patternVariableId()}; @@ -106,23 +135,23 @@ set[IdRole] defBeforeUseRoles = {variableId(), moduleVariableId(), formalId(), k Accept rascalIsAcceptableSimple(loc def, Use use, Solver s){ //println("rascalIsAcceptableSimple: *** *** def=, use="); Define d = s.getDefine(def); - if(isBefore(use.occ, def)){ + if(s.isBefore(use.occ, def)){ if(moduleVariableId() == d.idRole){ // Module variables should adhere to def before use, unless they are used inside a function. for(some_def <- s.getAllDefines(), some_def.idRole == functionId()){ - if(isContainedIn(use.occ, some_def.defined)){ + if(s.isContainedIn(use.occ, some_def.defined)){ return acceptBinding(); } } return ignoreContinue(); } else if(!isEmpty(use.idRoles & defBeforeUseRoles) // If we encounter a use before def - && isContainedIn(def, use.scope) // in an idRole that requires def before use + && s.isContainedIn(def, use.scope) // in an idRole that requires def before use ){ // and the definition is in the same scope as the use // then only allow this when inside explicitly defined areas (typically the result part of a comprehension) if(lrel[loc,loc] allowedParts := s.getStack(key_allow_use_before_def)){ list[loc] parts = allowedParts[use.scope]; - return !isEmpty(parts) && any(part <- parts, isContainedIn(use.occ, part)) ? acceptBinding() : ignoreContinue(); + return !isEmpty(parts) && any(part <- parts, s.isContainedIn(use.occ, part)) ? acceptBinding() : ignoreContinue(); } else { throw "Inconsistent value stored for : "; } @@ -130,7 +159,7 @@ Accept rascalIsAcceptableSimple(loc def, Use use, Solver s){ } // Uses of a keyword formal inside its initializing expression are rejected - if(d.idRole == keywordFormalId() && isContainedIn(use.occ, d.defined)){ + if(d.idRole == keywordFormalId() && s.isContainedIn(use.occ, d.defined)){ return ignoreContinue(); } return acceptBinding(); @@ -138,49 +167,58 @@ Accept rascalIsAcceptableSimple(loc def, Use use, Solver s){ Accept rascalIsAcceptableQualified(loc def, Use use, Solver s){ // println("rascalIsAcceptableQualified: , "); - atype = s.getType(def); - - defPath = def.path; - qualAsPath = replaceAll(use.ids[0], "::", "/") + ".rsc"; + assert isRascalLogicalLoc(def): "rascalIsAcceptableQualified: "; + path = def.path; + i = findLast(path, "/"); + assert i >= 0: " findLast in gives "; + defPath = def.path[..i]; + qualPath = "/" + replaceAll(use.ids[0], "::","/"); // qualifier and proposed definition are the same? - if(endsWith(defPath, qualAsPath)){ + if(defPath == qualPath){ return acceptBinding(); } + atype = s.getType(def); // Qualifier is a ADT name? if(acons(aadt(adtName, _, _), list[AType] _fields, list[Keyword] _kwFields) := atype){ - return use.ids[0] == adtName ? acceptBinding() : ignoreContinue(); + return use.ids[0] == adtName ? acceptBinding() : ignoreContinue(); + } + + if(afunc(AType _ret, list[AType] _formals, list[Keyword] _kwFormals) := atype){ + return acceptBinding(); } // Qualifier is a Production? if(aprod(prod(aadt(adtName, _, _), list[AType] _atypes)) := atype){ - return use.ids[0] == adtName ? acceptBinding() : ignoreContinue(); + return use.ids[0] == adtName ? acceptBinding() : ignoreContinue(); } // Is there another acceptable qualifier via an extend? - - extendedStarBy = { | <- s.getPaths()}*; - - if(!isEmpty(extendedStarBy) && any(p <- extendedStarBy[defPath]?{}, endsWith(p, defPath))){ + paths = enhancePathRelation(s.getPaths()); + defPathAsMODID = |rascal+module://|; + qualPathAsMODID = |rascal+module://|; + if(defPathAsMODID in paths[qualPathAsMODID]<1>){ + //println("acceptBinding: "); return acceptBinding(); } return ignoreContinue(); } -Accept rascalIsAcceptablePath(loc _defScope, loc def, Use _use, PathRole pathRole, Solver s) { +Accept rascalIsAcceptablePath(loc _defScope, loc def, Use use, PathRole pathRole, Solver s) { if(pathRole == importPath()){ the_define = s.getDefine(def); defIdRole = the_define.idRole; // Only data declarations, constructors and visible entities are visible if(!(defIdRole == dataId() || defIdRole == constructorId() || the_define.defInfo.vis == publicVis())){ + //println("rascalIsAcceptablePath: , , =\> ignoreContinue()"); return ignoreContinue(); } } - + //println("rascalIsAcceptablePath: , , =\> acceptBinding()"); return acceptBinding(); } @@ -287,7 +325,7 @@ bool rascalReportUnused(loc def, TModel tm){ if(!definitions[def]? || !tm.moduleLocs[tm.modelName]?) return false; - if(!isContainedIn(definitions[def].defined, tm.moduleLocs[tm.modelName])){ + if(!isContainedIn(definitions[def].defined, tm.moduleLocs[tm.modelName], tm.logical2physical)){ return false; } @@ -345,11 +383,27 @@ bool rascalReportUnused(loc def, TModel tm){ return true; } -// Enhance TModel before running Solver by adding transitive edges for extend +// Extend the path relation by +// - adding transitive edges for extend +// - adding imports via these extends +rel[loc, PathRole,loc] enhancePathRelation(rel[MODID, PathRole, MODID] paths){ + extendPlus = { | <- paths}+; + paths += { | <- extendPlus}; + + imports = { | <- paths}; + delta = { + | <- extendPlus o imports, + notin paths, + from != to2 + }; + paths += delta; + return paths; +} + +// Enhance TModel before running Solver by + TModel rascalPreSolver(map[str,Tree] _namedTrees, TModel m){ - extendPlus = { | <- m.paths}+; - m.paths += { | <- extendPlus}; - return m; + return m[paths = enhancePathRelation(m.paths)]; } void checkOverloading(map[str,Tree] namedTrees, Solver s){ @@ -357,7 +411,6 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ set[Define] defines = s.getAllDefines(); facts = s.getFacts(); - set[loc] actuallyUsedDefs = range(s.getUseDef()); moduleScopes = { t@\loc | t <- range(namedTrees) }; funDefs = { | define <- defines, define.idRole == functionId() }; @@ -366,8 +419,8 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ set[Define] defs = funDefs[id]; if(size(defs) > 1){ for(d1 <- defs, d2 <- defs, d1.defined != d2.defined, - t1 := facts[d1.defined]?afunc(avoid(),[],[]), - t2 := facts[d2.defined]?afunc(avoid(),[],[]), + d1.defined in facts, AType t1 := facts[d1.defined], + d2.defined in facts, AType t2 := facts[d2.defined], d1.scope in moduleScopes, d2.scope in moduleScopes, size(t1.formals) == size(t2.formals) ){ if(isEmpty(t1.formals)){ @@ -377,14 +430,16 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ s.addMessages(msgs); } if(isVoidAType(t1.ret) && !isVoidAType(t2.ret)){ - msgs = [ error("Declaration clashes with other declaration of function `` with result type at ", d1.defined) ]; + causes = [ info("Clashing declaration of ``", d2.defined) ]; + msgs = [ error("Declaration clashes with other declaration of function `` with result type", d1.defined, causes=causes) ]; s.addMessages(msgs); } if(comparableList(t1.formals, t2.formals)){ r1 = visit(t1.ret) {case p:aparameter(_,_,closed=true) => p[closed=false] }; r2 = visit(t2.ret) {case p:aparameter(_,_,closed=true) => p[closed=false] }; if(!comparable(r1, r2)){ - msgs = [ error("Return type `` of function `` is not comparable with return type `` of other declaration with comparable arguments", d1.defined) ]; + causes = [ info("ther declaration with comparable arguments", d2.defined) ]; + msgs = [ error("Return type `` of function `` is not comparable with return type `` of other declaration with comparable arguments", d1.defined, causes=causes) ]; s.addMessages(msgs); } @@ -419,64 +474,73 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ consNameDef = { | define <- defines, define.idRole == constructorId() }; - consIds = domain(consNameDef); for(id <- consIds){ defs = consNameDef[id]; allDefs = { d.defined | d <- defs }; for(d1 <- defs, d2 <- defs, d1.defined != d2.defined, - t1 := facts[d1.defined]?acons(aadt("***DUMMY***", [], dataSyntax()),[],[]), - t2 := facts[d2.defined]?acons(aadt("***DUMMY***", [], dataSyntax()),[],[]), + d1.defined in facts, t1 := facts[d1.defined], + d2.defined in facts, t2 := facts[d2.defined], comparableList(t1.fields, t2.fields), ! (isSyntaxType(t1) && isSyntaxType(t2))){ - msgs = []; - if(t1.adt == t2.adt){ - msgs = [ error("Constructor `` overlaps with other declaration for type ``, see ", d.defined) | d <- defs ]; + if(t1.adt == t2.adt && d1.scope.path == d2.scope.path){ + s.addMessages([error("Constructor `` overlaps with other declaration for type ``, see ", d.defined) | d <- defs ]); } - // NOTE: After discussion about the relevance of the following checks they have been commented out - // and will be removed later - // else if(d1.defined in actuallyUsedDefs && d2.defined in actuallyUsedDefs){ - // msgs = [ info("Constructor `` is used without qualifier and overlaps with other declaration, see ", d.defined) | d <- defs ]; - // } else { - // msgs = [ info("On use add a qualifier to constructor ``, it overlaps with other declaration, see ", d.defined) | d <- defs ]; - // } - s.addMessages(msgs); } } - try { - matchingConds = [ | <_, Define d> <- consNameDef, d.scope in moduleScopes, t := s.getType(d)]; - for( <- matchingConds, <- matchingConds, d1.defined != d2.defined){ - for(fld1 <- t1.fields, fld2 <- t2.fields, fld1.alabel == fld2.alabel, !isEmpty(fld1.alabel), !comparable(fld1, fld2)){ - msgs = [ info("Field `` is declared with different types in constructors `` and `` for ``", d1.defined) - ]; - s.addMessages(msgs); - } +} +void checkOverloadedConstructors(Tree t, Solver s){ + visit(t){ + case current: (Expression) ` ( <{Expression ","}* arguments> )`: { + try { + tp = s.getType(current); + if(overloadedAType(rel[loc def, IdRole idRole, AType atype] overloads) := tp){ + reportConstructorOverload(current, tp, s); + } + exptp = s.getType(expression); + if(isADTAType(tp) && overloadedAType(rel[loc def, IdRole idRole, AType atype] overloads) := exptp){ + reportConstructorOverload(current, exptp, s); + } + } catch _: ; } - } catch _: { - // Guard against type incorrect defines, but record for now - println("Skipping (type-incorrect) defines while checking duplicate labels in constructors"); } } -void rascalPostSolver(map[str,Tree] namedTrees, Solver s){ +void reportConstructorOverload(Expression current, overloadedAType(rel[loc def, IdRole idRole, AType atype] overloads), Solver s){ + coverloads = [ ovl | ovl <- overloads, isConstructorAType(ovl.atype) ]; + if(size(coverloads) > 1){ + ovl1 = coverloads[0]; + adtNames = { adtName | <- overloads, acons(ret:aadt(adtName, list[AType] _, _), list[AType] fields, list[Keyword] kwFields) := tp }; + qualifyHint = size(adtNames) > 1 ? " you may use as qualifier" : ""; + argHint = "make argument type(s) more precise"; + msg = error("Constructor `` is overloaded, maybe", + current@\loc); + s.addMessages([msg]); + } +} +void rascalPostSolver(map[str,Tree] namedTrees, Solver s){ if(!s.reportedErrors()){ checkOverloading(namedTrees, s); for(_mname <- namedTrees){ addADTsAndCommonKeywordFields(s); } + + for (pt <- range(namedTrees)){ + checkOverloadedConstructors(pt, s); + } } } -bool isLogicalLoc(loc l) - = startsWith(l.scheme, "rascal+"); +// bool isRascalLogicalLoc(loc l) +// = startsWith(l.scheme, "rascal+"); -loc rascalCreateLogicalLoc(Define def, str _modelName, PathConfig pcfg){ +loc rascalCreateLogicalLoc(Define def, str modelName, PathConfig pcfg){ if(def.idRole in keepInTModelRoles){ - if(isLogicalLoc(def.defined)) return def.defined; + if(isRascalLogicalLoc(def.defined)) return def.defined; moduleName = getRascalModuleName(def.defined, pcfg); moduleNameSlashed = replaceAll(moduleName, "::", "/"); suffix = def.defInfo.md5? ? "$" : ""; @@ -521,7 +585,7 @@ list[str] rascalSimilarNames(Use u, TModel tm){ similar = similarWords(w, domain(longNames), tm.config.cutoffForNameSimilarity)[0..10]; return sort({*longNames[s] | s <- similar }, bool (str a, str b) { return size(a) < size(b); }); } else { - vocabulary = { d.orgId | d <- tm.defines, d.idRole in idRoles, isContainedIn(u.occ, d.scope) }; + vocabulary = { d.orgId | d <- tm.defines, d.idRole in idRoles, isContainedIn(u.occ, d.scope, tm.logical2physical) }; similar = similarWords(w, vocabulary, tm.config.cutoffForNameSimilarity)[0..10]; return sort(similar, bool (str a, str b) { return a < b; }); } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Summary.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Summary.rsc index d0d59704a3e..9d3db075815 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Summary.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Summary.rsc @@ -36,6 +36,7 @@ extend lang::rascalcore::check::CheckerCommon; import lang::rascalcore::check::Import; import analysis::typepal::TModel; +import analysis::typepal::ConvertTModel; import util::Reflective; @@ -43,12 +44,13 @@ import IO; import Relation; import String; import ValueIO; +// import lang::rascalcore::CompilerPathConfig; // Duplicate in lang::rascalcore::compile::util::Names, factor out data PathConfig( loc generatedSources=|unknown:///|, - loc resources = |unknown:///|, - loc testResources =|unknown:///| + loc generatedResources = |unknown:///|, + loc generatedTestResources =|unknown:///| ); @doc{ @@ -74,7 +76,9 @@ private map[loc from, str tp] getLocationTypes(TModel tm) = (key : prettyAType(tm.specializedFacts[key] ? tm.facts[key]) | key <- tm.facts); ModuleSummary makeSummary(TModel tm, str qualifiedModuleName) { - tm = convertTModel2PhysicalLocs(tm); + if (!tm.usesPhysicalLocs) { + tm = convertTModel2PhysicalLocs(tm); + } // Extract @doc and @synopsis tags map[loc def, str synopsis] synopses = (); map[loc def, loc docloc] docLocs = (); @@ -167,10 +171,10 @@ str getSynopsis(str docContents){ ModuleSummary example1() { pcfg = pathConfig( - srcs=[|std:///|], - bin = |project://rascal-core/target/test-classes|, - generatedSources = |project://rascal-core/target/generated-test-sources|, - resources = |project://rascal-core/target/generated-test-resources|, + srcs=[|project://rascal|], + bin = |target://rascal|, + generatedSources = |project://rascal/target/generated-test-sources|, + generatedResources = |project://rascal/target/generated-test-resources|, libs = []); return makeSummary("Boolean", pcfg); } @@ -182,14 +186,19 @@ value main(){ // Simple sanity tests. Any change in Boolean.rsc will break these tests. test bool synopsis1() - = example1().synopses[ |project://rascal/src/org/rascalmpl/library/Boolean.rsc|(1538,254,<80,0>,<94,1>)] == "Convert Boolean value to string."; + = bprintln(example1().synopses) && example1().synopses[resolveLocation(|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(1618,268,<80,0>,<94,1>))] == "Convert Boolean value to string."; test bool vocabulary1() - = example1().vocabulary == {"Boolean","toString","toInt","toReal","fromString","arbBool"}; + = example1().vocabulary == + {"SchemeNotSupported","sentence","ArithmeticException","IO","message","first","MalFormedURI","toReal","classpath","Timeout","JavaCompilation","b","Java","InvalidUseOfDateTime","Boolean", + "IndexOutOfBounds","nonterminal","cause","cls","PermissionDenied","StackOverflow","NoParent","name","EmptyList","uri","toString","JavaException","IllegalTypeArgument","Ambiguity","Exception", + "NotImplemented","EmptyMap","MultipleKey","index","NoMainFunction","NoSuchField","IllegalArgument","s","DateTimeParsingError","locs","second","InvalidUseOfTime","NoSuchElement","label","toInt", + "PathNotFound","line","InvalidURI","InvalidUseOfDate","ParseError","location","EmptySet","v","arguments","column","NoSuchAnnotation","NoSuchKey","RuntimeException","class","ImplodeError", + "DateTimePrintingError","source","arbBool","ModuleNotFound","CallFailed","fromString","UnavailableInformation","InvalidUseOfLocation","RegExpSyntaxError","AssertionFailed","key"}; test bool usedef1() - = example1().useDef[|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(935,1,<39,6>,<39,7>)] - == {|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(923,1,<37,27>,<37,28>)}; + = example1().useDef[resolveLocation(|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(974,1,<39,6>,<39,7>))] + == {resolveLocation(|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(960,1,<37,27>,<37,28>))}; test bool locationTypes1() - = example1().locationTypes[|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(1023,48,<45,8>,<45,56>)] == "RuntimeException"; \ No newline at end of file + = example1().locationTypes[resolveLocation(|project://rascal/src/org/rascalmpl/library/Boolean.rsc|(1068,48,<45,8>,<45,56>))] == "RuntimeException"; \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/SyntaxGetters.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/SyntaxGetters.rsc index 4256726e2c5..01504fe9163 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/SyntaxGetters.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/SyntaxGetters.rsc @@ -99,8 +99,11 @@ map[str,str] getTags(Tags tags){ //map[str,str] getTags(Tags tags) // = ("" : tg has contents ? "" : "" | tg <- tags.tags); -bool ignoreCompiler(map[str,str] tagsMap) - = !isEmpty(domain(tagsMap) & {"ignore", "Ignore", "ignoreCompiler", "IgnoreCompiler"}); +bool hasIgnoreCompilerTag(map[str,str] tagsMap) + = !isEmpty(domain(tagsMap) & {"ignoreCompiler", "IgnoreCompiler"}); + +bool hasIgnoreTag(map[str,str] tagsMap) + = !isEmpty(domain(tagsMap) & {"ignore", "Ignore"}); tuple[bool, str] getDeprecated(map[str,str] tagsMap){ for(depr <- {"deprecated", "Deprecated"}){ diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc index 79e3ee3ab65..52c8618e7ba 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc @@ -31,34 +31,37 @@ import util::Reflective; import lang::rascalcore::check::BasicRascalConfig; import lang::rascalcore::check::RascalConfig; +import lang::rascalcore::check::ModuleLocations; +// import lang::rascalcore::CompilerPathConfig; + // Duplicate in lang::rascalcore::compile::util::Names, factor out data PathConfig( loc generatedSources=|unknown:///|, loc generatedTestSources=|unknown:///|, - loc resources = |unknown:///|, - loc testResources =|unknown:///| + loc generatedResources=|unknown:///|, + loc generatedTestResources = |unknown:///| ); // ---- Various PathConfigs --------------------------------------------- - -public loc RASCAL = |mvn://org.rascalmpl!rascal!0.40.17/!|; -public loc TYPEPAL = |mvn://org.rascalmpl!typepal!0.14.8/!|; -public loc OUTDATED_TYPEPAL - = |mvn://org.rascalmpl!typepal!0.14.1/!|; -public loc RASCAL_CORE = |mvn://org.rascalmpl!rascal-core!0.12.14/!|; - -public loc DRAMBIGUITY = |mvn://org.rascalmpl!drambiguity!0.1.2/!|; -public loc FLYBYTES = |mvn://org.rascalmpl!flybytes!0.1.5/!|; -public loc SALIX_CORE = |mvn://org.rascalmpl!salix-core!0.2.7/!|; -public loc SALIX_CONTRIB = |mvn://org.rascalmpl!salix-contrib!0.2.7/!|; -public loc RASCAL_LSP = |mvn://org.rascalmpl!rascal-language-server!0.12.1/!|; -public loc PHP_ANALYSIS = |mvn://org.rascalmpl!php-analysis!0.2.5-SNAPSHOT/!|; - -public loc REPO = |file:///Users/paulklint/git/|; -public loc COMPILED_RASCAL - = REPO + "compiled-rascal"; -public loc TMP_COMPILED_RASCAL - = |tmp:///compiled-rascal/|; +// use the `download-test-jars.sh` to download these dependencies +// (and make sure to KEEP THE VERSIONS up to date) + +public loc RASCAL = |mvn://org.rascalmpl--rascal--0.41.0-RC15/|; +public loc RASCAL42 = |mvn://org.rascalmpl--rascal--0.42.0-RC2/|; +loc TYPEPAL = |mvn://org.rascalmpl--typepal--0.14.8/|; +loc OUTDATED_TYPEPAL = |mvn://org.rascalmpl--typepal--0.14.1/|; +loc TYPEPAL166 = |mvn://org.rascalmpl--typepal--0.16.6-RC1/|; + +loc DRAMBIGUITY = |mvn://org.rascalmpl--drambiguity--0.1.2/|; +loc FLYBYTES = |mvn://org.rascalmpl--flybytes--0.1.5/|; +loc SALIX_CORE = |mvn://org.rascalmpl--salix-core--0.2.7/|; +loc SALIX_CONTRIB = |mvn://org.rascalmpl--salix-contrib--0.2.7/|; +loc RASCAL_LSP = |mvn://org.rascalmpl--rascal-lsp--2.21.2/|; +loc PHP_ANALYSIS = |mvn://org.rascalmpl--php-analysis--0.2.5-SNAPSHOT/|; + +loc REPO = |file:///Users/paulklint/git/|; +loc COMPILED_RASCAL = REPO + "compiled-rascal"; +loc TMP_COMPILED_RASCAL = |tmp:///compiled-rascal/|; // ---- PathConfigs for testing purposes -------------------------------------- @@ -73,9 +76,9 @@ public PathConfig getDefaultTestingPathConfig() { snpc = ""; return pathConfig( srcs = [ |memory:///test-modules/|, |std:///| ], - bin = |memory:///test-modules/rascal-core-tests-bin-|, + bin = |memory:///test-modules/rascal-tests-bin-|, generatedSources = |memory:///test-modules/generated-test-sources-|, - resources = |memory:///test-modules/generated-test-resources-|, + generatedResources = |memory:///test-modules/generated-test-resources-|, libs = [ ] ); } @@ -91,9 +94,9 @@ public PathConfig getReleasedStandardLibraryTestingPathConfig() { snpc = ""; return pathConfig( srcs = [ |memory:///test-modules/| ], - bin = |memory:///test-modules/rascal-core-tests-bin-|, + bin = |memory:///test-modules/rascal-tests-bin-|, generatedSources = |memory:///test-modules/generated-test-sources-|, - resources = |memory:///test-modules/generated-test-resources-|, + generatedResources = |memory:///test-modules/generated-test-resources-|, libs = [ |lib://rascal| ] ); } @@ -120,20 +123,13 @@ public PathConfig getRascalProjectTestingPathConfig() { public PathConfig makePathConfig(list[loc] sources, list[loc] libraries, bool keep = false) { COMPILED = keep ? COMPILED_RASCAL : TMP_COMPILED_RASCAL; return pathConfig( - srcs = sources, - bin = COMPILED + (keep ? "/target/classes" : "rascal"), - generatedSources = COMPILED + "/src/main/java", - generatedTestSources = COMPILED + "/src/test/java/", - resources = COMPILED + (keep ? "/src/main/java" : "rascal"), - testResources = COMPILED_RASCAL + (keep ? "/src/test/java/" : "rascal"), - libs = libraries - // srcs = sources, - // bin = keep ? COMPILED_RASCAL + "/target/classes" : repo, - // generatedSources = keep ? COMPILED_RASCAL + "/src/main/java" : |unknown:///|, - // generatedTestSources = keep ? COMPILED_RASCAL + "/src/test/java/" : |unknown:///|, - // resources = keep ? COMPILED_RASCAL + "/src/main/java" : repo + "/rascal", - // testResources = keep ? COMPILED_RASCAL + "/src/test/java/" : repo + "/rascal", - // libs = libraries + srcs = sources, + bin = COMPILED + (keep ? "/target/classes" : "rascal"), + generatedSources = COMPILED + "/src/main/java", + generatedTestSources = COMPILED + "/src/test/java/", + generatedResources = COMPILED + (keep ? "/src/main/java" : "rascal"), + generatedTestResources = COMPILED + (keep ? "/src/test/java/" : "rascal"), + libs = libraries ); } @@ -142,42 +138,56 @@ public PathConfig makePathConfig(list[loc] sources, list[loc] libraries, bool ke public PathConfig getAllSrcPathConfig(bool keep = false) { return makePathConfig([ RASCAL + "org/rascalmpl/library", RASCAL + "org/rascalmpl/benchmark/", - RASCAL_CORE + "org/rascalmpl/core/library", + RASCAL + "org/rascalmpl/compiler", TYPEPAL ], [ ], keep=keep); } +public RascalCompilerConfig getAllSrcCompilerConfig(PathConfig pcfg){ + return rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true]; +} + public RascalCompilerConfig getAllSrcCompilerConfig(bool keep=true){ return rascalCompilerConfig(getAllSrcPathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } // ---- public PathConfig getAllSrcREPOPathConfig(bool keep = false) { + LSP_REPO = REPO + "rascal-language-servers/rascal-lsp"; return makePathConfig([ REPO + "rascal/src/org/rascalmpl/library", REPO + "rascal/test/org/rascalmpl/benchmark/", - REPO + "rascal-core/src/org/rascalmpl/core/library", - REPO + "typepal/src" + REPO + "rascal/src/org/rascalmpl/compiler", + REPO + "rascal/src/org/rascalmpl/tutor", + REPO + "typepal/src", + LSP_REPO + "src/main/rascal/library", + LSP_REPO + "src/main/rascal/lsp", + LSP_REPO + "src/test/rascal", + REPO + "php-analysis/src/main/rascal" ], [ ], keep=keep); } +public RascalCompilerConfig getAllSrcREPOCompilerConfig(PathConfig pcfg, bool keep=true){ + return rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true]; +} + public RascalCompilerConfig getAllSrcREPOCompilerConfig(bool keep=true){ return rascalCompilerConfig(getAllSrcREPOPathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } // ---- public PathConfig getAllSrcWritablePathConfig(bool keep = false) { TMP_RASCAL = |tmp:///rascal/|; - TMP_RASCAL_CORE = |tmp:///rascal-core/|; TMP_TYPEPAL = |tmp:///typepal/|; + remove(TMP_RASCAL, recursive = true); + remove(TMP_TYPEPAL, recursive = true); copy(RASCAL, TMP_RASCAL, recursive=true, overwrite=true); - copy(RASCAL_CORE, TMP_RASCAL_CORE, recursive=true, overwrite=true); copy(TYPEPAL, TMP_TYPEPAL, recursive=true, overwrite=true); return makePathConfig([ TMP_RASCAL + "org/rascalmpl/library", TMP_RASCAL + "org/rascalmpl/benchmark/", - TMP_RASCAL_CORE + "org/rascalmpl/core/library", + TMP_RASCAL + "org/rascalmpl/compiler", TMP_TYPEPAL ], [ ], @@ -206,56 +216,36 @@ public PathConfig getRascalAsLibPathConfig(bool keep = false) { srcs = [ ], bin = RASCAL + "rascal", generatedSources = RASCAL, - resources = RASCAL + "rascal", + generatedResources = RASCAL + "rascal", libs = [ RASCAL] ); } public PathConfig getRascalWritablePathConfig(bool keep = false) { TMP_RASCAL = |tmp:///rascal/|; + remove(TMP_RASCAL, recursive = true); copy(RASCAL, TMP_RASCAL, recursive=true, overwrite=true); - return makePathConfig([ TMP_RASCAL + "org/rascalmpl/library" - //, RASCAL + "test/org/rascalmpl/benchmark/" + pcfg = makePathConfig([ TMP_RASCAL + "org/rascalmpl/library", + TMP_RASCAL + "org/rascalmpl/compiler" ], [], keep=keep); + return pcfg; } + public RascalCompilerConfig getRascalWritableCompilerConfig(bool keep=true){ return rascalCompilerConfig(getRascalWritablePathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } -// ---- rascal-core ----------------------------------------------------------- +// ---- scratch -------------------------------------------------------------- -@synopsis{PathConfig for type-checking test modules in the rascal-core project} -@description{ -* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` -* binaries will be stored the target folder of the rascal-core project -* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. -} -public PathConfig getRascalCorePathConfig(bool keep = false) { - return makePathConfig([ RASCAL_CORE + "org/rascalmpl/core/library" ], - [ RASCAL, TYPEPAL ], - keep=keep); -} - -public RascalCompilerConfig getRascalCoreCompilerConfig(bool keep=true){ - return rascalCompilerConfig(getRascalCorePathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; -} - -@synopsis{Developers version: PathConfig for type-checking modules in other (named) Rascal projects} -@description{ -* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` -* binaries will be stored the target folder of the rascal-core project -* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. -* Included projects: rascal-tutor, flybytes, rascal-lsp -} -public PathConfig getRascalCorePathConfigDev(bool keep = false) { - return makePathConfig([ RASCAL_CORE ], [ RASCAL, TYPEPAL ], keep=keep); +public PathConfig getScratchProjectPathConfig(bool keep = false) { + return makePathConfig([ REPO + "rascal-scratch/src/main/rascal/" ], [ RASCAL ], keep=keep); } -public RascalCompilerConfig getRascalCoreCompilerConfigDev(bool keep=true){ - return rascalCompilerConfig(getRascalCorePathConfigDev())[verbose = true][logWrittenFiles=true]; +public RascalCompilerConfig getScratchCompilerConfig(bool keep=true){ + return rascalCompilerConfig(getScratchProjectPathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } // ---- typepal --------------------------------------------------------------- @@ -271,7 +261,7 @@ public RascalCompilerConfig getTypePalCompilerConfig(bool keep=true){ // ---- flybytes -------------------------------------------------------------- public PathConfig getFlyBytesProjectPathConfig(bool keep = false) { - return makePathConfig([ FLYBYTES ], [ RASCAL ], keep=keep); + return makePathConfig([ REPO + "flybytes/src", REPO + "rascal/src/org/rascalmpl/library" ], [ ], keep=keep); } public RascalCompilerConfig getFlyBytesCompilerConfig(bool keep=true){ @@ -281,31 +271,32 @@ public RascalCompilerConfig getFlyBytesCompilerConfig(bool keep=true){ // ---- salix ----------------------------------------------------------------- public PathConfig getSalixPathConfig(bool keep = false) { - return makePathConfig([ SALIX_CORE + "src/main/rascal", SALIX_CONTRIB + "src/main/rascal" ], + return makePathConfig([ REPO + "salix-core/src/main/rascal", REPO + "salix-contrib/src/main/rascal" ], [ RASCAL ], keep=keep); } -public RascalCompilerConfig getSalixCompilerConfig(bool keep = false){ +public RascalCompilerConfig getSalixCompilerConfig(bool keep = true){ return rascalCompilerConfig(getSalixPathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } // ---- drambiguity ----------------------------------------------------------- public PathConfig getDrAmbiguityPathConfig(bool keep = false) { - return makePathConfig([ DRAMBIGUITY, SALIX_CORE + "src/main/rascal" ], + return makePathConfig([ REPO + "drambiguity/src", REPO + "salix-core/src/main/rascal" ], [ RASCAL ], keep=keep); } -public RascalCompilerConfig getDrAmbiguityCompilerConfig(bool keep = false){ +public RascalCompilerConfig getDrAmbiguityCompilerConfig(bool keep = true){ return rascalCompilerConfig(getDrAmbiguityPathConfig(keep=keep))[verbose = true][logWrittenFiles=true]; } // ---- rascal-language-server ------------------------------------------------ public PathConfig getLSPPathConfig(bool keep = false) { - return makePathConfig([ RASCAL_LSP + "src/main/rascal", RASCAL_LSP + "src/test/rascal"], + REPO_LSP = REPO + "rascal-language-servers/rascal-lsp/"; + return makePathConfig([ REPO_LSP + "src/main/rascal/library", REPO_LSP + "src/test/rascal"], [ RASCAL ], keep=keep); } @@ -329,31 +320,15 @@ public RascalCompilerConfig getPHPCompilerConfig(bool keep = false){ // ---- VSCode----------------------------------------------------------------- public PathConfig getVSCodePathConfig() { - VS_RASCAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.41.0-RC10/rascal-0.41.0-RC10.jar!/|; - VS_TYPEPAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/typepal/0.15.1-SNAPSHOT/typepal-0.15.1-SNAPSHOT.jar!/|; - VS_RASCAL_CORE_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal-core/0.12.14-SNAPSHOT/rascal-core-0.12.14-SNAPSHOT.jar!/|; - return - pathConfig( - ignores=[], - resources=|file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/target/classes/|, - javaCompilerPath=[], - bin=|file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/target/classes/|, - classloaders=[], - generatedSources=|file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/generated-sources|, - libs=[ - |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.41.0-RC10/rascal-0.41.0-RC10.jar!/|, - |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal-core/0.12.13/rascal-core-0.12.13.jar!/|, - |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/typepal/0.15.0/typepal-0.15.0.jar!/| - ], - srcs=[|file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/src/main/rascal/|]); - // pathConfig( - // bin = REPO + "compiled-rascal/target/classes", - // generatedSources = REPO + "compiled-rascal/src/main/java", - // generatedTestSources = REPO + "compiled-rascal/src/test/java/", - // resources = REPO + "compiled-rascal/src/main/java", - // testResources = REPO + "compiled-rascal/src/test/java", - // libs=[VS_RASCAL_JAR, VS_TYPEPAL_JAR, VS_RASCAL_CORE_JAR], - // srcs=[|file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/src/main/rascal|]); + LSP_REPO = |file:///Users/paulklint/git/rascal-language-servers/rascal-lsp/|; + return pathConfig( + srcs=[LSP_REPO + "src/main/rascal/library", LSP_REPO + "src/main/rascal/lsp"], + libs=[ TYPEPAL, RASCAL ], + ignores=[], + generatedResources=LSP_REPO + "target/classes/", + bin=LSP_REPO + "target/classes/", + generatedSources=LSP_REPO + "generated-sources/" + ); } public RascalCompilerConfig getVSCodeCompilerConfig(){ @@ -363,8 +338,7 @@ public RascalCompilerConfig getVSCodeCompilerConfig(){ // ---- Outdated TypePal Usage ----------------------------------------------------------------- public PathConfig getOutdatedTPLPathConfig(bool keep = false) { - return makePathConfig(RASCAL_CORE, - [RASCAL_CORE + "src/org/rascalmpl/core/library"], + return makePathConfig([RASCAL + "src/org/rascalmpl/core/library"], [ RASCAL, OUTDATED_TYPEPAL ], keep=keep); } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AliasTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AliasTCTests.rsc index 5d02d8f6f90..d80024d1bc7 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AliasTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AliasTCTests.rsc @@ -93,6 +93,6 @@ test bool CircularAliasError4() = unexpectedDeclarationInModule(" test bool Issue504() = redeclaredVariableInModule(" module Issue504 alias INT = int; - alias INT = int; + alias INT = rat; "); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AssignmentTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AssignmentTCTests.rsc index 918d8616dea..70a9a3575d3 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AssignmentTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/AssignmentTCTests.rsc @@ -218,6 +218,14 @@ test bool TUPLE4() = checkOK(" ltail == [2,3]; }"); +test bool TUPLE5() = checkOK(" + void main(){ + if(true){ + \ = \<123, false\>; + } + x = 456; + }"); + test bool E1() = checkOK("value zz = 1 + 2;"); test bool E2() = checkOK("value zz = 1 + 2.5; "); test bool E3() = unexpectedType("value zz = 1 + true; "); @@ -276,4 +284,99 @@ test bool IfThen3() = illegalUseInModule(" value zz = { if(true) 10;}; "); -test bool IfThen4() = unexpectedType("value zz = { if(1) 10; }; "); \ No newline at end of file +test bool IfThen4() = unexpectedType("value zz = { if(1) 10; }; "); + +test bool ReturnIntModuleVarOk() { + clearMemory(); + writeModule("module A public int X = 1;"); + return checkModuleOK(" + module B + import A; + int main() = X; + "); +} + +test bool AssignGlobalIntModuleVarOk() { + clearMemory(); + writeModule("module A public int X = 1;"); + return checkModuleOK(" + module B + import A; + int Y = X; + "); +} + +test bool ReturnIntModuleVarNotOk() { + clearMemory(); + writeModule("module A public int X = 1;"); + return unexpectedTypeInModule(" + module B + import A; + bool main() = X; + "); +} + +test bool AssignIntModuleVarOk() { + clearMemory(); + writeModule("module A public int X = 1;"); + return checkModuleOK(" + module B + import A; + void main() { X = 2; } + "); +} + +test bool AssignAndIncrementIntModuleVarOk() { + clearMemory(); + writeModule("module A public int X = 1;"); + return checkModuleOK(" + module B + import A; + void main() { X += 2; } + "); +} + +test bool AssignListIntModuleVarOk() { + clearMemory(); + writeModule("module A public list[int] X = [1];"); + return checkModuleOK(" + module B + import A; + void main() { X[0] = 2; } + "); +} + +test bool AssignAndIncrementListIntModuleVarOk() { + clearMemory(); + writeModule("module A public list[int] X = [1];"); + return checkModuleOK(" + module B + import A; + void main() { X[0] += 2; } + "); +} + +test bool InferredVarAndModuleVarOk(){ + clearMemory(); + return checkModuleOK(" + module B + int X = 1; + list[int] f() = [X | X \<- [1..10]]; + + list[int] g() = [X | X \<- [1..20]]; + void main() { X += 1; } + "); +} + +test bool InferredVarAndImportedModuleVarOk(){ + clearMemory(); + writeModule("module A public int X = 1;"); + return checkModuleOK(" + module B + import A; + list[int] f() = [X | X \<- [1..10]]; + + list[int] g() = [X | X \<- [1..20]]; + void main() { X += 1; } + "); +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/BinaryDependencyTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/BinaryDependencyTests.rsc index dc21ab6e51b..1cee586e9f1 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/BinaryDependencyTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/BinaryDependencyTests.rsc @@ -33,26 +33,32 @@ are only available as binary (e.g., as.tpl files on the libs path). module lang::rascalcore::check::tests::BinaryDependencyTests import lang::rascalcore::check::Checker; +import lang::rascalcore::check::ATypeBase; import lang::rascalcore::check::TestConfigs; import util::Reflective; import IO; +import ValueIO; import lang::rascalcore::check::Import; import Map; import lang::rascal::\syntax::Rascal; import ParseTree; import String; +import lang::rascalcore::check::ModuleLocations; +import util::FileSystem; +import util::SemVer; +import lang::rascalcore::check::tests::StaticTestingUtils; // ---- Utilities for test setup ---------------------------------------------- bool verbose = false; -data PathConfig(loc resources=|unknown:///|, loc generatedSources=|unknown:///|); +data PathConfig(loc generatedResources=|unknown:///|, loc generatedSources=|unknown:///|); data Project = project(str name, map[str moduleName, str moduleText] modules, PathConfig pcfg); -void clearMemory() { remove(|memory:///| recursive = true); } +void clearMemory() { remove(|memory:///|, recursive = true); } loc projectDir(str pname) = |memory:///|; @@ -67,7 +73,7 @@ loc generatedSources(str pname) = projectDir(pname) + "generated/"; loc resources(str pname) - = projectDir(pname) + "resources/"; + = projectDir(pname) + "bin/"; Project createProject(str pname, map[str mname, str mtext] modules, PathConfig pcfg){ remove(projectDir(pname), recursive=true); @@ -94,19 +100,24 @@ str writeModule(str mname, str mtext){ throw "Parse error in "; } +loc getModuleLoc(str mname, Project pd) + = src(pd.name) + ".rsc"; + PathConfig createPathConfig(str pname){ return pathConfig( srcs=[src(pname)], bin=bin(pname), generatedSources=generatedSources(pname), - resources=resources(pname), + generatedResources=resources(pname), libs=[] ); } Project addModule(str mname, str mtext, Project pd){ pd.modules[mname] = writeModule(mname, mtext); - writeFile(src(pd.name) + ".rsc", pd.modules[mname]); + mloc = getModuleLoc(mname, pd); + writeFile(mloc, pd.modules[mname]); + assert exists(mloc) : " does not exist after write"; return pd; } @@ -114,21 +125,53 @@ Project changeModule(str mname, str mtext, Project pd){ if(!pd.modules[mname]?) throw "Module does not exist in "; pd.modules[mname] = writeModule(mname, mtext); - writeFile(src(pd.name) + ".rsc", pd.modules[mname]); + mloc = getModuleLoc(mname, pd); + writeFile(mloc, pd.modules[mname]); + assert exists(mloc) : " does not exist after write"; return pd; } Project removeSourceOfModule(str mname, Project pd){ if(!pd.modules[mname]?) throw "Cannot remove non-existing module "; pd.modules = delete(pd.modules, mname); - remove(src(pd.name) + ".rsc", recursive=true); + mloc = getModuleLoc(mname, pd); + remove(mloc, recursive=true); + assert !exists(mloc): " not removed"; + return pd; +} + +Project removeTPLOfModule(str mname, Project pd){ + remove(bin(pd.name) + "rascal/$.tpl", recursive=true); + return pd; +} + +Project setTPLVersionOfProject(str v, Project pd){ + try { + for(loc f <- find(bin(pd.name), "tpl")){ + tm = readBinaryValueFile(#TModel, f); + tm.rascalTplVersion = v; + writeBinaryValueFile(f, tm); + } + } catch e: throw "setTPLVersionOfProject: "; return pd; } -bool expectNoErrors(map[str, list[Message]] msgsMap){ - present = (/error(_,_) := msgsMap); +bool validateTPLVersionOfProject(Project pd){ + try { + for(loc f <- find(bin(pd.name), "tpl")){ + tm = readBinaryValueFile(#TModel, f); + if(!satisfiesVersion(tm.rascalTplVersion, "2.0.0-3.0.0")){ + return false; + } + } + } catch e: throw "setTPLVersionOfProject: "; + return true; +} + +bool expectNoErrors(list[ModuleMessages] modMsgs){ + present = (/error(_,_) := modMsgs); if(present){ - iprintln(msgsMap); + iprintln(modMsgs); } return !present; } @@ -146,8 +189,9 @@ bool checkExpectNoErrors(str mname, PathConfig pcfg, list[Project] remove = []){ } } -bool expectErrors(map[str, list[Message]] msgsMap, list[str] expected){ - errors = {e | /e:error(_,_) := msgsMap}; +bool expectErrors(list[ModuleMessages] modMsgs, list[str] expected){ + if(verbose) iprintln(modMsgs); + errors = {e | /e:error(_,_) := modMsgs}; for(e <- errors){ if(any(ex <- expected, findFirst(e.msg, ex)>= 0)){ @@ -173,13 +217,14 @@ bool checkExpectErrors(str mname, list[str] expected, PathConfig pcfg, list[Proj TModel check(str mname, RascalCompilerConfig cfg){ ModuleStatus ms = rascalTModelForNames([mname], cfg, dummy_compile1); - = getTModelForModule(mname, ms); + = getTModelForModule(moduleName2moduleId(mname), ms); if(found) return tm; throw "check: no TModel found for "; } // --- Tests for source libraries -------------------------------------------- +@ignore{Loads TModel with version 2.0.0 while it is 3.0.0 since a22dcd4416. TODO Make this test more robust.} test bool importSimpleSourceModuleWithRascalAsLib(){ libName = "test-lib"; lib = @@ -239,7 +284,7 @@ test bool importSimpleBinaryModule(){ 'int bFunction() = aFunction(); // library usage "), createPathConfig(clientName) - [libs=[resources(libName)]] // library dependency on where the .tpl files are + [libs=[bin(libName)]] // library dependency on where the .tpl files are ); return checkExpectNoErrors("B", client.pcfg, remove = [lib, client]); } @@ -263,7 +308,7 @@ test bool extendTransitiveBinaryModule() { 'int bFunction() = aFunction(); // library usage "), createPathConfig(clientName) - [libs=[resources(libName)]]); // dependency on library lib + [libs=[bin(libName)]]); // dependency on library lib assert checkExpectNoErrors("B", client.pcfg); client = removeSourceOfModule("B", client); @@ -277,8 +322,8 @@ test bool extendTransitiveBinaryModule() { return checkExpectNoErrors("C", client.pcfg - [libs=[resources(libName) , // library dependencies for both projects we depend on - resources(clientName)]] + [libs=[bin(libName) , // library dependencies for both projects we depend on + bin(clientName)]] remove = [lib, client]); } @@ -302,7 +347,7 @@ test bool incompatibleWithBinaryLibrary(){ 'int main() = f(42, 43); // incompatible call fo f "), createPathConfig(clientName) - [libs = [resources(libName)] ] + [libs = [bin(libName)] ] ); return checkExpectErrors("M2", ["Expected 1 argument(s), found 2"], client.pcfg, remove = [lib, client]); } @@ -327,7 +372,7 @@ test bool incompatibleWithBinaryLibraryAfterChange(){ 'int main() = f(42); "), createPathConfig(clientName) - [libs = [resources(libName)] ] + [libs = [bin(libName)] ] ); assert checkExpectNoErrors("M2", client.pcfg); @@ -335,10 +380,114 @@ test bool incompatibleWithBinaryLibraryAfterChange(){ lib = addModule("M1", "int f(int n, int m) = n+m;", lib); assert checkExpectNoErrors("M1", lib.pcfg); + // Update M2's modifcation time to make sure it will rechecked + touch(getRascalModuleLocation("M2", client.pcfg)); // Call of "f" in M2 no longer complies with "f"'s signature in M1 return checkExpectErrors("M2", ["Expected 2 argument(s), found 1"], client.pcfg, remove = [lib, client]); } + +test bool incompatibleWithBinaryLibraryDueToTPLVersion(){ + // Create project "lib" and module "M1" and then compile "M1" + libName = "lib"; + lib = createProject(libName, + ("M1": "int f(int n) = n;"), + createPathConfig(libName) + ); + assert checkExpectNoErrors("M1", lib.pcfg); + + + lib = removeSourceOfModule("M1", lib); // remove source of M1 completely, to be sure + lib = setTPLVersionOfProject("0.0.1", lib); // set rascalTplVersion to incompatible version number + + // Create project "client" and module "M2" and then compile "M2" + // "client" uses "lib" as binary library + clientName = "client"; + client = createProject(clientName, + ("M2": "import M1; // binary import + 'int main() = f(42); // compatible call fo f + "), + createPathConfig(clientName) + [libs = [bin(libName)] ] + ); + return checkExpectErrors("M2", ["outdated Rascal TPL version"], client.pcfg, remove = [lib, client]); +} + +test bool removedTPLInBinaryLibrary(){ + // Create project "lib" and module "M1" and then compile "M1" + libName = "lib"; + lib = createProject(libName, + ("M1": "int f(int n) = n;"), + createPathConfig(libName) + ); + assert checkExpectNoErrors("M1", lib.pcfg); + + + lib = removeSourceOfModule("M1", lib); // remove source of M1 completely, to be sure + lib = removeTPLOfModule("M1", lib); // remove M1's tpl file + + // Create project "client" and module "M2" and then compile "M2" + // "client" uses "lib" as binary library + clientName = "client"; + client = createProject(clientName, + ("M2": "import M1; // binary import + 'int main() = f(42); // compatible call fo f + "), + createPathConfig(clientName) + [libs = [bin(libName)] ] + ); + return checkExpectErrors("M2", ["Module `M1` not found"], client.pcfg, remove = [lib, client]); +} + +// Scenarios with outdated TPL versions + +test bool recompileModulesInSameProjectWithIncompatibleTPLs(){ + // Create project "m" with modules "M1" and "M2" + // m's sources remain available while tpl version is downgraded and made incompatible + mName = "m"; + m = createProject(mName, + ("M1": "int f(int n) = n;", + "M2": "import M1; // import + 'int main() = f(42); // compatible call fo f + "), + createPathConfig(mName) + ); + assert checkExpectNoErrors("M2", m.pcfg); + m = setTPLVersionOfProject("0.0.0", m); // set rascalTplVersion to incompatible version number + // tpl is more recent than source + // expect seamless recompilation of M1 and M2 + assert checkExpectNoErrors("M2", m.pcfg, remove = [m]); + return validateTPLVersionOfProject(m); +} + +test bool recompileLibraryModulesWithIncompatibleTPLVersionWhenSourceIsAvailable(){ + // Create project "lib" and module "M1" and then compile "M1" + libName = "lib"; + lib = createProject(libName, + ("M1": "int f(int n) = n;"), + createPathConfig(libName) + ); + assert checkExpectNoErrors("M1", lib.pcfg); + + touch(getRascalModuleLocation("M1", lib.pcfg)); // keep src of M1 but change modification time + lib = setTPLVersionOfProject("0.0.0", lib); // set rascalTplVersion to incompatible version number + // tpl is more recent than source + + // Create project "client" and module "M2" and then compile "M2" + // "client" uses "lib" as library but lib's sources remain available + clientName = "client"; + client = createProject(clientName, + ("M2": "import M1; // binary import + 'int main() = f(42); // compatible call fo f + "), + createPathConfig(clientName) + [srcs = [src(clientName), src(libName)]] + [libs = [bin(libName)] ] + ); + assert checkExpectNoErrors("M2", client.pcfg, remove = [lib, client]); + return validateTPLVersionOfProject(lib) && validateTPLVersionOfProject(client); +} + /* * rascal: IO -+ rascal: IO' * extend | | | @@ -355,7 +504,7 @@ test bool incompatibleWithBinaryLibraryAfterChange(){ */ test bool incompatibleVersionsOfBinaryLibrary(){ - clearMemory() ; + clearMemory(); rascalName = "rascal"; rascal = createProject(rascalName, @@ -371,7 +520,7 @@ test bool incompatibleVersionsOfBinaryLibrary(){ createProject(typepalName, ("TP": "extend IO;"), createPathConfig(typepalName) - [libs = [resources(rascalName)]] // binary dependency on rascal + [libs = [bin(rascalName)]] // binary dependency on rascal ); assert checkExpectNoErrors("TP", typepal.pcfg); @@ -383,8 +532,8 @@ test bool incompatibleVersionsOfBinaryLibrary(){ 'value main() = f(3); "), createPathConfig(coreName) - [libs = [ resources(rascalName), - resources(typepalName)] ] // binary dependency on rascal and typepal + [libs = [ bin(rascalName), + bin(typepalName)] ] // binary dependency on rascal and typepal ); assert checkExpectNoErrors("Check", core.pcfg); @@ -394,8 +543,10 @@ test bool incompatibleVersionsOfBinaryLibrary(){ // Important: we do not recompile TP (and thus it will contain the outdated version of IO) + // Update Checks' modification time to make sure it will be rechecked + touch(getRascalModuleLocation("Check", core.pcfg)); // Recompile Check and discover the error - return checkExpectErrors("Check", ["Recompilation or reconfiguration needed: binary module `TP` uses incompatible module(s)"], core.pcfg, remove = [rascal, typepal, core]); + return checkExpectErrors("Check", ["Review of dependencies, reconfiguration or recompilation needed: binary module `TP` depends (indirectly) on incompatible module(s)"], core.pcfg, remove = [rascal, typepal, core]); } // ---- Binary compatibility of two TModels ----------------------------------- @@ -411,6 +562,7 @@ AGrammar getGrammar(TModel tm){ throw "`grammar` has incorrect format in store"; } } + // The binary compatibility test for TModels bool binaryCompatible(tuple[TModel old, TModel new] tms){ diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeAndHashTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeAndHashTests.rsc index 6a9bf1a502a..b40dc9ed3e0 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeAndHashTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeAndHashTests.rsc @@ -121,7 +121,7 @@ tuple[TModel old, TModel new] checkBoth(str oldM, str newM){ srcs=[|memory://stableHashProject/src|], bin=|memory://stableHashProject/bin|, generatedSources=|memory://stableHashProject/generated|, - resources=|memory://stableHashProject/resources|, + generatedResources=|memory://stableHashProject/resources|, libs=[] ); @@ -311,6 +311,12 @@ test bool consFieldLayoutChanged1() test bool consFieldLayoutChanged2() = expectEqual("data D = d(int n);", "data D = d (int n);"); +test bool consDifferentNewlineCount() + = expectEqual("data A = a(list[A] children\n\n);", "data A = a(list[A] children\n\n\n);"); + +test bool consDifferentNewlineChars() + = expectEqual("data A = a(list[A] children\n);", "data A = a(list[A] children\r\n);"); + // Keyword fields n and m generate separate locs, therefore we filter on constructors test bool consKwFieldChanged() @@ -349,7 +355,9 @@ test bool synParameterLayoutChanged() = expectEqualGrammar("syntax A[&T] = &T;", "syntax A[ &T ] = &T ;"); test bool synStartChanged() - = expectNotEqualGrammar("syntax A = \"a\";", "start syntax A = \"a\";"); + // start is no longer included in the type of the nonterminal; + // the grammar itself is therefore not changed + = expectEqualGrammar("syntax A = \"a\";", "start syntax A = \"a\";"); test bool synStartLayoutChanged() = expectEqualGrammar("start syntax A = \"a\";", "start syntax A = \"a\" ;"); @@ -540,4 +548,30 @@ test bool synUnequalChanged2() test bool synUnequalLayoutChanged() = expectEqualGrammar("syntax A = \"a\"; syntax B = \"b\"; syntax C = \"c\"; syntax D = A \\ \"b\";", - "syntax A = \"a\"; syntax B = \"b\"; syntax C = \"c\"; syntax D = A \\ \"b\" ;"); \ No newline at end of file + "syntax A = \"a\"; syntax B = \"b\"; syntax C = \"c\"; syntax D = A \\ \"b\" ;"); + +// Hash function properties + +test bool normalizedHashLayout(str S1, str S2) + = normalizedMD5Hash(" ") == normalizedMD5Hash(""); + +test bool normalizedHashParts1(str S1, str S2) + = normalizedMD5Hash("") != normalizedMD5Hash(S1, S2); + +test bool normalizedHashParts2(str S1, str S2) + = normalizedMD5Hash(S1, "", S2) != normalizedMD5Hash(S1, S2); + +test bool normalizedHashParts3(str S1, str S2) + = normalizedMD5Hash("|") != normalizedMD5Hash(S1, S2); + +test bool normalizedHashAnyValues(value V1, value V2) + = str _ := normalizedMD5Hash(V1, V2); + +test bool normalizedHashIdentity1(str S1) + = normalizedMD5Hash(S1) == normalizedMD5Hash(S1); + +test bool normalizedHashIdentity2(str S1, str S2) + = normalizedMD5Hash(S1) == normalizedMD5Hash(S2) + ? removeWhitespace(S1) == removeWhitespace(S2) + : S1 != S2 + ; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeScenarioTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeScenarioTests.rsc index 037d40b494c..28d9b0f1ca0 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeScenarioTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ChangeScenarioTests.rsc @@ -30,6 +30,7 @@ module lang::rascalcore::check::tests::ChangeScenarioTests import lang::rascalcore::check::tests::StaticTestingUtils; import lang::rascalcore::check::TestConfigs; extend lang::rascalcore::check::CheckerCommon; +import lang::rascalcore::check::ModuleLocations; import util::Reflective; import util::Benchmark; import IO; @@ -107,37 +108,47 @@ test bool fixMissingExtend(){ test bool fixErrorInImport(){ clearMemory(); - assert checkModuleOK("module A public bool b = false;"); - B = "module B import A; int n = b + 1;"; + assert checkModuleOK("module A public bool a = false;"); + B = "module B import A; int b = a + 1;"; assert unexpectedTypeInModule(B); - assert checkModuleOK("module A public int b = 0;"); // change b to type int + assert checkModuleOK("module A public int a = 0;"); // change a to type int return checkModuleOK(B); } test bool fixErrorInExtend(){ clearMemory(); - assert checkModuleOK("module A bool b = false;"); - B = "module B extend A; int n = b + 1;"; + assert checkModuleOK("module A bool a = false;"); + B = "module B extend A; int b = a + 1;"; assert unexpectedTypeInModule(B); - assert checkModuleOK("module A int b = 0;"); // change b to type int + assert checkModuleOK("module A int a = 0;"); // change a to type int return checkModuleOK(B); } +test bool fixErrorInIndirectExtend(){ + clearMemory(); + assert checkModuleOK("module A public bool a = false;"); + assert checkModuleOK("module B extend A;"); + C = "module C import B; int c = a + 1;"; + assert unexpectedTypeInModule(C); + assert checkModuleOK("module A public int a = 0;"); // change a to type int + return checkModuleOK(C); +} + test bool introduceErrorInImport(){ clearMemory(); - assert checkModuleOK("module A public int b = 0;"); - B = "module B import A; int n = b + 1;"; + assert checkModuleOK("module A public int a = 0;"); + B = "module B import A; int b = a + 1;"; assert checkModuleOK(B); - assert checkModuleOK("module A public bool b = false;"); + assert checkModuleOK("module A public bool a = false;"); return unexpectedTypeInModule(B); } test bool introduceErrorInExtend(){ clearMemory(); - assert checkModuleOK("module A int b = 0;"); - B = "module B extend A; int n = b + 1;"; + assert checkModuleOK("module A int a = 0;"); + B = "module B extend A; int b = a + 1;"; assert checkModuleOK(B); - assert checkModuleOK("module A bool b = false;"); + assert checkModuleOK("module A bool a = false;"); return unexpectedTypeInModule(B); } @@ -225,6 +236,23 @@ test bool removeConstructorAndRestoreIt(){ return checkModuleOK(B); } +test bool correctToIncorrectModuleOK(){ + clearMemory(); + Aloc = writeModule("module A + 'import B; + 'int x = y;"); + Bloc = writeModule("module B + 'public int y = 123;"); + assert checkModuleOK(Aloc); + Aloc = writeModule("module A + 'import B; + 'int x = y; // foo"); + Bloc = writeModule("module B + 'public str y = \"foo\";"); + assert checkModuleOK(Bloc); + return unexpectedDeclarationInModule(Aloc); +} + // ---- incremental type checking --------------------------------------------- // Legend: @@ -246,7 +274,7 @@ test bool removeConstructorAndRestoreIt(){ // | | | // *C1! *C1 *C1 -test bool nobreakingChange1(){ +test bool noBreakingChange1(){ clearMemory(); A1 = "module A"; A2 = "module A @@ -294,7 +322,7 @@ test bool nobreakingChange1(){ // | | | | // +--*E!---+ +---*E----+ -test bool nobreakingChange2(){ +test bool noBreakingChange2(){ clearMemory(); A1 = "module A"; B1 = "module B import A;"; @@ -441,46 +469,171 @@ test bool breakingChange1(){ return expectReChecks(D, ["C", "D"]); } +test bool fixedErrorsDisappearCompact() { + clearMemory(); + pcfg = getDefaultTestingPathConfig(); + + mlocs = writeModules(" + module ParserBase + "); + + assert checkModulesOK(mlocs, pathConfig=pcfg) : "Precondition failed: no errors expected!"; + + // Introduce a type error (import of module that does not exist) + l = writeModule(" + module ParserBase + + import vis::ParseTree; // module does not exist -\> error + + "); + + assert missingModuleInModule(l, pathConfig=pcfg) : "Precondition failed: expected at least one error, but got none!"; + + return true; +} + +test bool fixedErrorsDisappear() { // ht @toinehartman + clearMemory(); + pcfg = getReleasedStandardLibraryTestingPathConfig(); + pcfg = pcfg[libs = [RASCAL42]]; + + iprintln(pcfg); + + // Write a set of modules with imports, that should type-check without errors + mlocs = writeModules(" + module ParserBase + + import analysis::grammars::Ambiguity; + import FileLocations; + import ParseTree; + // import vis::ParseTree; // module does not exist + + import Debugging; + import FileUtility; + ", " + module FileLocations + ", " + module Debugging + + import DateTime; + import FileLocations; + + import FileUtility; + import StringUtility; + ", " + module FileUtility + + import FileLocations; + + import Debugging; + import ListUtility; + import StringUtility; + ", " + module ListUtility + ", " + module StringUtility + + + import Debugging; + import ListUtility; + import MathUtility; + ", " + module MathUtility + "); + + // Type-check everything + assert checkModulesOK(mlocs, pathConfig=pcfg) : "Precondition failed: no errors expected!"; + + // Introduce a type error (import of module that does not exist) + l = writeModule(" + module ParserBase + + import analysis::grammars::Ambiguity; + import FileLocations; + import ParseTree; + import vis::ParseTree; // module does not exist -\> error + + import Debugging; + import FileUtility; + "); + + // Type-check only the changed module + assert missingModuleInModule(l, pathConfig=pcfg) : "Precondition failed: expected at least one error, but got none!"; + + // Fix the error again, by removing the import. Now, we are at exactly the same state as where we started (without errors). + l = writeModule(" + module ParserBase + + import analysis::grammars::Ambiguity; + import FileLocations; + import ParseTree; + // import vis::ParseTree; + + import Debugging; + import FileUtility; + "); + + // Type-check only the changed module + assert checkModuleOK(l, pathConfig=pcfg) : "Expected no errors after reverting, but got some!"; + return true; +} + // ---- touch and recheck modules --------------------------------------------- -bool touchAndCheck(loc Top, list[str] moduleNames, PathConfig pcfg){ +bool touchAndCheck(loc topLoc, list[str] moduleNames, PathConfig pcfg){ println("TOUCH "); - for(mname <- moduleNames){ - touch(getRascalModuleLocation(mname, pcfg)); + mlocs = [ getRascalModuleLocation(mname, pcfg) | mname <- moduleNames ]; + for(mloc <- mlocs){ + touch(mloc); } - return expectReChecks(Top, moduleNames, pathConfig=pcfg); + return expectReChecks([topLoc, *mlocs], moduleNames + getModuleName(topLoc, pcfg), pathConfig=pcfg); } void safeRemove(loc l){ try remove(l, recursive=true); catch _:; } +@ignore{Investigate, after clearing messages} +test bool onlyTouchedModulesAreReChecked0(){ + clearMemory(); + pcfg = getRascalWritablePathConfig(); + safeRemove(pcfg.generatedResources); + topLoc = getRascalModuleLocation("List", pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); + assert validateBOMs(pcfg); + + assert touchAndCheck(topLoc, ["Exception"], pcfg); + return touchAndCheck(topLoc, ["Map"], pcfg); +} +@ignore{Can no longer test in this way since all "Checked .." messages are preserved} test bool onlyTouchedModulesAreReChecked1(){ + clearMemory(); pcfg = getRascalWritablePathConfig(); - safeRemove(pcfg.resources); - Top = getRascalModuleLocation("analysis::grammars::Ambiguity", pcfg); - assert checkModuleOK(Top, pathConfig = pcfg); + safeRemove(pcfg.generatedResources); + topLoc = getRascalModuleLocation("analysis::grammars::Ambiguity", pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); assert validateBOMs(pcfg); - assert touchAndCheck(Top, ["Exception"], pcfg); - assert touchAndCheck(Top, ["Set"], pcfg); - assert touchAndCheck(Top, ["Grammar"], pcfg); - return touchAndCheck(Top, ["Exception", "Set", "Grammar"], pcfg); + assert touchAndCheck(topLoc, ["Exception"], pcfg); + assert touchAndCheck(topLoc, ["Set"], pcfg); + assert touchAndCheck(topLoc, ["Grammar"], pcfg); + return touchAndCheck(topLoc, ["Exception", "Set", "Grammar"], pcfg); } @ignore{Very expensive test} test bool onlyTouchedModulesAreReChecked2(){ + clearMemory(); pcfg = getAllSrcWritablePathConfig(); - safeRemove(pcfg.resources); - Top = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); - assert checkModuleOK(Top, pathConfig = pcfg); + safeRemove(pcfg.generatedResources); + topLoc = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); assert validateBOMs(pcfg); - assert touchAndCheck(Top, ["Exception"], pcfg); - assert touchAndCheck(Top, ["Set"], pcfg); - assert touchAndCheck(Top, ["Exception", "Set"], pcfg); - assert touchAndCheck(Top, ["lang::rascalcore::check::CollectType"], pcfg); - return touchAndCheck(Top, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", "lang::rascalcore::check::CollectType"], pcfg); + assert touchAndCheck(topLoc, ["Exception"], pcfg); + assert touchAndCheck(topLoc, ["Set"], pcfg); + assert touchAndCheck(topLoc, ["Exception", "Set"], pcfg); + assert touchAndCheck(topLoc, ["lang::rascalcore::check::CollectType"], pcfg); + return touchAndCheck(topLoc, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", "lang::rascalcore::check::CollectType"], pcfg); } // ---- change and recheck modules -------------------------------------------- @@ -510,67 +663,110 @@ void restoreModules(list[str] moduleNames, PathConfig pcfg){ } } -bool changeAndCheck(loc Top, list[str] moduleNames, PathConfig pcfg, str injectedError=""){ +bool changeAndCheck(loc topLoc, list[str] moduleNames, PathConfig pcfg, str injectedError=""){ println("CHANGE "); + mlocs = [ getModuleLocation(mname, pcfg) | mname <- moduleNames ]; changeModules(moduleNames, pcfg, injectedError=injectedError); - return expectReChecks(Top, moduleNames, pathConfig=pcfg, errorsAllowed = injectedError?); + return expectReChecks([topLoc, *mlocs], moduleNames, pathConfig=pcfg, errorsAllowed = injectedError?); } -value main(){ +test bool onlyChangedModulesAreReChecked0(){ pcfg = getRascalWritablePathConfig(); - TopName = "Boolean"; - Top = getRascalModuleLocation(TopName, pcfg); - //assert changeAndCheck(Top, [TopName, "Exception"], pcfg, injectedError="int X = false;"); - changeModules([TopName], pcfg, injectedError="int X = false;"); - assert unexpectedDeclarationInModule(Top); - restoreModules([TopName], pcfg); - assert checkModuleOK(Top); + safeRemove(pcfg.generatedResources); + topLoc = getRascalModuleLocation("List", pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); + assert validateBOMs(pcfg); + + assert changeAndCheck(topLoc, ["Exception"], pcfg); + return changeAndCheck(topLoc, ["Map"], pcfg); +} + +test bool simpleChange(){ + ALoc = writeModule("module A import B; void f() throws EmptyList {}"); + BLoc = writeModule("module B data RuntimeException = EmptyList();"); + + assert checkModuleOK(ALoc); + assert checkModuleOK(BLoc); + writeModule("module A import B; void f() throws EmptyList {} public int n = 0;"); + assert checkModuleOK(ALoc); + assert checkModuleOK(BLoc); return true; } +test bool changedExtendedModule(){ + ALoc = writeModule("module A extend B;"); + BLoc = writeModule("module B extend C;"); + CLoc = writeModule("module C"); + ScratchLoc = writeModule("module Scratch import A; import B;"); + + assert checkModuleOK(ScratchLoc); + writeModule("module B extend C; int b = 0;"); + assert checkModuleOK(BLoc); + touch(ScratchLoc); + return checkModuleOK(ScratchLoc); +} + +// Issue #2562, ht @sungshik (Sung-Shik Jongmans) + +test bool changedExtendedModules(){ + ALoc = writeModule("module A extend B;"); + BLoc = writeModule("module B extend C;"); + CLoc = writeModule("module C"); + + assert checkModuleOK(ALoc); + writeModule("module A extend B; "); // extra space + writeModule("module C "); // extra space + + return checkModulesOK([ALoc, ALoc]); +} + +@ignore{Can no longer test in this way since all "Checked .." messages are preserved} test bool onlyChangedModulesAreReChecked1(){ + clearMemory(); pcfg = getRascalWritablePathConfig(); - safeRemove(pcfg.resources); - TopName = "analysis::grammars::Ambiguity"; - Top = getRascalModuleLocation(TopName, pcfg); - assert checkModuleOK(Top, pathConfig = pcfg); + safeRemove(pcfg.generatedResources); + str topName = "analysis::grammars::Ambiguity"; + loc topLoc = getRascalModuleLocation(topName, pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); assert validateBOMs(pcfg); - assert changeAndCheck(Top, ["Exception"], pcfg); - assert changeAndCheck(Top, ["Set"], pcfg); - assert changeAndCheck(Top, ["Grammar"], pcfg); - assert changeAndCheck(Top, ["Exception", "Set", "Grammar"], pcfg); + assert changeAndCheck(topLoc, ["Exception"], pcfg); + assert changeAndCheck(topLoc, ["Set"], pcfg); + assert changeAndCheck(topLoc, ["Grammar"], pcfg); + assert changeAndCheck(topLoc, ["Exception", "Set", "Grammar"], pcfg); assert validateBOMs(pcfg); restoreModules(["Exception", "Set", "Grammar"], pcfg); // Error scenario's - assert changeAndCheck(Top, [TopName], pcfg, injectedError="int X = false;"); - assert unexpectedDeclarationInModule(Top, pathConfig=pcfg); - restoreModules([TopName], pcfg); + assert changeAndCheck(topLoc, [topName], pcfg, injectedError="int X = false;"); + assert unexpectedDeclarationInModule(topLoc, pathConfig=pcfg); + restoreModules([topName], pcfg); - assert changeAndCheck(Top, ["Exception"], pcfg, injectedError="str S = 10;"); - assert unexpectedDeclarationInModule(Top, pathConfig=pcfg); + loc exceptionLoc = getRascalModuleLocation("Exception", pcfg); + assert changeAndCheck(topLoc, ["Exception"], pcfg, injectedError="str S = 10;"); + assert unexpectedDeclarationInModule(exceptionLoc, pathConfig=pcfg); restoreModules(["Exception"], pcfg); - assert checkModuleOK(Top, pathConfig=pcfg); + assert checkModuleOK(topLoc, pathConfig=pcfg); return true; } @ignore{Very expensive test} test bool onlyChangedModulesAreReChecked2(){ + clearMemory(); pcfg = getAllSrcWritablePathConfig(); - safeRemove(pcfg.resources); - Top = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); - assert checkModuleOK(Top, pathConfig = pcfg); + safeRemove(pcfg.generatedResources); + topLoc = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); + assert checkModuleOK(topLoc, pathConfig = pcfg); assert validateBOMs(pcfg); - assert changeAndCheck(Top, ["Exception"], pcfg); - assert changeAndCheck(Top, ["Set"], pcfg); - assert changeAndCheck(Top, ["Exception", "Set"], pcfg); - assert changeAndCheck(Top, ["lang::rascalcore::check::CollectType"], pcfg); - assert changeAndCheck(Top, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", + assert changeAndCheck(topLoc, ["Exception"], pcfg); + assert changeAndCheck(topLoc, ["Set"], pcfg); + assert changeAndCheck(topLoc, ["Exception", "Set"], pcfg); + assert changeAndCheck(topLoc, ["lang::rascalcore::check::CollectType"], pcfg); + assert changeAndCheck(topLoc, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", "lang::rascalcore::check::CollectType"], pcfg); assert validateBOMs(pcfg); @@ -579,6 +775,47 @@ test bool onlyChangedModulesAreReChecked2(){ return true; } +loc TYPEPAL166 = |mvn://org.rascalmpl--typepal--0.16.6-RC1/|; +test bool changeMultipleTimes() { // ht @toinehartman + loc projDir = |memory:///incremental-test/proj|; + loc checkerModule = projDir + "src" + "Checker.rsc"; + + PathConfig pcfg = pathConfig( + projectRoot = projDir, + srcs = [projDir + "src"], + bin = projDir + "target", + // There might be incompatibility here, since Rascal uses typepal--0.16.6-RC2 at the time of writing. + // However, I would still expect that errors caused by that appear on the first type-check. + libs = [TYPEPAL166, RASCAL42] + ); + iprintln(pcfg); + + // Clean + remove(projDir); + writeFile(checkerModule, " + module Checker + extend analysis::typepal::TypePal; + void collect(Collector c) { ; } + "); + + // First check + println("Initial check"); + if (!checkModuleOK(checkerModule, pathConfig = pcfg)) { + throw "First check failed; supposed to be OK."; + } + int N_TRIES = 10; + // Since this seems sporadically succeed, we run this a couple of times until it fails + for (i <- [1..N_TRIES + 1]) { + // Follow-up check + println("Follow-up check #"); + touch(checkerModule); + if (!checkModuleOK(checkerModule, pathConfig = pcfg)) { + return false; + } + } + return true; +} + // Benchmarks for incremental type checking void benchmark(str title, lrel[str, void()] cases){ @@ -595,75 +832,95 @@ void benchmark(str title, lrel[str, void()] cases){ void touchOne(){ pcfg = getRascalWritablePathConfig(); - safeRemove(pcfg.resources); - TopName = "ParseTree"; - Top = getRascalModuleLocation("ParseTree", pcfg); + safeRemove(pcfg.generatedResources); + str topName = "ParseTree"; + topLoc = getRascalModuleLocation("ParseTree", pcfg); cases = - [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }> - // <", touched", void(){ touchAndCheck(Top, [TopName], pcfg); }> + [<", first", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }> + // <", touched", void(){ touchAndCheck(topLoc, [topName], pcfg); }> ]; benchmark("touchOne", cases); } -void miniBenchmarkRechecking(){ +void miniBenchmarkRechecking1(){ pcfg = getRascalWritablePathConfig(); - safeRemove(pcfg.resources); - TopName = "ParseTree"; - Top = getRascalModuleLocation("ParseTree", pcfg); + safeRemove(pcfg.generatedResources); + topName = "ParseTree"; + topLoc = getRascalModuleLocation("ParseTree", pcfg); cases = - [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", nochange", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", touched", void(){ touchAndCheck(Top, [TopName], pcfg); }>, - <"Exception", void(){ touchAndCheck(Top, ["Exception"], pcfg); }>, - <"Set", void(){ touchAndCheck(Top, ["Set"], pcfg); }>, - <"Exception+Set", void(){ touchAndCheck(Top, ["Exception", "Set"], pcfg); }> + [<", first", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", nochange", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", touched", void(){ touchAndCheck(topLoc, [topName], pcfg); }>, + <"Exception", void(){ touchAndCheck(topLoc, ["Exception"], pcfg); }>, + <"Set", void(){ touchAndCheck(topLoc, ["Set"], pcfg); }>, + <"Exception+Set", void(){ touchAndCheck(topLoc, ["Exception", "Set"], pcfg); }> ]; - benchmark("miniBenchmarkRechecking", cases); + benchmark("miniBenchmarkRechecking1", cases); +} + +void miniBenchmarkRechecking2(){ + pcfg = getRascalWritablePathConfig(); + safeRemove(pcfg.generatedResources); + topName = "ParseTree"; + topLoc = getRascalModuleLocation("ParseTree", pcfg); + + cases = + [<", first", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", nochange", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", touched", void(){ touchAndCheck(topLoc, [topName], pcfg); }>, + <"Exception", void(){ touchAndCheck(topLoc, ["Exception"], pcfg); }>, + <"Set", void(){ touchAndCheck(topLoc, ["Set"], pcfg); }>, + <"Exception+Set", void(){ touchAndCheck(topLoc, ["Exception", "Set"], pcfg); }> + ]; + benchmark("miniBenchmarkRechecking2", cases); } void mediumBenchmarkRechecking(){ pcfg = getRascalWritablePathConfig(); - safeRemove(pcfg.resources); - TopName = "analysis::grammars::Ambiguity"; - Top = getRascalModuleLocation(TopName, pcfg); + safeRemove(pcfg.generatedResources); + topName = "analysis::grammars::Ambiguity"; + topLoc = getRascalModuleLocation(topName, pcfg); cases = - [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", nochange", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", touched", void(){ touchAndCheck(Top, [TopName], pcfg); }>, - <"Exception", void(){ touchAndCheck(Top, ["Exception"], pcfg); }>, - <"Set", void(){ touchAndCheck(Top, ["Set"], pcfg); }>, - <"Grammar", void(){ touchAndCheck(Top, ["Grammar"], pcfg); }>, - <"Exception+Set+Grammar", void(){ touchAndCheck(Top, ["Exception", "Set", "Grammar"], pcfg); }> + [<", first", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", nochange", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", touched", void(){ touchAndCheck(topLoc, [topName], pcfg); }>, + <"Exception", void(){ touchAndCheck(topLoc, ["Exception"], pcfg); }>, + <"Set", void(){ touchAndCheck(topLoc, ["Set"], pcfg); }>, + <"Grammar", void(){ touchAndCheck(topLoc, ["Grammar"], pcfg); }>, + <"Exception+Set+Grammar", void(){ touchAndCheck(topLoc, ["Exception", "Set", "Grammar"], pcfg); }> ]; benchmark("mediumBenchmarkRechecking", cases); } void largeBenchmarkRechecking(){ - pcfg = getAllSrcWritablePathConfig(); - safeRemove(pcfg.resources); - TopName = "lang::rascalcore::check::Checker"; - Top = getRascalModuleLocation(TopName, pcfg); + pcfg = getAllSrcREPOPathConfig(); + safeRemove(pcfg.generatedResources); + topName = "lang::rascalcore::check::Checker"; + topLoc = getRascalModuleLocation(topName, pcfg); cases = - [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", nochange", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, - <", touched", void(){ touchAndCheck(Top, [TopName], pcfg); }>, - <"Exception", void(){ touchAndCheck(Top, ["Exception"], pcfg); }>, - <"Set", void(){ touchAndCheck(Top, ["Set"], pcfg); }>, - <"Grammar", void(){ touchAndCheck(Top, ["Grammar"], pcfg); }>, - <"Exception+Set+Grammar", void(){ touchAndCheck(Top, ["Exception", "Set", "Grammar"], pcfg); }>, - <"lang::rascalcore::check::CollectType", void(){ touchAndCheck(Top, ["lang::rascalcore::check::CollectType"], pcfg); }>, - <"5 modules changed", void(){ touchAndCheck(Top, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", "lang::rascalcore::check::CollectType"], pcfg); }> + [<", first", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", nochange", void(){ checkModuleOK(topLoc, pathConfig = pcfg); }>, + <", touched", void(){ touchAndCheck(topLoc, [topName], pcfg); }>, + <"Exception", void(){ touchAndCheck(topLoc, ["Exception"], pcfg); }>, + <"Set", void(){ touchAndCheck(topLoc, ["Set"], pcfg); }>, + <"Grammar", void(){ touchAndCheck(topLoc, ["Grammar"], pcfg); }>, + <"Exception+Set+Grammar", void(){ touchAndCheck(topLoc, ["Exception", "Set", "Grammar"], pcfg); }>, + <"lang::rascalcore::check::CollectType", void(){ touchAndCheck(topLoc, ["lang::rascalcore::check::CollectType"], pcfg); }>, + <"5 modules changed", void(){ touchAndCheck(topLoc, ["Exception", "Set", "ParseTree", "analysis::typepal::TypePal", "lang::rascalcore::check::CollectType"], pcfg); }> ]; benchmark("largeBenchmarkRechecking", cases); } void allBenchmarks(){ - miniBenchmarkRechecking(); + beginTime = cpuTime(); + miniBenchmarkRechecking1(); + miniBenchmarkRechecking2(); mediumBenchmarkRechecking(); - largeBenchmarkRechecking(); + //largeBenchmarkRechecking(); + println("Total time: <(cpuTime() - beginTime)/1000000> ms"); } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc index 439ff4972b6..2271b724e36 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc @@ -528,4 +528,41 @@ test bool Issue480() = checkModuleOK(" | box(Figure inner = emptyFigure()); value my_main() = (!(ellipse(inner=emptyFigure(fillColor=\"red\")).fillColor == \"white\")); - "); \ No newline at end of file + "); + +test bool clashingFieldNamesOk() + = checkModuleOK(" + module A + data D = d1(int x) | d2(str x); + "); + +test bool clashingFieldNamesInImportOk(){ + writeModule("module A data D = d1(int x);"); + + return checkModuleOK(" + module B + import A; + data D = d2(str x); + "); +} + +test bool clashingFieldNamesInImportsOk(){ + writeModule("module A data D = d1(int x);"); + writeModule("module B data D = d2(str x);"); + + return checkModuleOK("module C import A;import B;"); +} +test bool fieldSelectionFromDestructuringAssignment(){ // ht @toinehartman + writeModule("module A data TModel = tmodel();"); + writeModule("module B + extend A; + data TModel(set[str] kwArg = {});"); + return checkModuleOK( + "module C + import B; + value main() { + \ = \; // tm\'s type is a tvar, is it handled below? + + return tm.kwArg; // Potential error: Unresolved type for useViaType `kwArg` in |file:.....| + }"); +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc index 89a4ac6a11f..58d81e033ee 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc @@ -97,7 +97,7 @@ test bool RedeclaredVarDeclaration(){ test bool ModuleVarReDeclaration(){ writeModule("module MMM public int n = 1; - public int n = 2;"); + public str n = \"a\";"); return redeclaredVariableInModule(" module ModuleVarReDeclaration import MMM; @@ -274,14 +274,41 @@ test bool UseVariableInConcreteSyntax() { "); } +test bool RedeclaredConstructorViaImportOk(){ + writeModule("module MMM data DATA = d(int n);"); + return checkModuleOK(" + module RedeclaredConstructorViaImportOk + import MMM; + data DATA = d(int m); + "); +} -test bool RedeclareConstructorError(){ +test bool RedeclaredConstructorInSameModuleNotOk(){ writeModule("module MMM data DATA = d(int n);"); return unexpectedDeclarationInModule(" - module RedeclareConstructorError + module RedeclaredConstructorInSameModuleNotOk + data DATA = d(int n); + data DATA = d(int m); + "); +} + +test bool OverloadedConstructorDifferentADTOnUseNotOk(){ + writeModule("module MMM data DATA = d(int n);"); + return unexpectedTypeInModule(" + module OverloadedConstructorDifferentADTOnUseNotOk + import MMM; + data DATA2 = d(int m); + value main() = d(4); + "); +} + +test bool OverloadedConstructorSameADTOnUseNotOk(){ + writeModule("module MMM data DATA = d(int n);"); + return unexpectedTypeInModule(" + module OverloadedConstructorSameADTOnUseNotOk import MMM; data DATA = d(int m); - DATA x = d(3); + value main() = d(4); "); } @@ -672,8 +699,7 @@ test bool LU4(){ test bool LU5() { writeModule("module A int twice(int n) = 2 * n;"); writeModule("module B - import A; - import B;"); + import A;"); return checkModuleOK(" module LU5 import A; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/FunctionTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/FunctionTCTests.rsc index be8cb085995..a68e56d33ce 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/FunctionTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/FunctionTCTests.rsc @@ -91,3 +91,24 @@ test bool matchNotOK1() = unexpectedType("bool f(&A \<: str a, &B \<:int b) = &A } return n; }"); + + +test bool ADTConstructorAsArgNotOk(){ + return argumentMismatchInModule(" + module ADTConstructorAsArgNotOk + data A = a(int i); + + void f(void(A) _) { } + + void main(){ f(a); }"); +} + +test bool SyntaxConstructorAsArgNotOk(){ + return argumentMismatchInModule(" + module SyntaxConstructorAsArgNotOk + syntax A = a: \"a\"; + + void f(void(A) _) { } + + void main(){ f(a); }"); +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ImportTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ImportTCTests.rsc index 502fae8ef08..a1c75f53910 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ImportTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ImportTCTests.rsc @@ -59,4 +59,289 @@ test bool UndefinedPrivateFunction(){ import M; value main() = f(); "); +} + +test bool FunctionNotVisibleViaIndirectImport(){ + writeModule("module A int twice(int n) = 2 * n;"); + writeModule("module B import A;"); + return undeclaredTypeInModule(" + module FunctionNotVisibleViaIndirectImport + import B; + int t = twice(3); + "); +} + +test bool FunctionVisibleViaExtend(){ + writeModule("module A int twice(int n) = 2 * n;"); + writeModule("module B extend A;"); + return checkModuleOK(" + module FunctionVisibleViaExtend + import B; + int t = twice(3); + "); +} + +test bool ADTNotVisibleViaIndirectImport(){ + writeModule("module A data D = d1();"); + writeModule("module B import A;"); + return undeclaredTypeInModule(" + module ADTNotVisibleViaIndirectImport + import B; + D x = d1(); + "); +} + +test bool ADTVisibleViaExtend(){ + writeModule("module A data D = d1();"); + writeModule("module B extend A;"); + return checkModuleOK(" + module ADTVisibleViaExtend + import B; + D x = d1(); + "); +} + +test bool SyntaxNotVisibleViaIndirectImport(){ + writeModule("module A syntax A = \"a\";"); + writeModule("module B import A;"); + return undeclaredTypeInModule(" + module SyntaxNotVisibleViaIndirectImport + import B; + A x = [A] \"a\"; + "); +} + +test bool SyntaxVisibleViaExtend(){ + writeModule("module A syntax A = \"a\";"); + writeModule("module B extend A;"); + return checkModuleOK(" + module SyntaxVisibleViaExtend + import B; + A x = [A] \"a\"; + "); +} + +// Diamond example suggested by Jurgen Vinju + +str MBottom = "module Bottom + 'data Exp; + 'data Bool = \true() | \false();"; + +str MLeft = "module Left + 'extend Bottom; + 'data Exp = or(Exp lhs, Exp rhs)| maybe() | \true() | \false();"; + +str MRight = "module Right + 'extend Bottom; + 'data Exp = and(Bool lhs, Bool rhs); + 'data Exp2 = or(Exp lhs, Exp rhs);"; + +test bool ImportsWithConflictingConstructorsAllowed(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module ImportsWithConflictingConstructorsAllowed + import Left; import Right; // ok: Both imports declare constructor `or` + "); +} + +test bool OverloadedTrueIsOk(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedTrueIsOk + import Left; import Right; + Exp main(){ + return \true(); // ok: resolved to Exp::\true() by declared return type Exp of main + } + "); +} + +test bool OverloadedTrueIsResolved(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedTrueIsResolved + import Left; import Right; + Exp main(){ + return Left::\true(); // ok: explicit disambiguation is not needed here + } + "); +} + +test bool OverloadedTrueIsNotResolved(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return unexpectedTypeInModule(" + module OverloadedTrueIsNotResolved + import Left; import Right; + value main(){ + return \true(); // not ok: explicit disambiguation is needed here due to value return type of main + } + "); +} + +test bool OverloadedTrueIsResolvedIncorrectly(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return unexpectedTypeInModule(" + module OverloadedTrueIsResolvedIncorrectly + import Left; import Right; + Exp main(){ + return Bool::\true(); // not ok: wrong explicit disambiguation + } + "); +} + +test bool OverloadedFieldOk(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedFieldOk + import Left; import Right; + Exp main(){ + x = and(Bool::\true(), Bool::\true()); + return x.lhs; // ok: x has already been resolved to Bool in previous statement + } + "); +} + +test bool OverloadedOrOk(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedOrNotOk + import Left; import Right; + Exp main(){ + return or(maybe(), maybe()); // ok: or is resolved via return type Exp of main + } + "); +} + +test bool OverloadedOrIsResolvedOk(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedOrIsResolvedOk + import Left; import Right; + Exp main(){ + return Exp::or(maybe(), maybe()); // ok: redundant disambiguation of or + } + "); +} + +test bool OverloadedFieldLhsOk1(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return checkModuleOK(" + module OverloadedFieldLhsOk1 + import Left; import Right; + Exp main(){ + Exp2 x = or(maybe(), maybe()); // ok: resolved to Exp::or thanks to declared type Exp of x + Exp y = x.lhs; // ok: lhs is overloaded, but resolved by inferred type Exp of x + return y; + } + "); +} + +test bool OverloadedFieldLhsNotOk1(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return unexpectedTypeInModule(" + module OverloadedFieldLhsNotOk1 + import Left; import Right; + Exp main(){ + x = or(maybe(), maybe()); // or cannot be resolved + y = x.lhs; // not ok: x is overloaded, no field selection possible + return y; + } + "); +} + +test bool OverloadedFieldLhsNotOk2(){ + writeModule(MBottom); writeModule(MLeft); writeModule(MRight); + return unexpectedTypeInModule(" + module OverloadedFieldLhsNotOk2 + import Left; import Right; + Exp main(){ + x = or(maybe(), maybe()); // or cannot be resolved + return or(x.lhs, x.lhs); // not ok: x is overloaded, no field selection possible + } + "); +} + +test bool OverloadedModuleVarNotOk(){ + writeModule("module Left public str global = \"World\";"); + writeModule("module Right public str global = \"Hello\";"); + return redeclaredVariableInModule(" + module OverloadedModuleVarNotOk + import Left; import Right; + str main() = global; // not ok: global is ambiguous, disambiguation required + "); +} + +test bool QualifiedOverloadedModuleVarOk(){ + writeModule("module Left public str global = \"World\";"); + writeModule("module Right public str global = \"Hello\";"); + return checkModuleOK(" + module OverloadedModuleVarOk + import Left; import Right; + str main() = Left::global; // ok: global is explicitly resolved + "); +} + +test bool selfImportNotOK(){ + return unexpectedDeclarationInModule("module A import A;"); +} + +test bool selfExtendNotOK(){ + return unexpectedDeclarationInModule("module A extend A;"); +} + +test bool cyclic2ImportOk(){ + writeModule("module A import B;"); + return checkModuleOK("module B import A;"); +} + +test bool cyclic3ImportOk(){ + writeModule("module A import B;"); + writeModule("module B import C;"); + return checkModuleOK("module C import A;"); +} + +test bool cyclic2ExtendNotOk(){ + writeModule("module A extend B;"); + return unexpectedDeclarationInModule("module B extend A;"); +} + +test bool cyclic2MixedOk(){ + writeModule("module A extend B;"); + return unexpectedDeclarationInModule("module B import A;"); +} + +test bool cyclic3ExtendNotOk(){ + writeModule("module A extend B;"); + writeModule("module B extend C;"); + return unexpectedDeclarationInModule("module C extend A;"); +} + +test bool cyclic3MixedNotOk1(){ + writeModule("module A import B;"); + writeModule("module B extend C;"); + return unexpectedDeclarationInModule("module C extend A;"); +} + +test bool cyclic3MixedNotOk2(){ + writeModule("module A extend B;"); + writeModule("module B import C;"); + return unexpectedDeclarationInModule("module C extend A;"); +} + +test bool cyclic3MixedNotOk3(){ + writeModule("module A extend B;"); + writeModule("module B extend C;"); + return unexpectedDeclarationInModule("module C import A;"); +} + +test bool indirectExtendOk(){ + writeModule("module A int f() = 42;"); + writeModule("module B extend A;"); + return checkModuleOK("module C extend B; int main() = f();"); +} + +test bool extendWithImportCycleOK(){ + writeModule("module Base alias INTEGER = int;"); + writeModule("module BaseExtended extend Base;"); + writeModule("module A2 extend BaseExtended; import A1; INTEGER N = 0;"); + return checkModuleOK("module A1 extend Base; import A2; INTEGER M = 1;"); } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PackagerTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PackagerTests.rsc new file mode 100644 index 00000000000..ee153433ed7 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PackagerTests.rsc @@ -0,0 +1,103 @@ +@license{ +Copyright (c) 2018-2025, NWO-I CWI, Swat.engineering and Paul Klint +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +} +module lang::rascalcore::check::tests::PackagerTests + +import lang::rascalcore::check::Checker; +import lang::rascalcore::check::RascalConfig; +import lang::rascalcore::package::Packager; + +import Location; +import Map; +import IO; +import ValueIO; +import Message; + +import util::FileSystem; +import util::PathConfig; + +private void runChecker(PathConfig pcfg, list[str] mnames) { + result = checkModules(mnames, rascalCompilerConfig(pcfg)); + for (/e:error(_,_) := result) { + println(e); + } +} + +test bool packagerRewritesTModelsCorrectly () { + println("**** Checking List"); + tplRoot = |memory://packager-test/|; + originalBin = tplRoot + "rascal-lib"; + rewrittenBin = tplRoot + "rascal-lib-rewritten"; + rascalLibPcfg = + pathConfig(srcs = [|mvn://org.rascalmpl--rascal--0.41.0-RC15/|], + bin = originalBin); + runChecker(rascalLibPcfg, ["List"]); + assert validateTModels(rascalLibPcfg.bin) : "Tpls before packager are not correct"; + println("**** Running packager"); + lang::rascalcore::package::Packager::main(pcfg = rascalLibPcfg, + sourceLookup=rascalLibPcfg.srcs[0], + relocatedClasses=rewrittenBin); + assert validateTModels(rewrittenBin): "Tpls after packager are not correct"; + return true; +} + +bool validateTModels(loc bin){ + println("**** Validating TModels in "); + bool result = true; + for (loc file <- find(bin, "tpl")) { + result = result && isValidTModel(readBinaryValueFile(file)); + } + return result; +} + +// Validity check on TModels focussing on the occurrence of logical/physical locations +bool isValidTModel(TModel tm){ + bool result = true; + + void report(str msg){ + result = false; + println(msg); + } + visit(tm.paths){ + case loc l: if(!isModuleId(l)) report("Paths: Expected moduleId, found "); + } + visit(domain(tm.logical2physical)){ + case loc l: if(!isRascalLogicalLoc(l)) report("logical2physical: Expected logical loc, found "); + } + visit(range(tm.logical2physical)){ + case loc l: if(isRascalLogicalLoc(l)) report("logical2physical: Expected physical loc, found "); + } + + visit(range(tm.moduleLocs)){ + case loc l: if(!isRascalLogicalLoc(l)) report("moduleLocs: Expected logical loc, found "); + } + + visit(tm.messages){ + case loc l: if(isRascalLogicalLoc(l)) report("messages: Expected physical loc, found "); + } + + return result; +} diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ParameterizedTypes.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ParameterizedTypes.rsc index 22917c93db9..6a4cc3e3263 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ParameterizedTypes.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/ParameterizedTypes.rsc @@ -135,6 +135,72 @@ test bool MaybeBoundViolated() = unexpectedTypeInModule(" Maybe[&S \<: num] mb() { if(3 \> 2) return just(3); return just(\"Abc\"); } "); +test bool MaybeMatchNothingOK() = checkModuleOK(" + module MaybeMatchNothingOK + data Maybe[&T] = none() | just(&T arg); + bool f() = just(&T \<: node t) := none(); + "); + +test bool MaybeInPattern1OK() = checkModuleOK(" + module MaybeInPattern1OK + data Tree = empty(); + data Maybe[&A] = nothing() | just(&A val); + + Maybe[&T \<: Tree] tryParseAs(type[&T \<: Tree] _begin) = nothing(); + + Tree parseAsOrEmpty(type[&T \<: Tree] T) = + just(Tree t) := tryParseAs(T) ? t : empty(); + "); + +test bool MaybeInPattern2OK() = checkModuleOK(" + module MaybeInPattern2OK + data Tree = empty(); + data Maybe[&A] = nothing() | just(&A val); + + Maybe[&T \<: Tree] tryParseAs(type[&T \<: Tree] _begin) = nothing(); + + bool parseAsOrEmpty(type[&T \<: Tree] T) = + just(empty()) := tryParseAs(T); + "); + +test bool MaybeInPattern3NOTOK() = unexpectedTypeInModule(" + module MaybeInPattern3NOTOK + data Tree = empty(); + data Maybe[&A] = nothing() | just(&A val); + + Maybe[&T \<: Tree] tryParseAs(type[&T \<: Tree] _begin) = nothing(); + + bool parseAsOrEmpty(type[&T \<: Tree] T) = + just(3) := tryParseAs(T); + "); + +test bool MaybeInIterator1OK() = checkModuleOK(" + module MaybeInIterator1OK + data Maybe[&T] = none() | just(&T arg); + + value f() = [true | i \<- [none(), just(1)]]; + "); + +test bool MaybeInIterator2OK() = checkModuleOK(" + module MaybeInIterator1OK + data Maybe[&T] = none() | just(&T arg); + + value f() = [true | Maybe[int] i \<- [none(), just(1)]]; + "); + +test bool MaybeInIterator3NOTOK() = cannotMatchInModule(" + module MaybeInIterator1OK + data Maybe[&T] = none() | just(&T arg); + + value f() = [true | Maybe[str] i \<- [none(), just(1)]]; + "); +test bool MaybeInIterator4OK() = checkModuleOK(" + module MaybeInIterator4OK + data Maybe[&T] = none() | just(&T arg); + + value f(&T v) = [true | Maybe[&T] i \<- [none(), just(v)]]; + "); + test bool BoundViolatedInCall() = unexpectedTypeInModule(" module BoundViolatedInCall bool strange(&L \<: num _, &R \<: &L _) = false; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PatternTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PatternTCTests.rsc index f2040ffde89..c1050669fcd 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PatternTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/PatternTCTests.rsc @@ -36,7 +36,7 @@ test bool matchNestedSet() = checkOK("{{1}} := {};"); data Bool = and(Bool, Bool) | t(); data Prop = or(Prop, Prop) | f(); -test bool cannotMatchListStr1() = cannotMatch("[1] := \"a\";"); +test bool cannotMatchListStr1() = cannotMatch("[1] := \"a\";"); // int and str are not comparable test bool unguardedMatchNoEscape1() = undeclaredVariable("int n = 3; int m := n; m == n;"); @@ -52,25 +52,29 @@ test bool matchListError1() = redeclaredVariable("list[int] x = [1,2,3]; [1, *in test bool matchListErrorRedeclaredSpliceVar1() = redeclaredVariable("list[int] x = [1,2,3];[1, * int L, * int L] := x;"); -test bool matchListError2() = checkOK("list[int] l = [1,2,3]; [1, list[str] L, 2] := l; "); +test bool matchListError2() = cannotMatch("list[int] l = [1,2,3]; [1, list[str] L, 2] := l; "); // list[str] and int are not comparable -test bool matchBoolIntError1() = cannotMatch("true !:= 1;"); +test bool matchBoolIntError1() = cannotMatch("true !:= 1;"); // bool and int are not comparable -test bool matchBoolIntError2() = cannotMatch("!(1 := true);"); +test bool matchBoolIntError2() = cannotMatch("!(1 := true);"); // int and bool are not comparable -test bool noMatchBoolIntError1() = cannotMatch("true !:= 1;"); + +test bool noMatchBoolIntError1() = cannotMatch("true !:= 1;"); // bool and int are not comparable -test bool noMatchBoolIntError2() = cannotMatch("1 !:= true;"); +test bool noMatchBoolIntError2() = cannotMatch("1 !:= true;"); // int and bool are not comparable + -test bool matchStringBoolError11() = cannotMatch("\"abc\" := true;"); +test bool matchStringBoolError11() = cannotMatch("\"abc\" := true;"); // str and bool are not comparable + -test bool matchStringBoolError21() = cannotMatch("true := \"abc\";"); +test bool matchStringBoolError21() = cannotMatch("true := \"abc\";"); // bool and str are not comparable + -test bool noMatchStringBoolError11() = cannotMatch("\"abc\" !:= true;"); +test bool noMatchStringBoolError11() = cannotMatch("\"abc\" !:= true;"); // str and bool are not comparable -test bool noMatchStringBoolError21() = cannotMatch("true !:= \"abc\";"); +test bool noMatchStringBoolError21() = cannotMatch("true !:= \"abc\";"); // bool and str are not comparable -test bool matchStringIntError11() = cannotMatch("\"abc\" !:= 1;"); +test bool matchStringIntError11() = cannotMatch("\"abc\" !:= 1;"); // str and int are not comparable test bool matchStringIntError2() = cannotMatch("1 !:= \"abc\";"); @@ -95,14 +99,18 @@ test bool noMatchIntRealError1() = cannotMatch("2 !:= 1.5;"); test bool noMatchIntRealError2() = cannotMatch("1.5 !:= 2;"); test bool errorRedclaredVariable1() = redeclaredVariable("{1, *int L, 2, *int L} := {1,2,3};"); - -test bool matchSetWrongElemError1() = checkOK("{1, \"a\", 2, *set[int] L} := {1,2,3};"); - -test bool matchSetWrongElemError2() = checkOK("{1, set[str] L, 2} := {1,2,3};"); -test bool matchSetWrongElemError3() = checkOK("{1, str S, 2} := {1,2,3};"); - -test bool matchSetWrongElemError4() = cannotMatch("set[str] S = {\"a\"}; {1, S, 2} := {1,2,3};"); +// pattern element of type set[int] and subject element type int are not comparable +test bool matchSetWrongElemError1() = cannotMatch("{1, \"a\", 2, *set[int] L} := {1,2,3};"); + +// pattern element of type set[str] and subject element type int are not comparable +test bool matchSetWrongElemError2() = cannotMatch("{1, set[str] L, 2} := {1,2,3};"); + +// pattern element of type str and subject element type int are not comparable +test bool matchSetWrongElemError3() = cannotMatch("{1, str S, 2} := {1,2,3};"); + +// pattern element of type set[str] and subject element type int are not comparable +test bool matchSetWrongElemError4() = cannotMatch("set[str] S = {\"a\"}; {1, S, 2} := {1,2,3};"); test bool matchSetErrorRedeclaredSpliceVar() = redeclaredVariable("set[int] x = {1,2,3}; {1, * int L, * int L} := x;"); @@ -144,15 +152,15 @@ test bool noMatchTupleArityError() = cannotMatch("\<1\> !:= \<1,2\>;"); test bool matchSetStringError() = cannotMatch("{1} := \"a\";"); -test bool matchListError3() = checkOK("list[int] x = [1,2,3]; [1, *list[int] L, 2, list[int] M] !:= x;"); // DISCUSS, was: cannotMatch +test bool matchListError3() = cannotMatch("list[int] x = [1,2,3]; [1, *list[int] L, 2, list[int] M] !:= x;"); test bool matchListError4() = unexpectedDeclaration("!([1, list[int] L, 2, list[int] L] := [1,2,3]);"); -test bool matchListError5() = checkOK("!([1, list[str] L, 2] := [1,2,3]);"); +test bool matchListError5() = cannotMatch("!([1, list[str] L, 2] := [1,2,3]);"); test bool matchListError6() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); -test bool matchListError7() = checkOK("list[int] x = [1,2,3] ; [1, str S, 2] := x;"); // DISCUSS, was: cannotMatch +test bool matchListError7() = cannotMatch("list[int] x = [1,2,3] ; [1, str S, 2] := x;"); test bool matchListError8() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); @@ -169,7 +177,7 @@ test bool RecursiveDataTypeNoPossibleHiddenRecursion() = unexpectedDeclarationIn void main() { p = or(t(),t()); and(t1,t2) := p; } "); -test bool NoDataDecl() = cannotMatchInModule(" +test bool NoDataDecl() = argumentMismatchInModule(" module NoDataDecl data Prop = f(); data Bool = and(list[Prop], list[Prop]) | t(); @@ -274,7 +282,7 @@ test bool Lst1() = checkOK("[] := [1];"); test bool Lst2() = checkOK("[1] := [1];"); test bool Lst3() = checkOK("[1,2] := [1];"); test bool Lst4() = checkOK("[1,2] := [1, 1.5];"); -test bool Lst5() = checkOK("[1,2.5] := [1, 2];"); +test bool Lst5() = cannotMatch("[1,2.5] := [1, 2];"); // real and int are not comparable test bool Lst6() = unexpectedType("[1] := [\"a\"];"); test bool Lst7() = checkOK("[x] := [\"a\"];"); test bool Lst8() = unexpectedType("m && x == \"a\";"); @@ -285,7 +293,7 @@ test bool Set1() = checkOK("{} := {1};"); test bool Set2() = checkOK("{1} := {1};"); test bool Set3() = checkOK("{1,2} := {1};"); test bool Set4() = checkOK("{1,2} := {1, 1.5};"); -test bool Set5() = checkOK("{1,2.5} := {1, 2};"); +test bool Set5() = cannotMatch("{1,2.5} := {1, 2};"); // real and int are not comparable test bool Set6() = unexpectedType("{1} := {\"a\"};"); test bool Set7() = checkOK("{x} := {\"a\"};"); test bool Set8() = checkOK("{x} := {\"a\"} && x == \"a\";"); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc index c8ab14218c9..641121e9b30 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc @@ -36,13 +36,20 @@ module lang::rascalcore::check::tests::StaticTestingUtils import IO; import String; +import Location; import Message; +import Relation; import Set; import util::Reflective; import ParseTree; +import util::FileSystem; import lang::rascalcore::check::RascalConfig; import lang::rascalcore::check::Checker; +import lang::rascalcore::check::TestConfigs; +import lang::rascal::\syntax::Rascal; + +import analysis::typepal::LocationChecks; bool verbose = false; @@ -50,7 +57,7 @@ PathConfig pathConfigForTesting() { return getDefaultTestingPathConfig(); } -str abbrev(str s) { return size(s) < 120 ? s : " ..."; } +str abbrev(str s) { return size(s) < 220 ? s : " ..."; } bool matches(str subject, str pat){ pat = uncapitalize(pat); @@ -76,7 +83,7 @@ loc composeModule(str stmts){ } void clearMemory() { - remove(|memory:///test-modules/| recursive = true); + remove(|memory:///test-modules/|, recursive = true); } str cleanName(str name) = name[0] == "\\" ? name[1..] : name; @@ -88,19 +95,29 @@ loc writeModule(str moduleText){ return mloc; } -void writeModules(str modules...){ - for(mname <- modules){ - writeModule(mname); - } -} +list[loc] writeModules(str modules...) + = [ writeModule(mname) | mname <- modules ]; void removeModule(str mname){ pcfg = getDefaultTestingPathConfig(); name = cleanName(mname); remove(|memory:///test-modules/.rsc|); - remove(pcfg.resources + ".tpl"); + remove(pcfg.generatedResources + ".tpl"); +} + +void printModules(){ + println("\<\<\<\<"); + for(f <- find(|memory:///|, "rsc")){ + println(" : + '"); + } + for(f <- find(|memory:///|, "tpl")){ + println(": "); + } + println("\>\>\>\>"); } + set[Message] getErrorMessages(ModuleStatus r) = { m | m <- getAllMessages(r), m is error }; @@ -111,8 +128,14 @@ set[Message] getAllMessages(ModuleStatus r) = { m | mname <- r.messages, m <- r.messages[mname] }; ModuleStatus checkStatements(str stmts) { + clearMemory(); mloc = composeModule(stmts); - return rascalTModelForLocs([mloc], rascalCompilerConfig(pathConfigForTesting())[infoModuleChecked=true], dummy_compile1); + return rascalTModelForLocs([mloc], rascalCompilerConfig(pathConfigForTesting())[infoModuleChecked=true][verbose=verbose], dummy_compile1); +} + +ModuleStatus checkModule(str moduleText){ + mloc = writeModule(moduleText); + return rascalTModelForLocs([mloc], rascalCompilerConfig(pathConfigForTesting())[infoModuleChecked=true][verbose=verbose], dummy_compile1); } bool checkStatementsAndFilter(str stmts, list[str] expected) { @@ -128,17 +151,17 @@ bool checkStatementsAndFilter(str stmts, list[str] expected) { } bool checkModuleAndFilter(str moduleText, list[str] expected, bool matchAll = false, bool errorsAllowed = true, PathConfig pathConfig = pathConfigForTesting()) { mloc = writeModule(moduleText); - return checkModuleAndFilter(mloc, expected, matchAll=matchAll, errorsAllowed=errorsAllowed, pathConfig=pathConfig); + return checkModuleAndFilter([mloc], expected, matchAll=matchAll, errorsAllowed=errorsAllowed, pathConfig=pathConfig); } -bool checkModuleAndFilter(loc mloc, list[str] expected, bool matchAll = false, bool errorsAllowed = true, PathConfig pathConfig = pathConfigForTesting()) { - ms = rascalTModelForLocs([mloc], rascalCompilerConfig(pathConfig)[infoModuleChecked=true], dummy_compile1); +bool checkModuleAndFilter(list[loc] mlocs, list[str] expected, bool matchAll = false, bool errorsAllowed = true, PathConfig pathConfig = pathConfigForTesting()) { + ms = rascalTModelForLocs(mlocs, rascalCompilerConfig(pathConfig)[infoModuleChecked=true][verbose=verbose], dummy_compile1); msgs = getAllMessages(ms); if (verbose) { println(msgs); } if(!errorsAllowed && !isEmpty(msgs) && any(error(_,_) <- msgs)) return false; matched = {}; - for(eitem <- msgs, str exp <- expected){ + for(Message eitem <- msgs, str exp <- expected){ if(matches(eitem.msg, exp)){ if(matchAll){ matched += eitem.msg; @@ -159,8 +182,10 @@ bool checkOK(str stmts) { throw errors; } -bool checkModuleOK(loc moduleToCheck, PathConfig pathConfig = pathConfigForTesting()) { - errors = getErrorMessages(rascalTModelForLocs([moduleToCheck], rascalCompilerConfig(pathConfig)[infoModuleChecked=true], dummy_compile1)); +bool checkModuleOK(loc moduleToCheck, PathConfig pathConfig = pathConfigForTesting()) = checkModulesOK([moduleToCheck], pathConfig = pathConfig); + +bool checkModulesOK(list[loc] modulesToCheck, PathConfig pathConfig = pathConfigForTesting()) { + errors = getErrorMessages(rascalTModelForLocs(modulesToCheck, rascalCompilerConfig(pathConfig)[infoModuleChecked=true][verbose=verbose], dummy_compile1)); if(size(errors) == 0) return true; throw abbrev(""); @@ -173,10 +198,75 @@ bool checkModuleOK(str moduleText, PathConfig pathConfig = pathConfigForTesting( return checkModuleOK(mloc, pathConfig=pathConfig); } -// bool checkModuleOK(str mbody){ -// mloc = writeModule("TestModule", mbody); -// return checkModuleOK(mloc); -// } +bool validateUseDefs(str moduleName, map[str, tuple[int, set[int]]] defuses, ModuleStatus ms){ + = getModuleParseTree(moduleName2moduleId(moduleName), ms); + map[str,list[loc]] names = (); + map[loc, str] loc2name = (); + top-down-break visit(pt){ + case Name nm: { + names[""] ? [] += [nm@\loc]; + loc2name[nm@\loc] = ""; + } + case QualifiedName nm: { + names[""] ? [] += [nm@\loc]; + loc2name[nm@\loc] = ""; + } + case Nonterminal nm: { + names[""] ? [] += [nm@\loc]; + loc2name[nm@\loc] = ""; + } + + case NonterminalLabel nm: { + names[""] ? [] += [nm@\loc]; + loc2name[nm@\loc] = ""; + } + } + println("names:"); iprintln(names); + = getTModelForModule(moduleName, ms); + foundUseDefs = tm.useDef; + println("foundUseDefs:"); + for( <- foundUseDefs){ + println(": ==\> "); + } + for(u <- domain(foundUseDefs)){ + defs = foundUseDefs[u]; + if(size(defs) != 1){ + throw "Use of name () has multiple defines "; + } + } + for(str v <- defuses){ + = defuses[v]; + list[loc] occ = []; + if(names[v]?) occ = names[v]; else throw "Name not found in tree"; + if(!occ[def]?) throw "Missing define for name "; + for(int u <- uses){ + println("u = "); + if(!occ[u]?){ + throw "Missing use for "; + } + potentialDefs = foundUseDefs[occ[u]]; + // We us containement here, give how the type chcker works at the moment. + // An equality test would be better. + if(isEmpty(potentialDefs) || !any(d <- potentialDefs, isContainedIn(occ[def], d, tm.logical2physical))){ + throw "Missing def for use of "; + } + } + } + return true; +} + +bool useDefOK(str moduleText, map[str, tuple[int, set[int]]] defuses, PathConfig pathConfig = pathConfigForTesting()) { + = extractModuleNameAndBody(moduleText); + pathConfig.srcs += pathConfigForTesting().srcs; + mloc = writeModule(moduleText); + ms = rascalTModelForLocs([mloc], rascalCompilerConfig(pathConfig)[verbose=verbose], dummy_compile1); + + errors = getErrorMessages(ms); + if(size(errors) != 0){ + throw abbrev(""); + } + return validateUseDefs(mname, defuses, ms); +} // ---- unexpectedType -------------------------------------------------------- @@ -195,6 +285,7 @@ list[str] unexpectedTypeMsgs = [ "Return expression does not bind _", "Type of generator should be _, found _", "Pattern should be comparable with _, found _", + "Pattern element should be comparable with _, found _", "Argument of _ should be _, found _", "Cannot call _ with _ argument(s), _", "_ not defined on _ and _", @@ -216,6 +307,7 @@ list[str] unexpectedTypeMsgs = [ "Bounds _ and _ are not comparable", "Type parameter(s) _ in return type of function _ not bound by its formal parameters", "Returned type _ is not always a subtype of expected return type _", + "Return statement with overloaded type _ not allowed", "Type parameter _ should be less than _, found _", "Ambiguous pattern type _", "Splice operator not allowed inside a tuple pattern", @@ -229,14 +321,17 @@ list[str] unexpectedTypeMsgs = [ "Expected _ type parameter(s) for _, found _", "Type _ cannot be parameterized, found _ parameter(s)", "Expected a non-terminal type, found _", - "Expected a binary relation, found _" - ]; + "Expected a binary relation, found _", + "Constructor _ is overloaded", + "Expression _ is overloaded", + "Base expression of field selection is ambiguous and should be resolved" +]; -bool unexpectedTypeInModule(str moduleText) - = checkModuleAndFilter(moduleText, unexpectedTypeMsgs); +bool unexpectedTypeInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, unexpectedTypeMsgs, pathConfig=pathConfig); -bool unexpectedTypeInModule(loc mloc) - = checkModuleAndFilter(mloc, unexpectedTypeMsgs); +bool unexpectedTypeInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], unexpectedTypeMsgs, pathConfig=pathConfig); bool unexpectedType(str stmts) = checkStatementsAndFilter(stmts, unexpectedTypeMsgs); @@ -245,8 +340,8 @@ bool unexpectedType(str stmts) // NOTE: type checker does not yet support analysis of uninitialized variables, therefore this check always succeeds, for now. -bool uninitializedInModule(str moduleText) = true; -bool uninitialized(str stmts) = true; +bool uninitializedInModule(str _) = true; +bool uninitialized(str _) = true; //bool uninitialized(str stmts) = //checkStatementsAndFilter(stmts, [ @@ -264,11 +359,11 @@ list[str] undeclaredVariableMsgs = [ "Variable(s) _ and _ should be introduced on both sides of `||` operator" ]; -bool undeclaredVariableInModule(str moduleText) - = checkModuleAndFilter(moduleText, undeclaredVariableMsgs); +bool undeclaredVariableInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, undeclaredVariableMsgs, pathConfig=pathConfig); -bool undeclaredVariableInModule(loc mloc) - = checkModuleAndFilter(mloc, undeclaredVariableMsgs); +bool undeclaredVariableInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], undeclaredVariableMsgs, pathConfig=pathConfig); bool undeclaredVariable(str stmts) = checkStatementsAndFilter(stmts, undeclaredVariableMsgs); @@ -278,11 +373,11 @@ bool undeclaredVariable(str stmts) = list[str] undeclaredTypeMsgs = [ "Undefined _" ]; -bool undeclaredTypeInModule(str moduleText) - = checkModuleAndFilter(moduleText, undeclaredTypeMsgs); +bool undeclaredTypeInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, undeclaredTypeMsgs, pathConfig=pathConfig); -bool undeclaredTypeInModule(loc mloc) - = checkModuleAndFilter(mloc, undeclaredTypeMsgs); +bool undeclaredTypeInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], undeclaredTypeMsgs, pathConfig=pathConfig); bool undeclaredType(str stmts) = checkStatementsAndFilter(stmts, undeclaredTypeMsgs); @@ -297,7 +392,7 @@ bool undefinedField(str stmts) = // ---- argumentMismatch ------------------------------------------------------ list[str] argumentMismatchMsgs = [ - "Undefined keyword argument _;", + "Undefined keyword argument _", "Expected _ argument(s),", "Expected _ type parameter(s)", "Argument _ should have type _, found _", @@ -305,11 +400,11 @@ list[str] argumentMismatchMsgs = [ "Keyword argument _ has type _, expected _" ]; -bool argumentMismatchInModule(str moduleText) - = checkModuleAndFilter(moduleText, argumentMismatchMsgs); +bool argumentMismatchInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, argumentMismatchMsgs, pathConfig=pathConfig); -bool argumentMismatchInModule(loc mloc) - = checkModuleAndFilter(mloc, argumentMismatchMsgs); +bool argumentMismatchInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], argumentMismatchMsgs, pathConfig=pathConfig); bool argumentMismatch(str stmts) = checkStatementsAndFilter(stmts, argumentMismatchMsgs); @@ -318,14 +413,15 @@ bool argumentMismatch(str stmts) = list[str] redeclaredVariableMsgs = [ "Undefined _ due to double declaration", - "Double declaration of _ _" + "Double declaration of _", + "Multiple declarations of _ are applicable here" ]; -bool redeclaredVariableInModule(str moduleText) - = checkModuleAndFilter(moduleText, redeclaredVariableMsgs); +bool redeclaredVariableInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, redeclaredVariableMsgs, pathConfig=pathConfig); -bool redeclaredVariableInModule(loc mloc) - = checkModuleAndFilter(mloc, redeclaredVariableMsgs); +bool redeclaredVariableInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], redeclaredVariableMsgs, pathConfig=pathConfig); bool redeclaredVariable(str stmts) = checkStatementsAndFilter(stmts, redeclaredVariableMsgs); @@ -338,15 +434,16 @@ list[str] cannotMatchMsgs = [ "Incompatible type in assignment to variable _, expected _, found _", "Pattern should be subtype of _, found _", "Pattern should be comparable with _, found _", + "Pattern element should be comparable with _, found _", "Expected tuple pattern with _ elements, found _", "Pattern variable _ has been introduced before, add explicit declaration of its type" ]; -bool cannotMatchInModule(str moduleText) - = checkModuleAndFilter(moduleText, cannotMatchMsgs); +bool cannotMatchInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, cannotMatchMsgs, pathConfig=pathConfig); -bool cannotMatchInModule(loc mloc) - = checkModuleAndFilter(mloc, cannotMatchMsgs); +bool cannotMatchInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], cannotMatchMsgs, pathConfig=pathConfig); bool cannotMatch(str stmts) = checkStatementsAndFilter(stmts, cannotMatchMsgs); @@ -358,7 +455,9 @@ list[str] unexpectedDeclarationMsgs = [ "Invalid initialization of _", "Undefined _", "Double declaration of _", + "Multiple declarations of _ are applicable here", "Constructor _ overlaps with other declaration for type _, see _", + "Incompatible field _ in _: _ in constructor _ clashes with _ in constructor _", "Constructor _ is used without qualifier and overlaps with other declaration, _", "Unresolved type for _", "Constructor _ in formal parameter should be unique", @@ -373,30 +472,33 @@ list[str] unexpectedDeclarationMsgs = [ "Exclude (`\\`) requires keywords as right argument, found _", "Nested iteration", "Element name _ ignored", - "Non-well-formed _ type, labels must be distinct" + "Non-well-formed _ type, labels must be distinct", + "Self import not allowed", + "Extend cycle not allowed", + "Mixed import/extend cycle not allowed" ]; -bool unexpectedDeclarationInModule(str moduleText, PathConfig pathConfig = pathConfigForTesting()) +bool unexpectedDeclarationInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) = checkModuleAndFilter(moduleText, unexpectedDeclarationMsgs, pathConfig=pathConfig); -bool unexpectedDeclarationInModule(loc mloc, PathConfig pathConfig = pathConfigForTesting()) - = checkModuleAndFilter(mloc, unexpectedDeclarationMsgs, pathConfig=pathConfig); +bool unexpectedDeclarationInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], unexpectedDeclarationMsgs, pathConfig=pathConfig); -bool unexpectedDeclaration(str stmts, PathConfig pathConfig = pathConfigForTesting()) = +bool unexpectedDeclaration(str stmts) = checkStatementsAndFilter(stmts, unexpectedDeclarationMsgs); // ---- missingModule --------------------------------------------------------- list[str] missingModuleMsgs = [ "Reference to name _ cannot be resolved", - "Undefined module _", - "Module _ not found_" + "Undefined module _", + "Module _ not found_" ]; -bool missingModuleInModule(str moduleText) - = checkModuleAndFilter(moduleText, missingModuleMsgs); +bool missingModuleInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, missingModuleMsgs, pathConfig=pathConfig); -bool missingModuleInModule(loc mloc) - = checkModuleAndFilter(mloc, missingModuleMsgs); +bool missingModuleInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], missingModuleMsgs, pathConfig=pathConfig); bool missingModule(str stmts) = checkStatementsAndFilter(stmts, missingModuleMsgs); @@ -408,11 +510,11 @@ list[str] illegalUseMsgs = [ "Right-hand side of assignment does not always have a value" ]; -bool illegalUseInModule(str moduleText) - = checkModuleAndFilter(moduleText, illegalUseMsgs); +bool illegalUseInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, illegalUseMsgs, pathConfig=pathConfig); -bool illegalUseInModule(loc mloc) - = checkModuleAndFilter(mloc, illegalUseMsgs); +bool illegalUseInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], illegalUseMsgs, pathConfig=pathConfig); bool illegalUse(str stmts) = @@ -424,11 +526,11 @@ list[str] nonVoidTypeMsgs = [ "Contribution to _ comprehension should not have type `void`" ]; -bool nonVoidTypeInModule(str moduleText) - = checkModuleAndFilter(moduleText, nonVoidTypeMsgs); +bool nonVoidTypeInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, nonVoidTypeMsgs, pathConfig=pathConfig); -bool nonVoidTypeInModule(loc mloc) - = checkModuleAndFilter(mloc, nonVoidTypeMsgs); +bool nonVoidTypeInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], nonVoidTypeMsgs, pathConfig=pathConfig); bool nonVoidType(str stmts) = checkStatementsAndFilter(stmts, nonVoidTypeMsgs); @@ -439,11 +541,11 @@ list[str] unsupportedMsgs = [ "Unsupported _" ]; -bool unsupportedInModule(str moduleText) - = checkModuleAndFilter(moduleText, unsupportedMsgs); +bool unsupportedInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter(moduleText, unsupportedMsgs, pathConfig=pathConfig); -bool unsupportedInModule(loc mloc) - = checkModuleAndFilter(mloc, unsupportedMsgs); +bool unsupportedInModule(loc mloc, PathConfig pathConfig = getDefaultTestingPathConfig()) + = checkModuleAndFilter([mloc], unsupportedMsgs, pathConfig=pathConfig); bool unsupported(str stmts) = checkStatementsAndFilter(stmts, unsupportedMsgs); @@ -453,12 +555,13 @@ bool unsupported(str stmts) = bool expectReChecks(str moduleText, list[str] moduleNames, PathConfig pathConfig = pathConfigForTesting(), bool errorsAllowed=false){ mloc = writeModule(moduleText); pathConfig.srcs += pathConfigForTesting().srcs; - return expectReChecks(mloc, moduleNames, pathConfig=pathConfig, errorsAllowed=errorsAllowed); + mlocs = mloc + [ getModuleLocation(mn, pathConfig) | mn <- moduleNames ]; + return expectReChecks(mlocs, moduleNames, pathConfig=pathConfig, errorsAllowed=errorsAllowed); } -bool expectReChecks(loc mloc, list[str] moduleNames, PathConfig pathConfig = pathConfigForTesting(), bool errorsAllowed=false){ +bool expectReChecks(list[loc] mlocs, list[str] moduleNames, PathConfig pathConfig = pathConfigForTesting(), bool errorsAllowed=false){ msgs = [ "Checked " | nm <- moduleNames ]; - return checkModuleAndFilter(mloc, msgs, matchAll=true, errorsAllowed=errorsAllowed, pathConfig = pathConfig); + return checkModuleAndFilter(mlocs, msgs, matchAll=true, errorsAllowed=errorsAllowed, pathConfig = pathConfig); } bool expectReChecksWithErrors(str moduleText, list[str] moduleNames, PathConfig pathConfig = pathConfigForTesting()){ @@ -468,5 +571,6 @@ bool expectReChecksWithErrors(str moduleText, list[str] moduleNames, PathConfig bool expectReChecksWithErrors(loc mloc, list[str] moduleNames, PathConfig pathConfig = pathConfigForTesting()){ msgs = [ "Checked " | nm <- moduleNames ]; - return checkModuleAndFilter(mloc, msgs, matchAll=true, errorsAllowed=true, pathConfig=pathConfig); -} \ No newline at end of file + mlocs = mloc + [ getModuleLocation(mn, pathConfig) | mn <- moduleNames ]; + return checkModuleAndFilter(mlocs, msgs, matchAll=true, errorsAllowed=true, pathConfig=pathConfig); +} diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtilsTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtilsTests.rsc index efd3d106c93..96785eb1f69 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtilsTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtilsTests.rsc @@ -28,6 +28,8 @@ POSSIBILITY OF SUCH DAMAGE. module lang::rascalcore::check::tests::StaticTestingUtilsTests import lang::rascalcore::check::tests::StaticTestingUtils; +import lang::rascalcore::check::CheckerCommon; +import Set; // Sanity check on the testing utilities themselves @@ -111,3 +113,30 @@ test bool TestUtils12() = checkModuleOK(" int main() = size([1,2,3]); "); +test bool tmodelWrittenWhenNoErrors() { + ms = checkModule("module A"); + = getTModelForModule("A", ms); + errors = getErrorMessages(ms); + assert found : "A not found: "; + assert isEmpty(errors) : ""; + return true; +} + +test bool tmodelWrittenWhenErrors() { + ms = checkModule("module A int a = x;"); + = getTModelForModule("A", ms); + errors = getErrorMessages(ms); + assert found : "A not found: "; + assert !isEmpty(errors) : ""; + return true; +} + +test bool tmodelClearedAfterChanges() { + ms = checkModule("module A int a = \"a\";"); + errors = getErrorMessages(ms); + assert !isEmpty(errors) : ""; + ms = checkModule("module A int a = 1;"); + errors = getErrorMessages(ms); + assert isEmpty(errors) : ""; + return true; +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc new file mode 100644 index 00000000000..eb11cc05d52 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc @@ -0,0 +1,104 @@ +module lang::rascalcore::check::tests::UseDefTests + +import lang::rascalcore::check::tests::StaticTestingUtils; + +test bool localVar1() = + useDefOK("module LocalVar1 + void main() { + int x = 10; + int y = x + x; + }", ("x": <0, {1, 2}>)); + +test bool globalVar1() = + useDefOK("module LocalVar1 + int x = 10; + void main() { + int y = x + x; + }", ("x": <0, {1, 2}>)); + +test bool fun1() = + useDefOK("module Fun + int f(int n) = n; + int main() = f(3);", + ("f": <0, {1}>)); + +test bool overloadedFun() { + mtext = "module OverloadedFun + int f(int n) = n; // first declaration of f + int f(bool b) = 0; // second declaration of f + int main1() = f(3); + int main2() = f(false);"; + return useDefOK(mtext, ("f": <0, {2}>)) // check uses of first declaration of f + && useDefOK(mtext, ("f": <1, {3}>)) // check uses of second declaration of f + ; +} + +test bool formal1() = + useDefOK("module Formal + int f(int n) = n;", + ("n": <0, {1}>)); + +test bool kw1() = + useDefOK("module KW + int f(int n = 0) = n;", + ("n": <0, {1}>)); + +test bool field1() = + useDefOK("module Field + data D = d(int n); + value main(){ + x = d(10); + return x.n; + }", + ("n": <0, {1}>)); + +test bool overloadedField() { + mtext = "module OverloadedField + data D = d(int n); // first declaration of n + data E = e(int n); // second declaration of n + value main(){ + x = d(10); + y = e(20); + return x.n + y.n; + }"; + return useDefOK(mtext, ("n": <0, {2}>)) // check uses of first declaration of n + && useDefOK(mtext, ("n": <1, {3}>)) // check uses of second declaration of n + ; +} + +@ignore{to be fixed in typechecker} + +test bool kwfield1() = + useDefOK("module KWField + data D = d(int n = 0); + value main(){ + x = d(n = 10); + return x.n; + }", + ("n": <0, {1, 2}>)); + +test bool syntaxField1() = + useDefOK("module SyntaxField + syntax C = \"c\"; + syntax D = C c; + value main(){ + x = [D] \"c\"; + return x.c; + }", + ("c": <0, {1}>)); + +test bool overloadedSyntaxField(){ + mtext = "module SyntaxField + syntax C = \"c\"; + syntax D = C c; // First declaration of c + syntax E = \"e\"; + syntax F = E c; // Second declaration of c + value main(){ + x = [D] \"c\"; + y = [F] \"e\"; + return [x.c, y.c]; + }"; + return useDefOK(mtext, ("c": <0, {2}>)) // check uses of first declaration of c + && useDefOK(mtext, ("c": <1, {3}>)) // check uses of first declaration of c + ; +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/download-test-jars.sh b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/download-test-jars.sh new file mode 100644 index 00000000000..84f0a0d91b0 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/download-test-jars.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +set -e -o pipefail + +function download() { + mvn dependency:get -DgroupId="$1" -DartifactId="$2" -Dversion="$3" +} + +# these should be synced with `TestConfigs.rsc` +download "org.rascalmpl" "rascal" "0.41.0-RC15" +download "org.rascalmpl" "rascal" "0.42.0-RC2" +download "org.rascalmpl" "typepal" "0.14.8" +download "org.rascalmpl" "typepal" "0.14.1" +download "org.rascalmpl" "typepal" "0.16.6-RC1" +download "org.rascalmpl" "drambiguity" "0.1.2" +download "org.rascalmpl" "flybytes" "0.1.5" +download "org.rascalmpl" "salix-core" "0.2.7" +download "org.rascalmpl" "salix-contrib" "0.2.7" +download "org.rascalmpl" "rascal-lsp" "2.21.2" \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Compile.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Compile.rsc index 2312ed7d5d5..8946aeb5af2 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Compile.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Compile.rsc @@ -35,8 +35,6 @@ import IO; import Set; import ValueIO; import util::Monitor; - -import lang::rascal::\syntax::Rascal; extend lang::rascalcore::check::Checker; import lang::rascalcore::check::RascalConfig; @@ -48,16 +46,12 @@ import lang::rascalcore::compile::muRascal2Java::CodeGen; import lang::rascalcore::compile::CompileTimeError; import lang::rascalcore::compile::util::Names; - -bool errorsPresent(TModel tmodel) = !isEmpty([ e | e:error(_,_) <- tmodel.messages ]); -bool errorsPresent(list[Message] msgs) = !isEmpty([ e | e:error(_,_) <- msgs ]); - data ModuleStatus; -list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig){ +list[Message] compile1(MODID moduleId, lang::rascal::\syntax::Rascal::Module M, map[MODID,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig){ + qualifiedModuleName = moduleId2moduleName(moduleId); pcfg = ms.pathConfig; - // = getTModelForModule(qualifiedModuleName, ms); - tm = transient_tms[qualifiedModuleName]; + tm = transient_tms[moduleId]; //iprintln(tm, lineLimit=10000); if(errorsPresent(tm)){ return tm.messages; @@ -79,10 +73,10 @@ list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::M = getTPLReadLoc(qualifiedModuleName, pcfg); - if(tplFound && exists(classFile) && lastModified(classFile) > lastModified(tplFile)){ - println("Reusing compiled Java file for: "); - return tm.messages; - } + // if(tplFound && exists(classFile) && lastModified(classFile) > lastModified(tplFile)){ + // println("Reusing compiled Java file for: "); + // return tm.messages; + // } = r2mu(M, tm, compilerConfig); @@ -93,10 +87,10 @@ list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::M return tm.messages; } - imports = { imp | <- ms.strPaths, m1 == qualifiedModuleName }; - extends = { ext | <- ms.strPaths, m1 == qualifiedModuleName }; + imports = { imp | <- ms.paths, m1 == moduleId }; + extends = { ext | <- ms.paths, m1 == moduleId }; tmodels = (); - for(m <- imports + extends, tpl_uptodate() in ms.status[m]){ + for(m <- imports + extends, hasProperty(m, ms, tpl_uptodate())){ if(m in transient_tms){ tmodels[m] = transient_tms[m]; } else { @@ -104,9 +98,11 @@ list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::M tmodels[m] = tpl; } } - tmodels[qualifiedModuleName] = tm; + // tmodels[qualifiedModuleName] = tm; + ms = addTModel(moduleId, tm, ms); - = muRascal2Java(muMod, tmodels, ms.moduleLocs, pcfg); + = muRascal2Java(muMod, ms); + // = muRascal2Java(muMod, tmodels, ms.moduleLocs, pcfg); writeFile(interfaceFile, the_interface); writeFile(classFile, the_class); @@ -123,13 +119,17 @@ list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::M return tm.messages; } +list[Message] compile(list[loc] moduleLocs, RascalCompilerConfig compilerConfig) { + return [info("not yet implemented", moduleLocs[0])]; +} + @doc{Compile a Rascal source module (given at a location) to Java} list[Message] compile(loc moduleLoc, RascalCompilerConfig compilerConfig) { pcfg = compilerConfig.typepalPathConfig; msgs = validatePathConfigForCompiler(pcfg, moduleLoc); if(!isEmpty(msgs)){ - return msgs; + return toList(msgs); } moduleName = "**unknown**"; try { @@ -142,19 +142,65 @@ list[Message] compile(loc moduleLoc, RascalCompilerConfig compilerConfig) { @doc{Compile a Rascal source module (given as qualifiedModuleName) to Java} list[Message] compile(str qualifiedModuleName, RascalCompilerConfig compilerConfig){ + return compile([qualifiedModuleName], compilerConfig); +} + +@doc{Compile a list of Rascal source modules to Java} +list[Message] compile(list[str] qualifiedModuleNames, RascalCompilerConfig compilerConfig){ pcfg = compilerConfig.typepalPathConfig; msgs = validatePathConfigForCompiler(pcfg, |unknown:///|); if(!isEmpty(msgs)){ - return msgs; + return toList(msgs); } - if(compilerConfig.verbose) { println("Compiling .. "); } + if(compilerConfig.verbose) { println("Compiling .. "); } start_comp = cpuTime(); - ms = rascalTModelForNames([qualifiedModuleName], compilerConfig, compile1); + ms = rascalTModelForNames(qualifiedModuleNames, compilerConfig, compile1); comp_time = (cpuTime() - start_comp)/1000000; - if(compilerConfig.verbose) { println("Compiled ... in ms [total]"); } - - return toList(ms.messages[qualifiedModuleName] ? {}); + if(compilerConfig.verbose) { println("Compiled ... in ms [total]"); } + return [*(ms.messages[moduleName2moduleId(m)] ? {}) | m <- qualifiedModuleNames]; +} + +int main( + PathConfig pcfg = pathConfig(), + list[loc] \modules = [], + bool logPathConfig = false, + bool logImports = false, + bool verbose = false, + bool logWrittenFiles = false, + bool warnUnused = true, + bool warnUnusedFormals = true, + bool warnUnusedVariables = true, + bool warnUnusedPatternFormals = true, + bool infoModuleChecked = false, + bool errorsAsWarnings = false, + bool warningsAsErrors = false + ) { + + pcfg.generatedResources = pcfg.bin; + pcfg.generatedTestResources = pcfg.bin; + + rascalConfig = rascalCompilerConfig(pcfg, + logPathConfig = logPathConfig, + verbose = verbose, + logWrittenFiles = logWrittenFiles, + warnUnused = warnUnused, + warnUnusedFormals = warnUnusedFormals, + warnUnusedVariables = warnUnusedVariables, + warnUnusedPatternFormals = warnUnusedPatternFormals, + infoModuleChecked = infoModuleChecked + ); + + list[Message] messages = []; + if (\modules == []) { + // the `compile` function throws EmptyList() on an empty list of modules + messages = [ info("No modules to compile.", |unknown:///|) ]; + } + else { + messages = compile(\modules, rascalConfig); + } + + return mainMessageHandler(messages, projectRoot=pcfg.projectRoot, errorsAsWarnings=errorsAsWarnings, warningsAsErrors=warningsAsErrors); } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/CompileTimeError.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/CompileTimeError.rsc index c846555d1fb..1b597e6fefd 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/CompileTimeError.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/CompileTimeError.rsc @@ -31,6 +31,5 @@ import Message; data Exception = CompileTimeError(Message msg) | InternalCompilerError(Message msg) - | rascalTplVersionError(str txt) - | rascalBinaryNeedsRecompilation(str moduleName, Message msg) + | rascalTplVersionError(str moduleName, loc tpl, str version, str txt) ; \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/A.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/A.rsc index a6f9f092d4c..2691ad4b174 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/A.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/A.rsc @@ -25,5 +25,5 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } module lang::rascalcore::compile::Examples::A - -public int X = 42; \ No newline at end of file + +extend lang::rascalcore::compile::Examples::B; \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/AssignmentTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/AssignmentTests.rsc deleted file mode 100644 index 64faba4831e..00000000000 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/AssignmentTests.rsc +++ /dev/null @@ -1,199 +0,0 @@ -@license{ -Copyright (c) 2018-2025, NWO-I CWI, Swat.engineering and Paul Klint -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -} -module lang::rascalcore::compile::Examples::AssignmentTests - -value main() = 42; - -test bool assignIntViaExternal() { - x = 0; - - int f(int n) { x = x + 1; return n; } - - void g(){ - x += f(9); - } - g(); - return x == 10; -} - -test bool assignStrViaExternal() { - x = ""; - - str f(str n) { x = x + "a"; return n; } - - void g(){ - x += f("b"); - } - g(); - return x == "ab"; -} - -test bool assignDateTimeViaExternal() { // TODO - x = $2022-09-03T09:51:21.097+00:00$; - - int f(int n) { x.year = 1000; return n; } - - void g(){ - x.hour = f(1); - } - g(); - return x == $1000-09-03T01:51:21.097+00:00$; -} - - -test bool assignLocViaExternal() { - x = |file:///home/paulk/pico.trm|(0,1,<2,3>,<4,5>); - - int f(int n) { x.length = 100; return n; } - - void g(){ - x.offset = f(9); - } - g(); - return x == |file:///home/paulk/pico.trm|(9,100,<2,3>,<4,5>); -} - -test bool assignTupleViaExternal1(){ - tuple[int x, int y, int z] facts = <0,1,2>; - - int f(int n) { facts.y = 100; return n; } - - void g(){ - facts.x = f(9); - } - - g(); - return facts == <9,100,2>; -} - -test bool assignTupleViaExternal2(){ - tuple[int x, int y, int z] facts = <0,1,2>; - - int f(int n) { facts[1] = 100; return n; } - - void g(){ - facts[0] = f(9); - } - - g(); - return facts == <9,100,2>; -} - -test bool assignListViaExternal1(){ - facts = []; - - int f(int n) { facts += 0; return n; } - - void g(){ - facts += f(9); - } - - g(); - return facts == [0,9]; -} - -test bool assignListViaExternal2(){ - facts = []; - - list[int] f(list[int] n) { facts += [0]; return n; } - - void g(){ - facts += f([9]); - } - - g(); - return facts == [0,9]; -} - -test bool assignListViaExternal3(){ // eval/comp differ - facts = [1,2]; - - int f(int n) { facts += [0]; return n; } - - void g(){ - facts[f(1)] = 9; - } - - g(); - return facts == [1,9,0]; -} - -test bool assignMapViaExternal(){ - facts = (); - - int f(int n) { facts[n] =100; return n; } - - void g(){ - facts[10] = f(9); - } - - g(); - return facts == (10:9,9:100); -} - -test bool assignSetViaExternal1() { - facts = {}; - - int f(int n) { facts += 100; return n; } - - void g(){ - facts += f(9); - } - - g(); - return facts == {9,100}; -} - -test bool assignSetViaExternal2() { - facts = {}; - - set[int] f(set[int] n) { facts += {100}; return n; } - - void g(){ - facts += f({9}); - } - - g(); - return facts == {9, 100}; -} - -//// node -// -data D = d(int x, int y, int z); - -test bool assignADTViaExternal(){ - facts = d(0,1,2); - - int f(int n) { facts.y = 100; return n; } - - void g(){ - facts.x = f(9); - } - - g(); - return facts == d(9,100,2); -} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/B.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/B.rsc index 8d72f237034..a2629e3e8cb 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/B.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/B.rsc @@ -24,10 +24,26 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } -module lang::rascalcore::compile::Examples::B -import IO; -import lang::rascalcore::compile::Examples::A; - -void main(){ - X += 1; -} \ No newline at end of file +module lang::rascalcore::compile::Examples::B +extend lang::rascalcore::compile::Examples::C; + +// int x = 1; +// // data D = d(int n) | d(str s); + +// // void f(D x){ +// // d(arg) := x; +// // } + +// syntax Body = "body"; + +// alias Body = int; + +// Body f(Body b) = b; + +// // data AType; + +// // data MuExp = muFailReturn(AType tp); + +// // MuExp muReturn1(AType t, muFailReturn(AType t)){ +// // return muFailReturn(t); +// // } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/ShowTPL.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/C.rsc similarity index 73% rename from src/org/rascalmpl/compiler/lang/rascalcore/compile/ShowTPL.rsc rename to src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/C.rsc index 9fc618aca40..7213915c02a 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/ShowTPL.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/C.rsc @@ -24,21 +24,4 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } -module lang::rascalcore::compile::ShowTPL - -import IO; -import ValueIO; -extend lang::rascalcore::check::CheckerCommon; - -void show(loc tplLoc, bool definitions=false){ - tm = readBinaryValueFile(#TModel, tplLoc); - if(definitions) iprintln(tm.definitions, lineLimit=10000); - else iprintln(tm, lineLimit=10000); -} - -void search(str key, loc tplLoc){ - tm = readBinaryValueFile(#TModel, tplLoc); - for(def <- tm.defines){ - if(def.id == key) println(def); - } -} \ No newline at end of file +module lang::rascalcore::compile::Examples::C \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CheckerBug.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CheckerBug.rsc new file mode 100644 index 00000000000..1ee40b5dc3c --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CheckerBug.rsc @@ -0,0 +1,59 @@ +module lang::rascalcore::compile::Examples::CheckerBug + +import IO; +import List; +import util::FileSystem; +import util::Reflective; +import lang::rascalcore::check::Checker; + +set[loc] checkAndGetTPLs(loc srcFile, RascalCompilerConfig ccfg) { + msgs = check([srcFile], ccfg); + iprintln(msgs); + msgs = [program(l, errors) | program(loc l, allMsgs) <- msgs, errors := {m | m <- allMsgs, m is error}, errors !:= {}]; + if (msgs != []) { + print("Errors: "); + iprintln(msgs); + } + + return find(ccfg.typepalPathConfig.bin, "tpl"); +} + +void main(loc birdCoreDir = |file:///Users/paulklint/git/bird/bird-core|) { + // simplified path config from second-level run + PathConfig pcfg = pathConfig( + projectRoot = birdCoreDir + , srcs = [birdCoreDir + "src/main/rascal" + // ,|file:///Users/paulklint/git/rascal/src/org/rascalmpl/library| + // ,|file:///Users/paulklint/git/typepal/src/| + ] + , libs = [ + //0.41.0-RC54 error + //0.40.3-RC3 error + //0.40.17 ok + + |mvn://org.rascalmpl--rascal--0.41.0-RC54|, + |mvn://org.rascalmpl--typepal--0.15.1| + ] + , bin = birdCoreDir + "/target/classes" + , resources = [] + ); + + + ccfg = rascalCompilerConfig(pcfg); + + // clean + remove(pcfg.bin); + println("Checking `lang::bird::Syntax`..."); + syntaxTPLs = checkAndGetTPLs(birdCoreDir + "/src/main/rascal/lang/bird/Syntax.rsc", ccfg); + print("TPLs: "); + iprintln(syntaxTPLs); + + println(); + + // clean + remove(pcfg.bin); + println("Checking `lang::bird::Checker`..."); + checkerTPLs = checkAndGetTPLs(birdCoreDir + "/src/main/rascal/lang/bird/Checker.rsc", ccfg); + print("TPLs: "); + iprintln(checkerTPLs); +} diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CompareTPLs.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CompareTPLs.rsc new file mode 100644 index 00000000000..0834402d40f --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/CompareTPLs.rsc @@ -0,0 +1,146 @@ +@license{ +Copyright (c) 2018-2025, NWO-I CWI, Swat.engineering and Paul Klint +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +} + +module lang::rascalcore::compile::Examples::CompareTPLs + +import IO; +import List; +import Location; +import Set; +import ValueIO; +import util::FileSystem; +import util::Monitor; + +import analysis::typepal::TModel; +import lang::rascalcore::check::LogicalLocations; + +str JOB = "Comparing TPLs"; + +void main() { + compareTPLs(); +} + +@synopsis{Compare locations in two TPLs two verify only expected (OS-specific newline offset) differences.} +rel[loc, loc, loc] compareTPLs() = job(JOB, rel[loc, loc, loc](void(str, int) step) { + /* + Preconditions + 1. Make sure the right Rascal release JAR is present in the Maven repository. + 2. Compile the same Rascal release locally and copy the JARs to the local target folder. + */ + loc localTarget = |home:///swat/projects/Rascal/rascal/targetBackup/relocatedClasses|; + loc remoteTarget = |mvn://org.rascalmpl--rascal--0.41.3-RC8|; + + rel[loc, loc, loc] differentLocations = {}; + step("Finding local TPLs", 1); + allTPLs = sort(find(localTarget, "tpl"), byPathLength); + jobTodo(JOB, work=size(allTPLs)); + + for (tpl <- allTPLs) { + relTplPath = relativize(localTarget, tpl); + step("Comparing ", 1); + differentLocations += toSet(compareTPL(relTplPath, localTarget, remoteTarget)); + } + + step("Computing statistics", 1); + + set[str] filesWithDiffs = {l.parent.path | l <- differentLocations<0>}; + set[loc] defs = differentLocations<0>; + + println("Number of tested TPLs: "); + println("Found different locations in files.");; + + print("Kinds of different locations: "); + iprintln({l.scheme | l <- differentLocations<0>}); + + return differentLocations; +}, totalWork=2); + +bool byPathLength(loc a, loc b) = a.path < b.path; + +lrel[loc, loc, loc] compareTPL(loc relTplPath, loc localTargetDir, loc unixTargetDir) { + loc localTplPath = resolve(localTargetDir, relTplPath); + loc unixTplPath = resolve(unixTargetDir, relTplPath); + + if (!exists(localTplPath)) { + throw "Local TPL does not exist"; + } + if (!exists(unixTplPath)) { + throw "Unix TPL does not exist"; + } + + localTpl = readBinaryValueFile(#TModel, localTplPath); + unixTpl = readBinaryValueFile(#TModel, unixTplPath); + + differentDefs = [ | <- difference(localTpl.defines.defined, unixTpl.defines.defined)]; + if ([_, *_] := differentDefs) { + println("Differences in defs of (\): "); + iprintln(differentDefs); + println(); + } + + return differentDefs; +} + +lrel[loc, loc] difference(set[loc] lLocs, set[loc] uLocs) = + [ | <- pairs, !isEqualModuloNewlines(l, u)] + when lrel[loc, loc] pairs := zip2(sort(lLocs, lessThan), sort(uLocs, lessThan)); + +bool isEqualModuloNewlines(loc localLoc, loc unixLoc) = isRascalLogicalLoc(localLoc) + ? isEqualLogicalModuloNewlines(localLoc, unixLoc) + : isEqualPhysicalModuloNewlines(localLoc, unixLoc); + +bool isEqualLogicalModuloNewlines(loc localLoc, loc unixLoc) = localLoc == unixLoc; + +bool isEqualPhysicalModuloNewlines(loc localLoc, loc unixLoc) { + if (localLoc.uri != unixLoc.uri) { + throw "URIs not equal: vs. "; + } + + if (!localLoc.begin?) { + // Cannot say anything sensible about newlines without line information + return true; + } + + if (localLoc.begin.line == localLoc.end.line) { + // Single line + return localLoc.length == unixLoc.length + && localLoc.begin == unixLoc.begin + && localLoc.end == unixLoc.end; + } + + // Multi line + return localLoc.begin == unixLoc.begin + && localLoc.end == unixLoc.end; +} + +bool lessThan(loc a, loc b) = a.offset? && a.uri == b.uri + ? a.offset < b.offset + : a.uri < b.uri; + +bool lessThan(tuple[&A, &B] a, tuple[&A, &B] b) = a<0> != b<0> + ? lessThan(a<0>, b<0>) + : lessThan(a<1>, b<1>); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/D.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/D.rsc new file mode 100644 index 00000000000..e1d0f88ce76 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/D.rsc @@ -0,0 +1,5 @@ +module lang::rascalcore::compile::Examples::D + +import lang::rascalcore::compile::Examples::A; +import lang::rascalcore::compile::Examples::B; +// Foooooooooooooo \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/IncompatibleModules.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/IncompatibleModules.rsc new file mode 100644 index 00000000000..ade2dc37503 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/IncompatibleModules.rsc @@ -0,0 +1,66 @@ +module lang::rascalcore::compile::Examples::IncompatibleModules + +// import IO; +// import Map; +// import Set; +// import String; +// import util::Reflective; +// import lang::rascalcore::check::Checker; + +// // Rascal 0.41.0-RC42 +// public loc projectDir = |file:///Users/paulklint/git/rascal/|; + +// // Typepal 0.15.1, met Rascal dependency aangepast naar 0.41.0-RC42 +// public loc typepalLib = |mvn://org.rascalmpl--typepal--0.15.1-SNAPSHOT/|; + +// PathConfig pcfg = pathConfig( +// srcs = [ projectDir + "src/org/rascalmpl/library" +// , projectDir + "src/org/rascalmpl/compiler" +// , projectDir + "test/org/rascalmpl/benchmark"], +// bin = projectDir + "target/classes", +// libs = [typepalLib] +// ); + +// void main() { +// mname = "lang::rascalcore::agrammar::tests::TestGrammars"; +// ccfg = rascalCompilerConfig(pcfg); +// ms = rascalTModelForNames([mname], ccfg, dummy_compile1); +// = getTModelForModule(mname, ms); +// println("Found: "); +// if (!found) { +// print("Messages: "); +// iprintln(ms.messages); + +// = getTModelForModule("analysis::typepal::FailMessage", ms); + +// = isCompatibleBinaryLibrary(tm, ms); + +// println("Names: "); +// iprintln(names); +// } +// } + +// // Is binary library module compatible with its dependencies (originating from imports and extends)? +// tuple[list[str], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatus ms){ +// libName = lib.modelName; +// set[loc] libLogical = domain(lib.logical2physical); +// set[loc] libDefines = { l | l <- libLogical, getModuleNameFromAnyLogical(l) == libName }; +// set[loc] libDependsOn = libLogical - libDefines; +// set[str] libDependsOnModules = { getModuleNameFromAnyLogical(l) | l <- libDependsOn }; +// set[loc] dependentsProvide = {}; +// for(m <- libDependsOnModules){ +// = getTModelForModule(m, ms, convert=false); +// if(found){ +// dependentsProvide += domain(tm.logical2physical); +// } +// } +// unsatisfied = libDependsOn - dependentsProvide; +// if(isEmpty(unsatisfied)){ +// //println("isCompatibleBinaryLibrary : satisfied"); +// return <[], ms>; +// } else { +// //println("isCompatibleBinaryLibrary, unsatisfied: "); +// incompatibleModules = { split("/", u.path)[1] | u <- unsatisfied }; +// return ; +// } +// } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Mystery.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Mystery.rsc new file mode 100644 index 00000000000..b3ec3ac0319 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Mystery.rsc @@ -0,0 +1,29 @@ +module lang::rascalcore::compile::Examples::Mystery +import ParseTree; +import IO; + +data P = t() | f() | axiom(P mine = t()); + +data P(int size = 0); + +// Analysis of the following test in lang::rascal::tests::functionality::Reification +//test bool allConstructorsHaveTheCommonKwParam() +// = all(/choice(def, /cons(_,_,kws,_)) := #P.definitions, label("size", \int()) in kws); + +test bool allConstructorsHaveTheCommonKwParam(){ + iprintln(#P.definitions); + // Alternative computation of the original test + allKws = {kws | /choice(def, /cons(_,_,kws,_)) := #P.definitions}; + result1 = true; + for(kws <- allKws){ + println(": "); + result1 = result1 && label("size", \int()) in kws; + } + // The original test: + result2 = all(/choice(def, /cons(_,_,kws,_)) := #P.definitions && label("size", \int()) in kws); + + println("result1, result2: , "); + return result1 && result2; +} + +bool main() = allConstructorsHaveTheCommonKwParam(); \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Origins.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Origins.rsc new file mode 100644 index 00000000000..7b14b80e9e8 --- /dev/null +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Origins.rsc @@ -0,0 +1,52 @@ +module lang::rascalcore::compile::Examples::Origins + +import String; +import util::Benchmark; +import util::Math; +import IO; + +data StringWithOrigin += stringWithOrigin( + str(str, loc) add, + tuple[str, rel[int, int, loc]]() construct +); + +StringWithOrigin newStringWithOrigin(str initial){ + str current = initial; + rel[int,int,loc] toOrigin = {}; + int len = size(initial); + + str _add(str s, loc orgLoc){ + slen = size(s); + toOrigin += ; + current += s; + return s; + } + + tuple[str, rel[int, int, loc]] _construct(){ + return ; + } + + return stringWithOrigin(_add, _construct); +} + +void main(){ + strings = [arbString(arbInt(50)) | int _ <- [0.. 100000]]; + begin1 = cpuTime(); + result1 = ""; + for(s <- strings) result1 += s; + end1 = cpuTime(); + + begin2 = cpuTime(); + nso = newStringWithOrigin(""); + l = |unknown:///|; + for(s <- strings) nso.add(s, l); + + = nso.construct(); + end2 = cpuTime(); + t1 = (end1 - begin1)/1000000; + t2 = (end2 - begin2)/1000000; + println(" versus : "); + +} + diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/OverlappingFiles.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/OverlappingFiles.rsc deleted file mode 100644 index 7f53820263e..00000000000 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/OverlappingFiles.rsc +++ /dev/null @@ -1,120 +0,0 @@ -@license{ -Copyright (c) 2018-2025, NWO-I CWI, Swat.engineering and Paul Klint -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -} -module lang::rascalcore::compile::Examples::OverlappingFiles - -import IO; -import util::FileSystem; -import Relation; -import String; -import Set; - -str asBaseFileName(loc l){ - path = l.path; - n = findLast(path, "/"); - return n >= 0 ? path[n+1 ..] : path; -} - -rel[str, str] getFiles(loc dir){ - dirPath = dir.path; - ndirPath = size(dirPath); - return { | loc f <- find(dir, bool (loc l) { return !isDirectory(l); }) }; -} - -void main(){ - rascalDir = |file:///Users/paulklint/git/rascal/src/|; - rascalCoreDir = |file:///Users/paulklint/git/rascal-core/src/|; - typepalDir = |file:///Users/paulklint/git/typepal/src|; - - srcDir = rascalCoreDir; - rascalFiles = getFiles(rascalDir); - srcFiles = getFiles(srcDir); - - identical = range(rascalFiles) & range(srcFiles); - println(" identical files:"); - iprintln(identical); - - // These files have the same name but cannot clash when merged - approved = {"AST.rsc", "TestGrammars.rsc", "Characters.rsc", "CharactersTests.rsc", "Names.rsc", "Keywords.rsc", - "Layout.rsc", "LayoutTests.rsc", "LiteralsTests.rsc", "Symbols.rsc", "Literals.rsc", - "Attributes.rsc", "Tests.rsc", "ModuleInfo.rsc", "Names.java"}; - sameName = domain(rascalFiles) & domain(srcFiles) - approved; - - println(" files with same name:"); - for(c <- sameName){ - println(": - ' <}>"); - - } -} - -// Recent run: -// 0 identical files: -// {} -// 11 files with same name: -// JavaCompilerException.java: -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/utils/JavaCompilerException.java -// org/rascalmpl/interpreter/utils/JavaCompilerException.java -// Fingerprint.java: -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/Fingerprint.java -// org/rascalmpl/library/lang/rascal/matching/internal/Fingerprint.java -// JavaCompiler.java: -// org/rascalmpl/interpreter/utils/JavaCompiler.java -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/utils/JavaCompiler.java -// A.rsc: -// org/rascalmpl/library/lang/rascal/tests/extends3/A.rsc -// org/rascalmpl/library/lang/rascal/tests/functionality/CommonKeywordParameterImport3/A.rsc -// org/rascalmpl/library/lang/rascal/tests/functionality/CommonKeywordParameter4/A.rsc -// org/rascalmpl/core/library/lang/rascalcore/compile/Examples/A.rsc -// B.rsc: -// org/rascalmpl/library/lang/rascal/tests/extends3/B.rsc -// org/rascalmpl/library/lang/rascal/tests/functionality/CommonKeywordParameterImport3/B.rsc -// org/rascalmpl/library/lang/rascal/tests/functionality/CommonKeywordParameter4/B.rsc -// org/rascalmpl/core/library/lang/rascalcore/compile/Examples/B.rsc -// Fingerprint.rsc: -// org/rascalmpl/core/library/lang/rascalcore/check/Fingerprint.rsc -// org/rascalmpl/library/lang/rascal/matching/Fingerprint.rsc -// ConcreteSyntax.rsc: -// org/rascalmpl/library/lang/rascal/syntax/tests/ConcreteSyntax.rsc -// org/rascalmpl/library/lang/rascal/grammar/ConcreteSyntax.rsc -// org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/ConcreteSyntax.rsc -// RascalFunctionActionExecutor.java: -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/RascalFunctionActionExecutor.java -// org/rascalmpl/parser/uptr/action/RascalFunctionActionExecutor.java -// JavaBridge.java: -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/utils/JavaBridge.java -// org/rascalmpl/interpreter/utils/JavaBridge.java -// SubSetGenerator.java: -// org/rascalmpl/interpreter/matching/SubSetGenerator.java -// org/rascalmpl/core/library/lang/rascalcore/compile/runtime/utils/SubSetGenerator.java -// .DS_Store: -// org/rascalmpl/.DS_Store -// org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/.DS_Store -// org/rascalmpl/library/.DS_Store -// org/.DS_Store -// org/rascalmpl/core/library/lang/rascalcore/compile/.DS_Store -// org/rascalmpl/library/lang/rascal/grammar/tests/.DS_Store -// .DS_Store \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst.rpage b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst.rpage deleted file mode 100644 index 12b8a9c3815..00000000000 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst.rpage +++ /dev/null @@ -1,7 +0,0 @@ -1 + 2; ⇨ int: 3 - -// xxxx - -x + 2; -⚠ Undeclared variable: x -⚠ Advice: |http://tutor.rascal-mpl.org/Errors/Static/UndeclaredVariable/UndeclaredVariable.html| diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst0.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst0.rsc index 7dfe08f1f04..9c55eaac18b 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst0.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst0.rsc @@ -25,7 +25,18 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } module lang::rascalcore::compile::Examples::Tst0 - -import lang::rascalcore::check::Checker; - -value main() = 42; \ No newline at end of file + +import ParseTree; +import String; +import IO; +import util::Reflective; +import Grammar; + +value main() { + GEMPTY0 = grammar({sort("S")}, ()); + s = sort("S"); + GEMPTY1 = grammar({s}, ()); + println("GEMPTY0, , , "); + println("GEMPTY1, , , "); + return -1; +} \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst1.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst1.rsc index 4ccc2d94a32..ca37933cc6d 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst1.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst1.rsc @@ -25,22 +25,96 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } module lang::rascalcore::compile::Examples::Tst1 +import lang::rascalcore::check::Checker; +import util::FileSystem; +import util::PathConfig; +import IO; +import Message; -/* - Perform a path analysis on the Rascal source code of a function. - On the fly it will report dead code. -*/ +private void runChecker(PathConfig pcfg, bool (loc m) validModule) { + result = check([m | src <- pcfg.srcs, m <- find(src, "rsc"), validModule(m)], rascalCompilerConfig(pcfg)); + for (/e:error(_,_) := result) { + println(e); + } +} + +private void runChecker(PathConfig pcfg, list[str] mnames) { + result = checkModules(mnames, rascalCompilerConfig(pcfg)); + for (/e:error(_,_) := result) { + println(e); + } +} -extend lang::rascalcore::check::CheckerCommon; - -import lang::rascal::\syntax::Rascal; +void main(loc repoRoot = |file:///Users/paulklint/git/|, loc tplRoot = |file:///Users/paulklint/rascal-tpls|) { + + println("**** Checking rascal-lib"); + rascalLibPcfg = + pathConfig(srcs = [repoRoot + "rascal/src/org/rascalmpl/library"], + bin = tplRoot + "rascal-lib"); + runChecker(rascalLibPcfg, bool (loc m) { return true; }); -// import String; + println("**** Checking typepal"); + typepalPcfg = + pathConfig(srcs = [repoRoot + "typepal/src/"], + bin = tplRoot + "typepal", + libs = [rascalLibPcfg.bin]); + runChecker(typepalPcfg, bool (loc m) { return true; }); -/********************************************************************/ -/* Return path analysis */ -/********************************************************************/ + println("**** Checking rascalAll"); + rascalAllPcfg = + pathConfig(srcs = [repoRoot + "rascal/src/org/rascalmpl/compiler", + repoRoot + "rascal/tutor/"], + bin = tplRoot + "rascal-all", + libs = [typepalPcfg.bin, rascalLibPcfg.bin]); + + runChecker(rascalAllPcfg, bool (loc m) { return true; }); + println("**** Checking lsp"); + LSP_REPO = repoRoot + "rascal-language-servers/rascal-lsp"; + lspPcfg = + pathConfig(srcs = [LSP_REPO + "src/main/rascal/library", + LSP_REPO + "src/main/rascal/lsp", + LSP_REPO + "src/test/rascal"], + bin = tplRoot + "lsp", + libs = [typepalPcfg.bin, rascalLibPcfg.bin, rascalAllPcfg.bin]); -bool returnsViaAllPath((Statement) `