diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileChanges/last-build.bin b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileChanges/last-build.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileContent/fileContent.lock b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileContent/fileContent.lock new file mode 100644 index 0000000..15ff428 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileContent/fileContent.lock differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.bin b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.bin new file mode 100644 index 0000000..81c741c Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.lock b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.lock new file mode 100644 index 0000000..f3bd09f Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.lock differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/gc.properties b/anno2/Sem2/lft/progetto/.gradle/4.10.3/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/classAnalysis.bin b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/classAnalysis.bin new file mode 100644 index 0000000..a658742 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/classAnalysis.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/javaCompile.lock b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/javaCompile.lock new file mode 100644 index 0000000..256e80a Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/javaCompile.lock differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/taskHistory.bin b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/taskHistory.bin new file mode 100644 index 0000000..a936d82 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/javaCompile/taskHistory.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.bin b/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.bin new file mode 100644 index 0000000..064d7b1 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.lock b/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.lock new file mode 100644 index 0000000..3ca6e33 Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/4.10.3/taskHistory/taskHistory.lock differ diff --git a/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..ae8096d Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/cache.properties b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..6f72b57 --- /dev/null +++ b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri Jul 05 11:29:46 CEST 2019 +gradle.version=4.10.3 diff --git a/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/outputFiles.bin b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..8207dee Binary files /dev/null and b/anno2/Sem2/lft/progetto/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/anno2/Sem2/lft/progetto/.gradle/vcs-1/gc.properties b/anno2/Sem2/lft/progetto/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/anno2/Sem2/lft/progetto/.idea/compiler.xml b/anno2/Sem2/lft/progetto/.idea/compiler.xml new file mode 100644 index 0000000..f5921e9 --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/compiler.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <bytecodeTargetLevel> + <module name="lft_main" target="1.8" /> + <module name="lft_test" target="1.8" /> + </bytecodeTargetLevel> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/gradle.xml b/anno2/Sem2/lft/progetto/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/gradle.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="GradleSettings"> + <option name="linkedExternalProjectsSettings"> + <GradleProjectSettings> + <option name="distributionType" value="DEFAULT_WRAPPED" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="modules"> + <set> + <option value="$PROJECT_DIR$" /> + </set> + </option> + </GradleProjectSettings> + </option> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__junit_junit_4_12.xml b/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__junit_junit_4_12.xml new file mode 100644 index 0000000..04c10dd --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -0,0 +1,11 @@ +<component name="libraryTable"> + <library name="Gradle: junit:junit:4.12"> + <CLASSES> + <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa/junit-4.12-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..8262f72 --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ +<component name="libraryTable"> + <library name="Gradle: org.hamcrest:hamcrest-core:1.3"> + <CLASSES> + <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b/hamcrest-core-1.3-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/misc.xml b/anno2/Sem2/lft/progetto/.idea/misc.xml new file mode 100644 index 0000000..c7d45f6 --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/misc.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/build/classes" /> + </component> + <component name="ProjectType"> + <option name="id" value="Android" /> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/modules.xml b/anno2/Sem2/lft/progetto/.idea/modules.xml new file mode 100644 index 0000000..6027f4f --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/modules.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/lft.iml" filepath="$PROJECT_DIR$/lft.iml" group="lft" /> + <module fileurl="file://$PROJECT_DIR$/.idea/modules/lft_main.iml" filepath="$PROJECT_DIR$/.idea/modules/lft_main.iml" group="lft" /> + <module fileurl="file://$PROJECT_DIR$/.idea/modules/lft_test.iml" filepath="$PROJECT_DIR$/.idea/modules/lft_test.iml" group="lft" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/modules/lft_main.iml b/anno2/Sem2/lft/progetto/.idea/modules/lft_main.iml new file mode 100644 index 0000000..bc20592 --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/modules/lft_main.iml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module external.linked.project.id="lft:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="lft" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> + <output url="file://$MODULE_DIR$/../../build/classes/java/main" /> + <exclude-output /> + <content url="file://$MODULE_DIR$/../../src/main"> + <sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/modules/lft_test.iml b/anno2/Sem2/lft/progetto/.idea/modules/lft_test.iml new file mode 100644 index 0000000..987713d --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/modules/lft_test.iml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module external.linked.project.id="lft:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="lft" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> + <output-test url="file://$MODULE_DIR$/../../build/classes/java/test" /> + <exclude-output /> + <content url="file://$MODULE_DIR$/../../src/test"> + <sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="lft_main" /> + <orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" /> + <orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" /> + </component> + <component name="TestModuleProperties" production-module="lft_main" /> +</module> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/vcs.xml b/anno2/Sem2/lft/progetto/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/.idea/workspace.xml b/anno2/Sem2/lft/progetto/.idea/workspace.xml new file mode 100644 index 0000000..e9d62dc --- /dev/null +++ b/anno2/Sem2/lft/progetto/.idea/workspace.xml @@ -0,0 +1,465 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="33d5db20-82eb-4430-8abe-9b85f32741c4" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/fileHashes/fileHashes.bin" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/fileHashes/fileHashes.lock" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/javaCompile/classAnalysis.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/javaCompile/classAnalysis.bin" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/javaCompile/javaCompile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/javaCompile/javaCompile.lock" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/taskHistory/taskHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/taskHistory/taskHistory.bin" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/4.10.3/taskHistory/taskHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.10.3/taskHistory/taskHistory.lock" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/lft.iml" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/modules/lft.main.iml" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/modules/lft.test.iml" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/uiDesigner.xml" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/build/classes/java/main/lft/es2_1/Lexer.class" beforeDir="false" afterPath="$PROJECT_DIR$/build/classes/java/main/lft/es2_1/Lexer.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/build/classes/java/main/lft/es5/CodeGenerator.class" beforeDir="false" afterPath="$PROJECT_DIR$/build/classes/java/main/lft/es5/CodeGenerator.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/build/classes/java/main/lft/es5/Translator.class" beforeDir="false" afterPath="$PROJECT_DIR$/build/classes/java/main/lft/es5/Translator.class" afterDir="false" /> + </list> + <ignored path="$PROJECT_DIR$/.gradle/" /> + <ignored path="$PROJECT_DIR$/build/" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="DefaultGradleProjectSettings"> + <option name="isMigrated" value="true" /> + </component> + <component name="ExternalProjectsData"> + <projectState path="$PROJECT_DIR$"> + <ProjectState /> + </projectState> + </component> + <component name="ExternalProjectsManager"> + <system id="GRADLE"> + <state> + <projects_view /> + </state> + </system> + </component> + <component name="FileEditorManager"> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es5/Translator.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="557"> + <caret line="256" column="34" selection-start-line="256" selection-start-column="34" selection-end-line="256" selection-end-column="34" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es5/CodeGenerator.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="306"> + <caret line="24" selection-start-line="24" selection-end-line="24" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es2_1/Lexer.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="4014"> + <caret line="228" column="16" selection-start-line="228" selection-start-column="16" selection-end-line="228" selection-end-column="16" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es3/Parser2.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="162"> + <caret line="12" column="8" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es3/Parser.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="324"> + <caret line="21" column="14" selection-start-line="21" selection-start-column="14" selection-end-line="21" selection-end-column="14" /> + <folding> + <element signature="e#405#406#0" expanded="true" /> + <element signature="e#463#464#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="Class" /> + </list> + </option> + </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/src/main/java/lft/es2_1/invalidSymbol.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/es2_1/erroneousCharacter.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/lftError/LftError.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/es5/unknownVariableException.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/es2_1/Lexer.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/es5/CodeGenerator.java" /> + <option value="$PROJECT_DIR$/src/main/java/lft/es5/Translator.java" /> + </list> + </option> + </component> + <component name="ProjectFrameBounds" extendedState="6"> + <option name="x" value="1920" /> + <option name="width" value="946" /> + <option name="height" value="1062" /> + </component> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="Scope" /> + <pane id="PackagesPane" /> + <pane id="ProjectPane"> + <subPane> + <expand> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + <item name="lft" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + <item name="lft" type="462c0819:PsiDirectoryNode" /> + <item name="es2_1" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + <item name="lft" type="462c0819:PsiDirectoryNode" /> + <item name="es3" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + <item name="lft" type="462c0819:PsiDirectoryNode" /> + <item name="es4" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="lft" type="b2602c69:ProjectViewProjectNode" /> + <item name="lft" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + <item name="lft" type="462c0819:PsiDirectoryNode" /> + <item name="es5" type="462c0819:PsiDirectoryNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> + <property name="project.structure.last.edited" value="Project" /> + <property name="project.structure.proportion" value="0.0" /> + <property name="project.structure.side.proportion" value="0.0" /> + <property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.gradle" /> + </component> + <component name="RecentsManager"> + <key name="CreateClassDialog.RecentsKey"> + <recent name="lft.lftError" /> + <recent name="lft.es2_1" /> + </key> + </component> + <component name="RunDashboard"> + <option name="ruleStates"> + <list> + <RuleState> + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> + </RuleState> + <RuleState> + <option name="name" value="StatusDashboardGroupingRule" /> + </RuleState> + </list> + </option> + </component> + <component name="RunManager"> + <configuration name="Translator" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="lft.es5.Translator" /> + <module name="lft_main" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="lft.es5.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <recent_temporary> + <list> + <item itemvalue="Application.Translator" /> + </list> + </recent_temporary> + </component> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="33d5db20-82eb-4430-8abe-9b85f32741c4" name="Default Changelist" comment="" /> + <created>1562751113122</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1562751113122</updated> + </task> + <servers /> + </component> + <component name="ToolWindowManager"> + <frame x="1920" y="0" width="1920" height="1062" extended-state="6" /> + <layout> + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2571885" /> + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> + <window_info id="Build Variants" order="2" side_tool="true" /> + <window_info id="Image Layers" order="3" /> + <window_info id="Designer" order="4" /> + <window_info id="Capture Tool" order="5" /> + <window_info id="UI Designer" order="6" /> + <window_info id="Favorites" order="7" side_tool="true" /> + <window_info anchor="bottom" id="Message" order="0" /> + <window_info anchor="bottom" id="Find" order="1" /> + <window_info anchor="bottom" id="Run" order="2" weight="0.32954547" /> + <window_info anchor="bottom" id="Debug" order="3" weight="0.39988938" /> + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> + <window_info anchor="bottom" id="TODO" order="6" /> + <window_info anchor="bottom" id="Version Control" order="7" /> + <window_info anchor="bottom" id="Terminal" order="8" /> + <window_info anchor="bottom" id="Event Log" order="9" side_tool="true" /> + <window_info anchor="bottom" id="Build" order="10" weight="0.32964602" /> + <window_info anchor="bottom" id="Messages" order="11" /> + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> + <window_info anchor="right" id="Maven" order="3" /> + <window_info anchor="right" id="Gradle" order="4" /> + <window_info anchor="right" id="Theme Preview" order="5" /> + <window_info anchor="right" id="Palette" order="6" /> + <window_info anchor="right" id="Capture Analysis" order="7" /> + <window_info anchor="right" id="Palette	" order="8" /> + <window_info anchor="right" id="Coverage" order="9" side_tool="true" weight="0.32947975" /> + </layout> + </component> + <component name="com.intellij.coverage.CoverageDataManagerImpl"> + <SUITE FILE_PATH="coverage/lft$Translator.ic" NAME="Translator Coverage Results" MODIFIED="1562752284685" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false"> + <FILTER>lft.es5.*</FILTER> + </SUITE> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es5/unknownVariableException.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="108"> + <caret line="6" column="11" selection-start-line="6" selection-start-column="11" selection-end-line="6" selection-end-column="11" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/lftError/LftError.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="108"> + <caret line="6" column="4" selection-start-line="6" selection-start-column="4" selection-end-line="6" selection-end-column="4" /> + <folding> + <element signature="e#172#173#0" expanded="true" /> + <element signature="e#222#223#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es2_1/invalidSymbol.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="144"> + <caret line="8" column="8" selection-start-line="8" selection-start-column="8" selection-end-line="8" selection-end-column="8" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es2_1/erroneousCharacter.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="108"> + <caret line="6" column="15" selection-start-line="6" selection-start-column="15" selection-end-line="6" selection-end-column="15" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es4/Translator.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="72"> + <caret line="10" column="13" selection-start-line="10" selection-start-column="13" selection-end-line="10" selection-end-column="13" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es5/Translator.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="557"> + <caret line="256" column="34" selection-start-line="256" selection-start-column="34" selection-end-line="256" selection-end-column="34" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es5/CodeGenerator.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="306"> + <caret line="24" selection-start-line="24" selection-end-line="24" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es2_1/Lexer.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="4014"> + <caret line="228" column="16" selection-start-line="228" selection-start-column="16" selection-end-line="228" selection-end-column="16" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es3/Parser2.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="162"> + <caret line="12" column="8" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/lft/es3/Parser.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="324"> + <caret line="21" column="14" selection-start-line="21" selection-start-column="14" selection-end-line="21" selection-end-column="14" /> + <folding> + <element signature="e#405#406#0" expanded="true" /> + <element signature="e#463#464#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </component> + <component name="masterDetails"> + <states> + <state key="ArtifactsStructureConfigurable.UI"> + <settings> + <artifact-editor /> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="FacetStructureConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="GlobalLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="JdkListConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ModuleStructureConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + </states> + </component> +</project> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/build.gradle b/anno2/Sem2/lft/progetto/build.gradle new file mode 100644 index 0000000..9c8cba5 --- /dev/null +++ b/anno2/Sem2/lft/progetto/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java' +} + +group 'lft' +version '1.0-SNAPSHOT' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1$1.class new file mode 100644 index 0000000..f65a866 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1.class new file mode 100644 index 0000000..1f1e9c4 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_1/es1_1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_10/es1_10.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_10/es1_10.class new file mode 100644 index 0000000..d3b79e6 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_10/es1_10.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_11/es1_11.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_11/es1_11.class new file mode 100644 index 0000000..63abb7b Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_11/es1_11.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2$1.class new file mode 100644 index 0000000..a3ade23 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2.class new file mode 100644 index 0000000..ba7f4a7 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_2/es1_2.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_3/es1_3.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_3/es1_3.class new file mode 100644 index 0000000..504c51b Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_3/es1_3.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_4/es1_4.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_4/es1_4.class new file mode 100644 index 0000000..ecc2ed9 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_4/es1_4.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_5/es1_5.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_5/es1_5.class new file mode 100644 index 0000000..a5b71fc Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_5/es1_5.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6$1.class new file mode 100644 index 0000000..2c378a0 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6.class new file mode 100644 index 0000000..ed46122 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_6/es1_6.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7$1.class new file mode 100644 index 0000000..7039d66 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7.class new file mode 100644 index 0000000..b23a709 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_7/es1_7.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8$1.class new file mode 100644 index 0000000..1aaea01 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8.class new file mode 100644 index 0000000..1daef4e Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_8/es1_8.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9$1.class new file mode 100644 index 0000000..0e8f6f7 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9.class new file mode 100644 index 0000000..4771ed1 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es1_9/es1_9.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Lexer.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Lexer.class new file mode 100644 index 0000000..05daffc Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Lexer.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/NumberTok.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/NumberTok.class new file mode 100644 index 0000000..aaa8bf9 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/NumberTok.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Tag.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Tag.class new file mode 100644 index 0000000..927fca7 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Tag.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Token.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Token.class new file mode 100644 index 0000000..01e5211 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Token.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Word.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Word.class new file mode 100644 index 0000000..6030c64 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/Word.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/erroneousCharacter.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/erroneousCharacter.class new file mode 100644 index 0000000..7adb709 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/erroneousCharacter.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/invalidSymbol.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/invalidSymbol.class new file mode 100644 index 0000000..281bde6 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es2_1/invalidSymbol.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser.class new file mode 100644 index 0000000..6a86dd3 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser2.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser2.class new file mode 100644 index 0000000..aa1f252 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es3/Parser2.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es4/Translator.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es4/Translator.class new file mode 100644 index 0000000..a016377 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es4/Translator.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/CodeGenerator.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/CodeGenerator.class new file mode 100644 index 0000000..f7de11b Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/CodeGenerator.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction$1.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction$1.class new file mode 100644 index 0000000..2e752df Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction$1.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction.class new file mode 100644 index 0000000..c8765b0 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Instruction.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/OpCode.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/OpCode.class new file mode 100644 index 0000000..9a6bb75 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/OpCode.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/SymbolTable.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/SymbolTable.class new file mode 100644 index 0000000..6993c8e Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/SymbolTable.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Translator.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Translator.class new file mode 100644 index 0000000..7188c44 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/Translator.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/unknownVariableException.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/unknownVariableException.class new file mode 100644 index 0000000..11b1597 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/es5/unknownVariableException.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/lftError/LftError.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/lftError/LftError.class new file mode 100644 index 0000000..2a6b710 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/lftError/LftError.class differ diff --git a/anno2/Sem2/lft/progetto/build/classes/java/main/lft/trezeri/TreZeri.class b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/trezeri/TreZeri.class new file mode 100644 index 0000000..1949e96 Binary files /dev/null and b/anno2/Sem2/lft/progetto/build/classes/java/main/lft/trezeri/TreZeri.class differ diff --git a/anno2/Sem2/lft/progetto/es2.program b/anno2/Sem2/lft/progetto/es2.program new file mode 100644 index 0000000..1dcd05c --- /dev/null +++ b/anno2/Sem2/lft/progetto/es2.program @@ -0,0 +1,21 @@ +d:=300; + + +y:= 2 + 2 - 8 * 7 / 1; +while (d < 1000) do + x:= 10; + y := 30; + d := x * y + d; + print(d*2); + print (d*2; + print ( d *2 ) ; + print (d * 2 ) ; + ;;;; + a := { 1; 2 ; 3 ;4}; + d := read (); + d := read( ) ; + /*** comment */ + ///////// comment + /* ;; ; // */ +when (2 * 2 > 0 && d < 10 || 9 / 3 && !a) then y:=2 else + y:=25 ; \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/es3_1.program b/anno2/Sem2/lft/progetto/es3_1.program new file mode 100644 index 0000000..be8a33f --- /dev/null +++ b/anno2/Sem2/lft/progetto/es3_1.program @@ -0,0 +1,5 @@ +2+2 * 8 + (45 + 2) - + +4 + 4 ++ 6 + / 2 + (5 / 5 + 1) \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/es3_2.program b/anno2/Sem2/lft/progetto/es3_2.program new file mode 100644 index 0000000..b048333 --- /dev/null +++ b/anno2/Sem2/lft/progetto/es3_2.program @@ -0,0 +1,21 @@ +d:=300; + +{ + y:= 2 + 2 - 8 * 7 / 1; + while (d < 1000) + x:= 10; + y := 30; + d := x * y + d; + print(d*2); + print (d*2); + print ( d *2 ) ; + print (d * 2 ) ; + read(d) ; + /*** comment */ + ///////// comment + /* ;; ; // */ + case when (2 > 0) y:=2 else + { y:=25 }; + case when (2 > 0) print(y) else + { print(x) } +} \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/es5.program b/anno2/Sem2/lft/progetto/es5.program new file mode 100644 index 0000000..bd00280 --- /dev/null +++ b/anno2/Sem2/lft/progetto/es5.program @@ -0,0 +1,14 @@ +/*while(x<>2) + x := x + 1; + +while(x>2){ + print(x); + print(x); + read(x) + }; + */ + +x := 49 ; y := 21 ; while (x <> y) +case when (x < y) y := y - x +when (x > 2) print(y) +else x := x - y \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.jar b/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..94336fc Binary files /dev/null and b/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.jar differ diff --git a/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.properties b/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..290541c --- /dev/null +++ b/anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/anno2/Sem2/lft/progetto/gradlew b/anno2/Sem2/lft/progetto/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/anno2/Sem2/lft/progetto/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/anno2/Sem2/lft/progetto/gradlew.bat b/anno2/Sem2/lft/progetto/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/anno2/Sem2/lft/progetto/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/anno2/Sem2/lft/progetto/lft.iml b/anno2/Sem2/lft/progetto/lft.iml new file mode 100644 index 0000000..2bd3d4e --- /dev/null +++ b/anno2/Sem2/lft/progetto/lft.iml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module external.linked.project.id="lft" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="lft" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/.gradle" /> + <excludeFolder url="file://$MODULE_DIR$/build" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/programs/1.program b/anno2/Sem2/lft/progetto/programs/1.program new file mode 100644 index 0000000..73f595f --- /dev/null +++ b/anno2/Sem2/lft/progetto/programs/1.program @@ -0,0 +1,4 @@ +max := a; +case when(b>max) max := b + when(c>max) max := c + else max:=a+b+c; \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/programs/2.program b/anno2/Sem2/lft/progetto/programs/2.program new file mode 100644 index 0000000..f3ff433 --- /dev/null +++ b/anno2/Sem2/lft/progetto/programs/2.program @@ -0,0 +1,13 @@ +while (1>0){ +read(a); +read(b); +read(c); +case when (a>b) + print (a) + when(b>c) + print(b) + when(c>a) + print(c) + else + print(a) + } \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/programs/Output.class b/anno2/Sem2/lft/progetto/programs/Output.class new file mode 100644 index 0000000..c791d94 Binary files /dev/null and b/anno2/Sem2/lft/progetto/programs/Output.class differ diff --git a/anno2/Sem2/lft/progetto/programs/fib.program b/anno2/Sem2/lft/progetto/programs/fib.program new file mode 100644 index 0000000..1b5e9d1 --- /dev/null +++ b/anno2/Sem2/lft/progetto/programs/fib.program @@ -0,0 +1,16 @@ +read(max); +a:=0; +b:=1; +while(a<max){ + print(a); + c :=a; + a := a+b; + b:=c +}; +print(a) + + + + + + diff --git a/anno2/Sem2/lft/progetto/programs/jasmin.jar b/anno2/Sem2/lft/progetto/programs/jasmin.jar new file mode 100644 index 0000000..7897e7f Binary files /dev/null and b/anno2/Sem2/lft/progetto/programs/jasmin.jar differ diff --git a/anno2/Sem2/lft/progetto/programs/unknownVariable.program b/anno2/Sem2/lft/progetto/programs/unknownVariable.program new file mode 100644 index 0000000..be0bd9c --- /dev/null +++ b/anno2/Sem2/lft/progetto/programs/unknownVariable.program @@ -0,0 +1,4 @@ +read(a); +read(b); +print(a); +print(c) \ No newline at end of file diff --git a/anno2/Sem2/lft/progetto/settings.gradle b/anno2/Sem2/lft/progetto/settings.gradle new file mode 100644 index 0000000..46f6331 --- /dev/null +++ b/anno2/Sem2/lft/progetto/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'lft' + diff --git a/anno2/Sem2/lft/progetto/settings.zip b/anno2/Sem2/lft/progetto/settings.zip new file mode 100644 index 0000000..4f05acc Binary files /dev/null and b/anno2/Sem2/lft/progetto/settings.zip differ diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_1/es1_1.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_1/es1_1.java new file mode 100644 index 0000000..b23307a --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_1/es1_1.java @@ -0,0 +1,138 @@ +package lft.es1_1; +import java.util.HashMap; + +import lft.trezeri.TreZeri; + +public class es1_1 { + static String nope="Nope"; + static String ok = "Ok"; + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("320010331413433240" , nope); + put("22", nope); + put("10242333101004114022", nope); + put("04342322103",nope); + put("41030010", nope); + put("243142031320410",nope); + put("13121224233133011322",nope); + put("41204331422040332",nope); + put("333230",nope); + put("1003012214313",nope); + put("3343341441140002330",nope); + put("31104400",nope); + put("444234123233414434",nope); + put("2140041",nope); + put("342443",nope); + put("44324100313041",nope); + put("40340240333014040430",nope); + put("41133240",nope); + put("23424",nope); + put("00000000",ok); + put("1110",nope); + put("01101010010111011011",nope); + put("00111101000",ok); + put("10010001",ok); + put("00",nope); + put("000101111110010001",ok); + put("111000000",ok); + put("100010100111110",ok); + put("00100111",nope); + put("1",nope); + put("010110110110110011",nope); + put("1001000111000100",ok); + put("10000101110100",ok); + put("0111110111110110011",nope); + put("1000110011110100",ok); + put("1000100",ok); + put("1100010010000",ok); + put("001100101101",nope); + put("010011000000111010",ok); + put("0010111",nope); + put("20010101220112",nope); + put("0012021200",nope); + put("101",nope); + put("012112",nope); + put("20220201211022222111",nope); + put("1020212020222120101",nope); + put("0010",nope); + put("11022011221201102",nope); + put("01201212111021220022",nope); + put("22011220020",nope); + put("122110002002",nope); + put("00000110212122122112",nope); + put("22011112101",nope); + put("00200212122001100",nope); + put("0110211212122121",nope); + put("1201001011200220",nope); + put("2",nope); + put("002221201111",nope); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = TreZeri.scan(key); + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } + } + + public static void testComplementare() + { + HashMap<String, String> testComplementare = new HashMap<String, String>(); + for(String key: tests.keySet()){ + if(key.contains("2") || key.contains("3") || key.contains("4")) + testComplementare.put(key, nope); + else + testComplementare.put(key, tests.get(key) == nope? ok:nope); // inverse result + } + for(String key: testComplementare.keySet()) { + boolean result = scanComplementare(key); + System.out.println("Test Complementare: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + testComplementare.get(key)); + } + } + + public static boolean scanComplementare(String s) { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == '0') + state = 1; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 1: + if (ch == '0') + state = 2; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 2: + if (ch == '0') + state = 3; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 3: + if (ch == '0' || ch == '1') + state = 3; + else + state = -1; + break; + } + } + return state < 3 && state != -1; + } + + public static void main(String[] args){ + test(); + testComplementare(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_10/es1_10.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_10/es1_10.java new file mode 100644 index 0000000..279f05f --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_10/es1_10.java @@ -0,0 +1,72 @@ +package lft.es1_10; + + +public class es1_10 { + + public static boolean scan(String parola) { + int state = 0; + int i = 0; + while (state >= 0 && i < parola.length()) { + final char ch = parola.charAt(i++); + switch (state) { + case 0: + if(ch == '/') + state = 1; + else + state = -1; + break; + case 1: + if(ch == '*') + state = 2; + else + state = -1; + break; + case 2: + if(ch == '*') + state = 3; + else if(ch == 'a' || ch == '/') + state = 2; + else + state = -1; + break; + case 3: + if(ch == '/') + state = 4; + else if (ch == 'a') + state = 2; + else if(ch == '*') + state = 3; + else + state = -1; + break; + case 4: // accettante + if (ch == '/') + state = 1; + else + state = -1; + break; + } + } + + return state == 4; + } + + public static String[] test = new String[] { "/*//*/", "/****/", "/*a*a*/", "/*a/**/", "/**a///a/a**/", "/**/" , "/*/*/", + "/**/***/", + "/**//**/", + "/*/", "aaa", "a/**/a", "b"}; // sbagliata + + public static void main(String[] args) + { + String parole[] = test; + //String[] parole = new String[] /"/**/", "aaa/****/aa", "aa/*a*a*/", "aaaa", "/****/", "/*aa*/", "*/aa/**/***a", +//"a/**/***/a" , "a/**/aa/***/a",}; + + for(String parola: parole){ + System.out.print(parola + ": "); + System.out.println(scan(parola) ? "OK" : "NOPE"); + } + } + +} + diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_11/es1_11.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_11/es1_11.java new file mode 100644 index 0000000..b056ad3 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_11/es1_11.java @@ -0,0 +1,84 @@ +package lft.es1_11; + +import java.util.LinkedList; + +import static lft.es1_10.es1_10.test; + +public class es1_11 { + + public static boolean scan(String parola) { + int state = 0; + int i = 0; + while (state >= 0 && i < parola.length()) { + final char ch = parola.charAt(i++); + switch (state) { + case 0: // accettante + if(ch == '/') + state = 1; + else if(ch == 'a' || ch == '*') + state = 0; + else + state = -1; + break; + case 1: + if(ch == '*') + state = 2; + else if(ch == '/' || ch == 'a') + state = 0; + else + state = -1; + break; + case 2: + if(ch == '*') + state = 3; + else if(ch == 'a' || ch == '/') + state = 2; + else + state = -1; + break; + case 3: + if(ch == '/') + state = 4; + else if (ch == 'a') + state = 2; + else if(ch == '*') + state = 3; + else + state = -1; + break; + case 4: // accettante + if (ch == '/') + state = 1; + else if (ch == 'a') + state = 0; + else + state = -1; + break; + } + } + + return state == 4 || state == 0 || state == 1; + } + + + public static void main(String[] args) + { + LinkedList<String> parole = new LinkedList<String>(); + String[] nuove = new String[]{"/*//*/", "/**//**/", "a/**/***a", "/*****//******/", "/*******/****/", + "***", "///", "aaa", "aaa/****/aa", "aa/*a*a*a*/", "/******/", "*/a", + "a/**/***a", "a/**/***/a", "a/**/aa/***/a", + "aaa/*aa", "aa/*aa"}; + for(String n:nuove) + parole.add(n); + for(String n: test) + parole.add(n); + + for(String parola: parole){ + System.out.print(parola + ": "); + System.out.println(scan(parola) ? "OK" : "NOPE"); + } + } + +} + + diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_2/es1_2.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_2/es1_2.java new file mode 100644 index 0000000..d168004 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_2/es1_2.java @@ -0,0 +1,73 @@ +package lft.es1_2; + +import java.util.HashMap; + +public class es1_2 +{ + static String nope="Nope"; + static String ok = "Ok"; + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("ciao" , ok); + put("0ciao", nope); + put("_under", ok); + put("___",nope); + put("HEXdump", ok); + put("&&HEXDUMP",nope); + put("JAVAISVERBOSE",nope); + put("lab-1.2", nope); + put("133t",nope); + put("l33t", ok); + put("camelCaseIdentifier", ok); + put("is_this_C99", ok); + put("space is the place", nope); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = scan(key); + if (tests.get(key) == (result? "Ok" : "Nope")) { + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } else { + System.out.println("\nERROR Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key) + "\n"); + + } + } + } + + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (Character.isLetter(ch)) // a-z|A-Z + state = 1; + else if (ch == '_') + state = 2; + else // 0-9 not allowed + state = -1; + break; + case 1: + if (!(Character.isLetter(ch) || Character.isDigit(ch) || ch == '_')) + state = -1; + break; + case 2: + if (Character.isLetter(ch) || Character.isDigit(ch)) + state = 1; + else if(!(ch == '_')) + state = -1; + break; + } + } + return state == 1; + } + + + public static void main(String[] args) + { + test(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_3/es1_3.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_3/es1_3.java new file mode 100644 index 0000000..fa0908a --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_3/es1_3.java @@ -0,0 +1,69 @@ +package lft.es1_3; + +public class es1_3 { + public static String lwalph = "abcdefghijklmnopqrstuvzwxy"; + public static String upalph = lwalph.toUpperCase(); + public static String digits = "0123456789"; + public static String upDueAlph = "ABCDEFGHIJK"; + public static String upTreAlph = "LMNOPQRSTUVZWXY"; + public static String evens = "02468"; + public static String evensNoZero = "2468"; + public static String odds = "13579"; + + public static boolean scan(String parola) { + + int state = 0; + int i = 0; + while (state >= 0 && i < parola.length()) { + final String ch = ""+parola.charAt(i++); + switch (state) { + case 0: + if(evensNoZero.contains(ch)) + state = 1; + else if (odds.contains(ch)) + state = 2; + else + state = -1; + break; + + case 1: + if (evens.contains(ch)) + state = 1; + else if (odds.contains(ch)) + state = 2; + else if (upDueAlph.contains(ch)) + state = 3; + else + state = -1; + break; + + case 2: + if (evens.contains(ch)) + state = 1; + else if (odds.contains(ch)) + state = 2; + else if (upTreAlph.contains(ch)) + state = 3; + else + state = -1; + break; + case 3: // accettante + if (lwalph.contains(ch)) + state = 3; + else + state = -1; + break; + } + } + return state == 3; + } + + public static void main(String[] args) + { + String[] parole = new String[] {"2M", "Mario2", "123Mario", "123456Bianchi", "0&m"}; + for(String parola: parole){ + System.out.print(parola + ": "); + System.out.println(scan(parola) ? "OK" : "NOPE"); + } + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_4/es1_4.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_4/es1_4.java new file mode 100644 index 0000000..4d34b7e --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_4/es1_4.java @@ -0,0 +1,102 @@ +package lft.es1_4; + +import static lft.es1_3.es1_3.*; + +public class es1_4 { + + private static boolean isSpace(String st){ + assert st.length() == 1; + return st.charAt(0) == ' '; + } + + public static boolean scan(String parola) { + + int state = 0; + int i = 0; + while (state >= 0 && i < parola.length()) { + final String ch = ""+parola.charAt(i++); + switch (state) { + case 0: + if(isSpace(ch)) + state = 0; + else if(evensNoZero.contains(ch)) + state = 1; + else if (odds.contains(ch)) + state = 2; + else + state = -1; + break; + + case 1: + if (evens.contains(ch)) + state = 1; + else if(isSpace(ch)) + state = 4; + else if (odds.contains(ch)) + state = 2; + else if (upDueAlph.contains(ch)) + state = 3; + else + state = -1; + break; + + case 2: + if (evens.contains(ch)) + state = 1; + else if(isSpace(ch)) + state = 5; + else if (odds.contains(ch)) + state = 2; + else if (upTreAlph.contains(ch)) + state = 3; + else + state = -1; + break; + case 3: // accettante + if(isSpace(ch)) + state = 6; + else if (lwalph.contains(ch)) + state = 3; + else + state = -1; + break; + case 4: + if(isSpace(ch)) + state = 4; + else if (upDueAlph.contains(ch)) // cognome turno due + state = 3; + else + state = -1; + break; + case 5: + if(isSpace(ch)) + state = 5; + else if (upTreAlph.contains(ch)) // cognome turno tre + state = 3; + else + state = -1; + break; + case 6: // accettante + if(isSpace(ch)) + state = 6; + else if (upalph.contains(ch)) // Seconda parte del cognome + state = 3; + else + state = -1; + } + } + return state == 3 || state == 6; + } + + public static void main(String[] args) + { + String[] parole = new String[] {"2M", "Mario2", "123Mario", "123456Bianchi", "0&m", " 654321 Rossi", "123456 Bianchi", " 123456Bianchi ", + "123456De Gasperi", " 123456 De Gasperi " }; + + for(String parola: parole){ + System.out.print(parola + ": "); + System.out.println(scan(parola) ? "OK" : "NOPE"); + } + } +} + diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_5/es1_5.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_5/es1_5.java new file mode 100644 index 0000000..784805b --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_5/es1_5.java @@ -0,0 +1,91 @@ +package lft.es1_5; + +import static lft.es1_3.es1_3.*; + +public class es1_5 { + + public static boolean scan(String parola) { + int state = 0; + int i = 0; + while (state >= 0 && i < parola.length()) { + final String ch = "" + parola.charAt(i++); + switch (state) { + case 0: + if (upDueAlph.contains(ch)) + state = 2; + else if (upTreAlph.contains(ch)) + state = 3; + else + state = -1; + break; + + case 2: + if (lwalph.contains(ch)) + state = 2; + else if (digits.contains(ch)) + state = 4; + else + state = -1; + break; + + case 3: + if (lwalph.contains(ch)) + state = 3; + else if (digits.contains(ch)) + state = 5; + else + state = -1; + break; + + case 4: + if (odds.contains(ch)) + state = 4; + else if (evens.contains(ch)) + state = 6; + else + state = -1; + break; + + case 5: + if (evens.contains(ch)) + state = 5; + else if (odds.contains(ch)) + state = 7; + else + state = -1; + break; + + case 6: // accettante + if (odds.contains(ch)) + state = 4; + else if (evens.contains(ch)) + state = 6; + else + state = -1; + break; + + case 7: // accettante + if (evens.contains(ch)) + state = 5; + else if (odds.contains(ch)) + state = 7; + else + state = -1; + break; + } + } + + return state == 6 || state == 7; + } + + public static void main(String[] args) + { + String[] parole = new String[] {"Mario123457", "Degasperi123456", "Bianchi123456","Mario123452", "Bianchi123451"}; + + for(String parola: parole){ + System.out.print(parola + ": "); + System.out.println(scan(parola) ? "OK" : "NOPE"); + } + } + +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_6/es1_6.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_6/es1_6.java new file mode 100644 index 0000000..20b64b2 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_6/es1_6.java @@ -0,0 +1,80 @@ +package lft.es1_6; + +import java.util.HashMap; + +public class es1_6 +{ + static String nope="Nope"; + static String ok = "Ok"; + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("0" , "0"); + put("11", "3"); + put("110", "6"); + put("1001", "9"); + put("1100", "12"); + put("1111", "15"); + put("10010", "18"); + put("10101", "21"); + put("11000", "24"); + put("11011", "27"); + put("11110", "30"); + put("101", "5"); + put("010", "2"); + put("0001", "1"); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = scan(key); + if (tests.get(key) == (result? "Ok" : "Nope")) { + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } else { + System.out.println("\nERROR Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key) + "\n"); + + } + } + } + + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == '1') + state = 1; + else if (ch == '0') + state = 0; + else // not allowed + state = -1; + break; + case 1: + if (ch == '1') + state = 0; + else if(ch == '0') + state = 2; + else + state = -1; + break; + case 2: + if (ch == '1') + state = 2; + else if(ch == '0') + state = 1; + else + state = -1; + break; + } + } + return state == 0; + } + + + public static void main(String[] args) + { + test(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_7/es1_7.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_7/es1_7.java new file mode 100644 index 0000000..4fca17b --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_7/es1_7.java @@ -0,0 +1,84 @@ +package lft.es1_7; + +import java.util.HashMap; + +public class es1_7 +{ + static String nope="Nope"; + static String ok = "Ok"; + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("aaab" , ok); + put("babbb", ok); + put("abbab", ok); + put("bbabb", ok); + put("bbbba", nope); + put("a", ok); + put("ba", ok); + put("abc",nope); + put("ciao", nope); + put("&&&&",nope); + put("ababa", ok); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = scan(key); + if (tests.get(key) == (result? "Ok" : "Nope")) { + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } else { + System.out.println("\nERROR Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key) + "\n"); + + } + } + } + + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == 'a') + state = 4; + else if (ch == 'b') + state = 1; + else // 0-9 not allowed + state = -1; + break; + case 1: + if (ch == 'a') + state = 4; + else if (ch == 'b') + state = 2; + else + state = -1; + break; + case 2: + if (ch == 'a') + state = 4; + else if (ch == 'b') + state = 3; + else + state = -1; + break; + case 3: + state = -1; + break; + case 4: + if (ch != 'a' && ch != 'b') + state = -1; + break; + } + } + return state == 4; + } + + + public static void main(String[] args) + { + test(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_8/es1_8.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_8/es1_8.java new file mode 100644 index 0000000..b732d56 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_8/es1_8.java @@ -0,0 +1,83 @@ +package lft.es1_8; + +import java.util.HashMap; + +public class es1_8 +{ + static String nope="Nope"; + static String ok = "Ok"; + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("abba" , ok); + put("bbba", ok); + put("aabb", ok); + put("bbab", ok); + put("babbb", nope); + put("a", ok); + put("ba", ok); + put("bba", ok); + put("ciao", nope); + put("&&&&", nope); + put("ababa", ok); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = scan(key); + if (tests.get(key) == (result? "Ok" : "Nope")) { + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } else { + System.out.println("\nERROR Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key) + "\n"); + + } + } + } + + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == 'a') + state = 0; + else if (ch == 'b') + state = 1; + else + state = -1; + break; + case 1: + if (ch == 'a') + state = 0; + else if (ch == 'b') + state = 2; + else + state = -1; + break; + case 2: + if (ch == 'a') + state = 0; + else if (ch == 'b') + state = 3; + else + state = -1; + break; + case 3: + if(ch == 'a') + state = 0; + else if (ch != 'b') + state = -1; + break; + } + } + return state != 3 && state != -1; + } + + + public static void main(String[] args) + { + test(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es1_9/es1_9.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_9/es1_9.java new file mode 100644 index 0000000..0e29390 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es1_9/es1_9.java @@ -0,0 +1,84 @@ +package lft.es1_9; + +import java.util.HashMap; + +public class es1_9 +{ + static String nope="Nope"; + static String ok = "Ok"; + + static HashMap<String, String> tests = new HashMap<String, String>() {{ + put("Fra" , ok); + put("ara", ok); + put("Fva", ok); + put("Fre", ok); + put("*ra", ok); + put("FFa", ok); + put("fra", ok); + put("Fbr", nope); + put("_r_",nope); + put("(((", nope); + put("a", nope); + }}; + + public static void test() + { + for(String key: tests.keySet()) { + boolean result = scan(key); + if (tests.get(key) == (result? "Ok" : "Nope")) { + System.out.println("Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key)); + } else { + System.out.println("\nERROR Test: " + key + ", got: " +(result? "Ok" : "Nope") + ", expected: " + tests.get(key) + "\n"); + + } + } + } + + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == 'F') + state = 1; + else + state = 3; + break; + case 1: + if (ch == 'r') + state = 2; + else + state = 4; + break; + case 2: + state = 5; + break; + + case 3: + if (ch == 'r') + state = 4; + else + state = -1; + break; + case 4: + if (ch == 'a') + state = 5; + else + state = -1; + break; + case 5: + state = -1; // string should be empty + } + } + return state == 5; + } + + + public static void main(String[] args) + { + test(); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Lexer.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Lexer.java new file mode 100644 index 0000000..000c3e1 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Lexer.java @@ -0,0 +1,234 @@ +package lft.es2_1; + +import java.io.*; +import java.util.*; +import lft.es2_1.Token; +import lft.es2_1.Word; +import lft.es2_1.Tag; +import lft.es2_1.NumberTok; + +public class Lexer { + + public static int line = 1; + public static String program = ""; + private char peek = ' '; + private void readch(BufferedReader br) { + try { + peek = (char) br.read(); + } catch (IOException exc) { + peek = (char) -1; // ERROR + } + } + + public Token lexical_scan(BufferedReader br) { + + while (peek == ' ' || peek == '\t' || peek == '\n' || peek == '\r') { + if (peek == '\n') line++; + readch(br); + } + + char current = peek; + String check; + + switch (peek) { + /** + * TOKENS + */ + case '!': + peek = ' '; + return Token.not; + case '(': + peek = ' '; + return Token.lpt; + case ')': + peek = ' '; + return Token.rpt; + case '{': + peek = ' '; + return Token.lpg; + case '}': + peek = ' '; + return Token.rpg; + case '+': + peek = ' '; + return Token.plus; + case '-': + peek = ' '; + return Token.minus; + case '*': + peek = ' '; + return Token.mult; + case '/': + readch(br); + if(peek == '/') { // single-line comments + while (peek != '\n' && peek != '\r') { + if(peek == '\n') + line++; + readch(br); + } + peek = ' '; + return lexical_scan(br); + } else if(peek == '*') { + char prev = ' '; + while(true) { + readch(br); + if(peek == '\n') + line++; + if(peek == '*') { + prev = peek; + } + if(prev == '*' && peek == '/') { + peek = ' '; + return lexical_scan(br); + } + } + } else { + peek = ' '; + return Token.div; + } + case ';': + peek = ' '; + return Token.semicolon; + + /** + * WORDS + */ + case '&': + if(checkSequence(br, "&&")) { + return Word.and; + } else return null; + case '|': + if(checkSequence(br, "||")) { + return Word.or; + } else return null; + case ':': + if(checkSequence(br, ":=")) { + return Word.assign; + } else return null; + case '=': + if(checkSequence(br, "==")) { + return Word.eq; + } else return null; + case '<': + current = peek; + readch(br); + check = "" + current + peek; + if(check.equals("<=")) { + peek = ' '; + return Word.le; + } else if(check.equals("<>")) { + peek = ' '; + return Word.ne; + } else { + return Word.lt; + } + case '>': + current = peek; + readch(br); + check = "" + current + peek; + if(check.equals(">=")) { + peek = ' '; + return Word.ge; + } else { + return Word.gt; + } + case (char)-1: + return new Token(Tag.EOF); + + default: + if (Character.isLetter(peek) || peek == '_') { + /** + * IDENTIFIERS + KEYWORDS + */ + String symbol = ""; + while(Character.isLetter(peek) || Character.isDigit(peek) || peek == '_') { + symbol = symbol + peek; + if(symbol.equals("case")) { + peek = ' '; + return Word.casetok; + } + else if(symbol.equals("when")){ + peek = ' '; + return Word.when; + } + else if(symbol.equals("then")) { + peek = ' '; + return Word.then; + } + else if(symbol.equals("else")) { + peek = ' '; + return Word.elsetok; + } + else if(symbol.equals("while")) { + peek = ' '; + return Word.whiletok; + }else if(symbol.equals("read")) { + peek = ' '; + return Word.read; + }else if(symbol.equals("print")) { + peek = ' '; + return Word.print; + } + else if(symbol.equals("do")) { + peek = ' '; + return Word.dotok; + } + readch(br); + } + + if(symbol.contains("_")){ + // check if it contains a letter after __ + Character[] s = symbol.chars().filter(x -> Character.isLetter(x)) + .mapToObj(c -> (char )c).toArray(Character[]::new); + if(s.length== 0) { + throw new invalidSymbol(program, line, symbol); + } + } + return new Word(Tag.ID, symbol); + + } else if (Character.isDigit(peek)) { + /** + * NUMBERS + */ + String symbol = ""; + while(Character.isDigit(peek)) { + symbol = symbol + peek; + readch(br); + } + return new NumberTok(Integer.parseInt(symbol)); + + } else { + throw new erroneousCharacter(program, line, peek); + } + } + } + + private boolean checkSequence(BufferedReader br, String symbols) + { + char cur; + for(char s: symbols.toCharArray()) { + cur = peek; + if (peek != s) { + throw new erroneousCharacter(program, line, peek); + } else { + readch(br); + } + } + return true; + } + + public static void main(String[] args) { + Lexer lex = new Lexer(); + String path = "./es2.program"; // il percorso del file da leggere + try { + BufferedReader br = new BufferedReader(new FileReader(path)); + Token tok; + do { + tok = lex.lexical_scan(br); + if(tok == null) break; + System.out.println("Scan: " + tok); + } while (tok.tag != Tag.EOF); + br.close(); + } catch (IOException e) {e.printStackTrace();} + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/NumberTok.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/NumberTok.java new file mode 100644 index 0000000..81f044e --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/NumberTok.java @@ -0,0 +1,7 @@ +package lft.es2_1; + +public class NumberTok extends Token { + public int num = 0; + public NumberTok(int n) { super(Tag.NUM); num = n; } + public String toString() { return "<" + tag + ", " + num + ">"; } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Tag.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Tag.java new file mode 100644 index 0000000..8091fdc --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Tag.java @@ -0,0 +1,9 @@ +package lft.es2_1; + +public class Tag { + public final static int + EOF = -1, NUM = 256, ID = 257, RELOP = 258, + CASE = 259, WHEN = 260, THEN = 261, ELSE = 262, + WHILE = 263, DO = 264, ASSIGN = 265, PRINT = 266, READ = 267, + OR = 268, AND = 269; +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Token.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Token.java new file mode 100644 index 0000000..dd1b446 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Token.java @@ -0,0 +1,18 @@ +package lft.es2_1; + +public class Token { + public final int tag; + public Token(int t) { tag = t; } + public String toString() {return "<" + tag + ">";} + public static final Token + not = new Token('!'), + lpt = new Token('('), + rpt = new Token(')'), + lpg = new Token('{'), + rpg = new Token('}'), + plus = new Token('+'), + minus = new Token('-'), + mult = new Token('*'), + div = new Token('/'), + semicolon = new Token(';'); +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Word.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Word.java new file mode 100644 index 0000000..a9146fa --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Word.java @@ -0,0 +1,25 @@ +package lft.es2_1; + +public class Word extends Token { + public String lexeme = ""; + public Word(int tag, String s) { super(tag); lexeme=s; } + public String toString() { return "<" + tag + ", " + lexeme + ">"; } + public static final Word + casetok = new Word(Tag.CASE, "case"), + when = new Word(Tag.WHEN, "when"), + then = new Word(Tag.THEN, "then"), + elsetok = new Word(Tag.ELSE, "else"), + whiletok = new Word(Tag.WHILE, "while"), + dotok = new Word(Tag.DO, "do"), + assign = new Word(Tag.ASSIGN, ":="), + print = new Word(Tag.PRINT, "print"), + read = new Word(Tag.READ, "read"), + or = new Word(Tag.OR, "||"), + and = new Word(Tag.AND, "&&"), + lt = new Word(Tag.RELOP, "<"), + gt = new Word(Tag.RELOP, ">"), + eq = new Word(Tag.RELOP, "=="), + le = new Word(Tag.RELOP, "<="), + ne = new Word(Tag.RELOP, "<>"), + ge = new Word(Tag.RELOP, ">="); +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/erroneousCharacter.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/erroneousCharacter.java new file mode 100644 index 0000000..37180d5 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/erroneousCharacter.java @@ -0,0 +1,11 @@ +package lft.es2_1; +import lft.es5.unknownVariableException; +import lft.lftError.LftError; +public class erroneousCharacter extends LftError { + public String msg; + public erroneousCharacter(String program, int line, char symbol) { + super(); + this.msg = unknownVariableException.progLine(program, line) + + "erroneous character: '" + symbol +"'"; + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/invalidSymbol.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/invalidSymbol.java new file mode 100644 index 0000000..ff6d2cc --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/invalidSymbol.java @@ -0,0 +1,12 @@ +package lft.es2_1; + +import lft.es5.unknownVariableException; +import lft.lftError.LftError; + +public class invalidSymbol extends LftError { + public invalidSymbol(String program, int line, String symbol) { + super(); + msg = unknownVariableException.progLine(program, line) + + "invalid symbol: '" + symbol +"'"; + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser.java new file mode 100644 index 0000000..ad1604e --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser.java @@ -0,0 +1,87 @@ +package lft.es3; + +import lft.es2_1.*; +import java.io.*; +import java.util.stream.IntStream; + +public class Parser { + protected Lexer lex; + protected BufferedReader pbr; + protected Token look; + public Parser(Lexer l, BufferedReader br) { + lex = l; + pbr = br; + move(); + } + + protected void move() { + look = lex.lexical_scan(pbr); + System.out.println("token = " + look); + } + protected void error(String s) { + throw new Error("near line " + lex.line + ": " + s); + } + + protected boolean match(int... t) { + boolean contains = IntStream.of(t).anyMatch(x -> x == look.tag); + if (contains) { + if (look.tag != Tag.EOF) move(); + } + return contains; + } + + protected void matchOrThrow(int... t){ + if(!(match(t))) + error("syntax error"); + } + + public void start() { + expr(); + matchOrThrow(Tag.EOF); + } + + protected void expr() { + term(); + exprp(); + } + + protected void exprp() { + if(match('-', '+')) { + term(); + exprp(); + } + } + + protected void term() { + fact(); + termp(); + } + + protected void termp() { + if(match('*', '/')) { + fact(); + termp(); + } + } + + protected void fact() { + if(match('(')) { + expr(); + matchOrThrow(')'); + } else{ + matchOrThrow(Tag.NUM); + } + } + + public static void main(String[] args) { + Lexer lex = new Lexer(); + String path = "./es3_1.program"; // il percorso del file da leggere + try { + BufferedReader br = new BufferedReader(new FileReader(path)); + Parser parser = new Parser(lex, br); + parser.start(); + System.out.println("Input OK"); + br.close(); + } catch (IOException e) {e.printStackTrace();} + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser2.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser2.java new file mode 100644 index 0000000..1c14c25 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser2.java @@ -0,0 +1,101 @@ +package lft.es3; + +import lft.es2_1.*; +import java.io.*; + +public class Parser2 extends Parser { + public Parser2(Lexer l, BufferedReader br) { + super(l, br); + } + + public void prog() { // START HERE + statlist(); + matchOrThrow(Tag.EOF); + } + + protected void statlist(){ + stat(); + statlistp(); + } + protected void statlistp(){ + if(match(';')) { + stat(); + statlistp(); + } + } + protected void stat(){ + if(match(Tag.ID)){ + matchOrThrow(Tag.ASSIGN); + expr(); + } else if(match(Tag.PRINT)){ + matchOrThrow('('); + expr(); + matchOrThrow(')'); + } else if(match(Tag.READ)){ + matchOrThrow('('); + matchOrThrow(Tag.ID); + matchOrThrow(')'); + } else if(match(Tag.CASE)){ + whenlist(); + matchOrThrow(Tag.ELSE); + stat(); + }else if(match(Tag.WHILE)){ + matchOrThrow('('); + bexpr(); + matchOrThrow(')'); + stat(); + } else if(match('{')){ + statlist(); + matchOrThrow('}'); + }else + error("syntax error"); + } + protected void whenlist(){ + whenitem(); + whenlistp(); + } + protected void whenlistp(){ + if(look.tag == Tag.ELSE) // insieme guida, follow + return; + else if(look.tag == Tag.WHEN){ // first + whenitem(); + whenlistp(); + } else + error("Syntax error"); + } + protected void whenitem(){ + matchOrThrow(Tag.WHEN); + matchOrThrow('('); + bexpr(); + matchOrThrow(')'); + stat(); + } + protected void bexpr(){ + expr(); + matchOrThrow(Tag.RELOP); + expr(); + } + + @Override + protected void fact() { + if(match('(')) { + expr(); + matchOrThrow(')'); + } else{ + matchOrThrow(Tag.NUM, Tag.ID); + } + } + + + public static void main(String[] args) { + Lexer lex = new Lexer(); + String path = "./es3_2.program"; // il percorso del file da leggere + try { + BufferedReader br = new BufferedReader(new FileReader(path)); + Parser2 parser = new Parser2(lex, br); + parser.prog(); + System.out.println("Input OK"); + br.close(); + } catch (IOException e) {e.printStackTrace();} + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es4/Translator.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es4/Translator.java new file mode 100644 index 0000000..0063587 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es4/Translator.java @@ -0,0 +1,116 @@ +package lft.es4; + +import lft.es2_1.*; +import lft.es3.Parser; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.stream.IntStream; + +public class Translator{ + protected Lexer lex; + protected BufferedReader pbr; + protected Token look; + + public Translator(Lexer l, BufferedReader br) { + lex = l; + pbr = br; + move(); + } + + protected void move() { + look = lex.lexical_scan(pbr); + System.out.println("token = " + look); + } + protected void error(String s) { + throw new Error("near line " + lex.line + ": " + s); + } + + protected boolean match(int... t) { + boolean contains = IntStream.of(t).anyMatch(x -> x == look.tag); + if (contains) { + if (look.tag != Tag.EOF) move(); + } + return contains; + } + + protected void matchOrThrow(int... t){ + if(!(match(t))) + error("syntax error"); + } + + public void start()throws Exception{ + int exprVal = expr(); + matchOrThrow(Tag.EOF); + System.out.println(exprVal); + } + + private int expr()throws Exception{ + int termVal = term(); + int exprpVal = exprp(termVal); + return exprpVal; + } + + private int exprp(int i) throws Exception { + if(match('+')) { + int termVal = term(); + int exprPVal = exprp(termVal+i); + return exprPVal; + } else if(match('-')) { + int termVal = term(); + int exprPVal = exprp(i - termVal); + return exprPVal; + } else { + return i; + } + } + + protected int term() throws Exception { + int factVal = fact(); + int termPVal = termp(factVal); + return termPVal; + } + + protected int termp(int i) throws Exception { + if(match('*')) { + int factVal = fact(); + int termPVal = termp(factVal*i); + return termPVal; + } else if(match('/')) { + int factVal = fact(); + int termPVal = termp(i/factVal); + return termPVal; + } else { + return i; + } + } + + protected int fact() throws Exception { + if(match('(')) { + int val = expr(); + matchOrThrow(')'); + return val; + } else{ + if(look instanceof NumberTok){ + NumberTok t = (NumberTok) look; + move(); + return t.num; + } else { + throw new Exception("Should have been a number token"); + } + } + } + + public static void main(String[] args) { + Lexer lex = new Lexer(); + String path = "./es3_1.program"; // il percorso del file da leggere + try { + BufferedReader br = new BufferedReader(new FileReader(path)); + Translator translator = new Translator(lex, br); + translator.start(); + System.out.println("Input OK"); + br.close(); + } catch (Exception e) {e.printStackTrace();} + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/CodeGenerator.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/CodeGenerator.java new file mode 100644 index 0000000..5accedb --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/CodeGenerator.java @@ -0,0 +1,82 @@ +package lft.es5; + +import java.util.LinkedList; +import java.io.*; + +public class CodeGenerator { + + LinkedList <Instruction> instructions = new LinkedList <Instruction>(); + + int label=0; + + public void emit( OpCode opCode) { + instructions.add( new Instruction(opCode)); + } + + public void emit( OpCode opCode , int operand ) { + instructions.add( new Instruction( opCode, operand )); + } + + public void emitLabel (int operand ) { + emit( OpCode.label , operand ); + } + + public int newLabel () { + return label++; + + } + + public void toJasmin () throws IOException{ + PrintWriter out = new PrintWriter(new FileWriter("/tmp/file.j")); + String temp = ""; + temp = temp + header; + while(instructions.size() > 0){ + Instruction tmp = instructions.remove(); + temp = temp + tmp.toJasmin(); + } + temp = temp + footer; + out.println(temp); + out.flush(); + out.close(); + } + + private static final String header = ".class public Output \n"+ ".super java/lang/Object\n" + + "\n" + + ".method public <init>()V\n" + + " aload_0\n" + + " invokenonvirtual java/lang/Object/<init>()V\n" + + " return\n" + + ".end method\n" + + "\n" + + ".method public static print(I)V\n" + + " .limit stack 2\n" + + " getstatic java/lang/System/out Ljava/io/PrintStream;\n" + + " iload_0 \n" + + " invokestatic java/lang/Integer/toString(I)Ljava/lang/String;\n" + + " invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V\n" + + " return\n" + + ".end method\n" + + "\n" + + ".method public static read()I\n" + + " .limit stack 3\n" + + " new java/util/Scanner\n" + + " dup\n" + + " getstatic java/lang/System/in Ljava/io/InputStream;\n" + + " invokespecial java/util/Scanner/<init>(Ljava/io/InputStream;)V\n" + + " invokevirtual java/util/Scanner/next()Ljava/lang/String;\n" + + " invokestatic java/lang/Integer.parseInt(Ljava/lang/String;)I\n" + + " ireturn\n" + + ".end method\n" + + ".method public static run()V\n" + + " .limit stack 1024\n" + + " .limit locals 256\n"; + + private static final String footer = " return\n" + + ".end method\n" + + "\n" + + ".method public static main([Ljava/lang/String;)V\n" + + " invokestatic Output/run()V\n" + + " return\n" + + ".end method\n"; +} + diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Instruction.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Instruction.java new file mode 100644 index 0000000..1f2e1cf --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Instruction.java @@ -0,0 +1,40 @@ +package lft.es5; + +public class Instruction { + OpCode opCode ; + int operand ; + + public Instruction ( OpCode opCode) { + this.opCode = opCode; + } + + public Instruction ( OpCode opCode , int operand ) { + this.opCode = opCode; + this.operand = operand; + } + + public String toJasmin () { + String temp=""; + switch (opCode) { + case ldc : temp = " ldc "+ operand + "\n"; break; + case iadd : temp = " iadd " + "\n"; break; + case invokestatic : if( operand == 1) temp = " invokestatic "+ "Output/print(I)V" + "\n"; + else temp =" invokestatic " + "Output/read()I" + "\n"; break; + case imul : temp = " imul " + "\n"; break; + case idiv : temp = " idiv " + "\n"; break; + case isub : temp = " isub " + "\n"; break; + case istore : temp = " istore " + operand + "\n"; break; + case iload : temp = " iload " + operand + "\n"; break; + case if_icmpeq : temp = " if_icmpeq L" + operand + "\n"; break; + case if_icmple : temp = " if_icmple L" + operand + "\n"; break; + case if_icmplt : temp = " if_icmplt L" + operand + "\n"; break; + case if_icmpne : temp = " if_icmpne L" + operand + "\n"; break; + case if_icmpge : temp = " if_icmpge L" + operand + "\n"; break; + case if_icmpgt : temp = " if_icmpgt L" + operand + "\n"; break; + case ifne : temp = " ifne L" + operand + "\n"; break; + case GOto : temp = " goto L" + operand + "\n" ; break; + case label : temp = "L" + operand + ":\n"; break; + } + return temp; + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/OpCode.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/OpCode.java new file mode 100644 index 0000000..d3d6e3b --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/OpCode.java @@ -0,0 +1,8 @@ +package lft.es5; + +public enum OpCode { + ldc , imul , idiv , iadd , + isub , istore , iload , + if_icmpeq , if_icmple , if_icmplt , if_icmpne, if_icmpge , + if_icmpgt , ifne , GOto , invokestatic , label +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/SymbolTable.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/SymbolTable.java new file mode 100644 index 0000000..9828c93 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/SymbolTable.java @@ -0,0 +1,22 @@ +package lft.es5; +import java.util.*; + +public class SymbolTable { + + Map <String, Integer> OffsetMap = new HashMap <String,Integer>(); + + public void insert( String s, int address ) { + if( !OffsetMap.containsValue(address) ) + OffsetMap.put(s,address); + else + throw new IllegalArgumentException("Reference to a memory location already occupied by another variable"); + } + + public int lookupAddress ( String s ) { + if( OffsetMap.containsKey(s) ) + return OffsetMap.get(s); + else + //throw new IllegalArgumentException("Unknown variable"); + return -1; + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Translator.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Translator.java new file mode 100644 index 0000000..6e6a29e --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/Translator.java @@ -0,0 +1,270 @@ +package lft.es5; +import lft.es2_1.*; +import lft.es3.Parser2; +import lft.lftError.LftError; + +import java.io.*; + +public class Translator extends Parser2 { + + SymbolTable st = new SymbolTable(); + CodeGenerator code = new CodeGenerator(); + int count=0; + String program; + boolean facoltativo = false; + + public Translator(Lexer l, BufferedReader br, String program, boolean facoltativo) { + super(l, br); + this.program = program; + l.program = program; + this.facoltativo = facoltativo; + } + + private int address(){ + // creates if not found + int addr = st.lookupAddress(((Word) look).lexeme); + if (addr == -1) { + addr = count; + st.insert(((Word) look).lexeme, count++); + } + return addr; + } + + public void prog() { + int lnext_prog = code.newLabel(); + statlist(lnext_prog); + code.emitLabel(lnext_prog); + matchOrThrow(Tag.EOF); + try { + code.toJasmin(); + } + catch(java.io.IOException e) { + System.out.println("IO error\n"); + }; + } + + public void statlist(int lnext){ + int lnextProg = code.newLabel(); + stat(lnextProg); + code.emitLabel(lnextProg); + statlistp(lnext); + } + + private void statlistp(int lnext) { + if(match(';')) { + int lnew = code.newLabel(); + stat(lnew); + code.emitLabel(lnew); + statlistp(lnext); + } else if(look.tag == Tag.EOF || look.tag == '}') { + // do nothing + return; + } else { + System.out.println("Error in: " +look); + error("Syntax error"); + } + } + + public void stat(int lnext) { + switch (look.tag) { + case Tag.ID: + int addr = address(); + matchOrThrow(Tag.ID); + matchOrThrow(Tag.ASSIGN); + expr(); + code.emit(OpCode.istore, addr); + break; + + case Tag.CASE: + int lelse = code.newLabel(); + matchOrThrow(Tag.CASE); + whenlist(lnext, lelse); + match(Tag.ELSE); + code.emitLabel(lelse); + stat(lelse); + break; + case Tag.WHILE: + matchOrThrow(Tag.WHILE); + matchOrThrow('('); + int begin = code.newLabel(); + code.emitLabel(begin); + int btrue = code.newLabel(); + bexpr(btrue, lnext); + matchOrThrow(')'); + code.emitLabel(btrue); + stat(begin); + code.emit(OpCode.GOto, begin); + break; + case Tag.PRINT: + matchOrThrow(Tag.PRINT); + matchOrThrow('('); + expr(); + code.emit(OpCode.invokestatic, 1); + matchOrThrow(')'); + break; + case Tag.READ: + matchOrThrow(Tag.READ); + matchOrThrow('('); + if (look.tag == Tag.ID) { + int read_id_addr = address(); + matchOrThrow(Tag.ID); + matchOrThrow(')'); + code.emit(OpCode.invokestatic, 0); + code.emit(OpCode.istore, read_id_addr); + } else + error("Error in grammar (stat) after read( with " + look); + break; + case '{': + matchOrThrow('{'); + statlist(lnext); + matchOrThrow('}'); + break; + default: + error("Syntax error"); + } + } + + protected void whenlist(int label, int lelse){ + int lb = code.newLabel(); + whenitem(label, lb); + code.emitLabel(lb); + whenlistp(label, lelse); + } + protected void whenlistp(int lnext, int lelse){ + if(look.tag == Tag.ELSE) // insieme guida, follow + return; + else if(look.tag == Tag.WHEN){ // first + int lb = code.newLabel(); + whenitem(lnext, lb); + code.emitLabel(lb); + whenlistp(lnext, lelse); + } else + error("Syntax error"); + } + + protected void whenitem(int lnext, int lfalse){ + int ltrue = code.newLabel(); + + matchOrThrow(Tag.WHEN); + matchOrThrow('('); + bexpr(ltrue, lfalse); + matchOrThrow(')'); + + code.emitLabel(ltrue); + int ll = code.newLabel(); + stat(ll); + code.emit(OpCode.GOto, lnext); + } + + + private void bexpr(int ltrue, int lfalse) { + expr(); + Token src = look; + matchOrThrow(Tag.RELOP); + expr(); + + if(src instanceof Word){ + Word w = (Word) src; + OpCode op; + int label = !facoltativo ? ltrue : lfalse; + switch(w.lexeme){ + case "==": + op = !facoltativo ? OpCode.if_icmpeq : OpCode.if_icmpne; + code.emit( op, label); + break; + case ">=": + op = !facoltativo ? OpCode.if_icmpge : OpCode.if_icmplt; + code.emit( op, label); + break; + case "<=": + op = !facoltativo ? OpCode.if_icmple : OpCode.if_icmpgt; + code.emit( op, label); + break; + case ">": + op = !facoltativo ? OpCode.if_icmpgt : OpCode.if_icmple; + code.emit( op, label); + break; + case "<": + op = !facoltativo ? OpCode.if_icmplt : OpCode.if_icmpge; + code.emit( op, label); + break; + case "<>": + op = !facoltativo ? OpCode.if_icmpne : OpCode.if_icmpeq; + code.emit( op, label); + break; + } + } + if(!facoltativo) + code.emit(OpCode.GOto, lfalse); + + } + + @Override + protected void exprp() { + if(match('-')) { + term(); + code.emit(OpCode.isub); + exprp(); + }else if(match('+')) { + term(); + code.emit(OpCode.iadd); + exprp(); + } + } + + @Override + protected void termp() { + if(match('/')) { + fact(); + code.emit(OpCode.idiv); + termp(); + }else if(match('*')) { + fact(); + code.emit(OpCode.imul); + termp(); + } else if(look.tag == ')' || look.tag == '}' || look.tag == ';' || look.tag == Tag.WHEN + || look.tag == Tag.RELOP || look.tag == '+' || look.tag == '-' || look.tag == Tag.EOF){ + // do nothing + return; + } else{ + error("Invalid syntax"); + } + } + + @Override + protected void fact() { + Token src = look; + if(match('(')) { + expr(); + matchOrThrow(')'); + } + if(match(Tag.NUM)) { + int num = ((NumberTok) src).num; + code.emit(OpCode.ldc, num); + } else if(match(Tag.ID)){ + Word word = (Word) src; + int addr = st.lookupAddress(word.lexeme); + if(addr == -1) + throw new unknownVariableException(program, Lexer.line, word.lexeme); + code.emit(OpCode.iload, addr); + }else + error("Fact did not match"); + } + + public static void main(String[] args) { + Lexer lex = new Lexer(); + //String path = "./es5.program"; // il percorso del file da leggere + String path = "programs/fib.program"; + try { + BufferedReader br = new BufferedReader(new FileReader(path)); + Translator translator = new Translator(lex, br, path, false); + translator.prog(); + System.out.println("Input OK"); + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } catch (LftError e){ + System.err.println(e.msg); + } + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/es5/unknownVariableException.java b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/unknownVariableException.java new file mode 100644 index 0000000..e6b8512 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/es5/unknownVariableException.java @@ -0,0 +1,10 @@ +package lft.es5; + +import lft.lftError.LftError; + +public class unknownVariableException extends LftError { + public unknownVariableException(String program, int line, String id){ + this.msg = progLine(program , line) + "undeclared variable \"" + id + "\""; + } + +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/lftError/LftError.java b/anno2/Sem2/lft/progetto/src/main/java/lft/lftError/LftError.java new file mode 100644 index 0000000..b8126de --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/lftError/LftError.java @@ -0,0 +1,10 @@ +package lft.lftError; + +public class LftError extends Error{ + public String msg; + public LftError(){ + } + static public String progLine(String program, int line){ + return program + ":" + line + ": "; + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/lft/trezeri/TreZeri.java b/anno2/Sem2/lft/progetto/src/main/java/lft/trezeri/TreZeri.java new file mode 100644 index 0000000..dbab730 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/lft/trezeri/TreZeri.java @@ -0,0 +1,57 @@ +package lft.trezeri; + + +public class TreZeri +{ + public static boolean scan(String s) + { + int state = 0; + int i = 0; + while (state >= 0 && i < s.length()) { + final char ch = s.charAt(i++); + switch (state) { + case 0: + if (ch == '0') + state = 1; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 1: + if (ch == '0') + state = 2; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 2: + if (ch == '0') + state = 3; + else if (ch == '1') + state = 0; + else + state = -1; + break; + case 3: + if (ch == '0' || ch == '1') + state = 3; + else + state = -1; + break; + } + } + return state == 3; + } + + + public static void main(String[] args) + { + if(args.length != 1) { + System.err.println("No args"); + System.exit(2); + } + System.out.println(scan(args[0]) ? "OK" : "NOPE"); + } +} diff --git a/anno2/Sem2/lft/progetto/src/main/java/source.program b/anno2/Sem2/lft/progetto/src/main/java/source.program new file mode 100644 index 0000000..9c668b3 --- /dev/null +++ b/anno2/Sem2/lft/progetto/src/main/java/source.program @@ -0,0 +1,4 @@ +a:=2; +print(d*t); +case when x>y then x:=0 else y:=0 +while(cases<=printread) do cases:=cases+1 diff --git a/anno2/Sem2/lft/progetto/test b/anno2/Sem2/lft/progetto/test new file mode 100644 index 0000000..ea0e5ba --- /dev/null +++ b/anno2/Sem2/lft/progetto/test @@ -0,0 +1,58 @@ +"320010331413433240", +"22", +"10242333101004114022", +"04342322103", +"41030010", +"243142031320410", +"13121224233133011322", +"41204331422040332", +"333230", +"1003012214313", +"3343341441140002330", +"31104400", +"444234123233414434", +"2140041", +"342443", +"44324100313041", +"40340240333014040430", +"41133240", +"23424", +"00000000", +"1110", +"01101010010111011011", +"0011110100", +"10010001", +"00", +"000101111110010001", +"111000000", +"100010100111110", +"001000111", +"1", +"010110110110110011", +"1001000111000100", +"10000101110100", +"0111110111110110011", +"1000110011110100", +"1000100", +"1100010010000", +"001100101101", +"010011000000111010", +"0010111", +"20010101220112", +"0012021200", +"101", +"012112", +"20220201211022222111", +"1020212020222120101", +"0010", +"11022011221201102", +"01201212111021220022", +"22011220020", +"122110002002", +"00000110212122122112", +"22011112101", +"00200212122001100", +"0110211212122121", +"1201001011200220", +"2", +"002221201111",