progetto, 24 :(
This commit is contained in:
parent
e07f38e026
commit
139c532818
109 changed files with 3099 additions and 0 deletions
Binary file not shown.
Binary file not shown.
BIN
anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.bin
Normal file
BIN
anno2/Sem2/lft/progetto/.gradle/4.10.3/fileHashes/fileHashes.bin
Normal file
Binary file not shown.
Binary file not shown.
0
anno2/Sem2/lft/progetto/.gradle/4.10.3/gc.properties
Normal file
0
anno2/Sem2/lft/progetto/.gradle/4.10.3/gc.properties
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
#Fri Jul 05 11:29:46 CEST 2019
|
||||||
|
gradle.version=4.10.3
|
Binary file not shown.
0
anno2/Sem2/lft/progetto/.gradle/vcs-1/gc.properties
Normal file
0
anno2/Sem2/lft/progetto/.gradle/vcs-1/gc.properties
Normal file
9
anno2/Sem2/lft/progetto/.idea/compiler.xml
Normal file
9
anno2/Sem2/lft/progetto/.idea/compiler.xml
Normal file
|
@ -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>
|
16
anno2/Sem2/lft/progetto/.idea/gradle.xml
Normal file
16
anno2/Sem2/lft/progetto/.idea/gradle.xml
Normal file
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
9
anno2/Sem2/lft/progetto/.idea/misc.xml
Normal file
9
anno2/Sem2/lft/progetto/.idea/misc.xml
Normal file
|
@ -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>
|
10
anno2/Sem2/lft/progetto/.idea/modules.xml
Normal file
10
anno2/Sem2/lft/progetto/.idea/modules.xml
Normal file
|
@ -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>
|
13
anno2/Sem2/lft/progetto/.idea/modules/lft_main.iml
Normal file
13
anno2/Sem2/lft/progetto/.idea/modules/lft_main.iml
Normal file
|
@ -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>
|
17
anno2/Sem2/lft/progetto/.idea/modules/lft_test.iml
Normal file
17
anno2/Sem2/lft/progetto/.idea/modules/lft_test.iml
Normal file
|
@ -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>
|
6
anno2/Sem2/lft/progetto/.idea/vcs.xml
Normal file
6
anno2/Sem2/lft/progetto/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
465
anno2/Sem2/lft/progetto/.idea/workspace.xml
Normal file
465
anno2/Sem2/lft/progetto/.idea/workspace.xml
Normal file
|
@ -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>
|
16
anno2/Sem2/lft/progetto/build.gradle
Normal file
16
anno2/Sem2/lft/progetto/build.gradle
Normal file
|
@ -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'
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21
anno2/Sem2/lft/progetto/es2.program
Normal file
21
anno2/Sem2/lft/progetto/es2.program
Normal file
|
@ -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 ;
|
5
anno2/Sem2/lft/progetto/es3_1.program
Normal file
5
anno2/Sem2/lft/progetto/es3_1.program
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
2+2 * 8 + (45 + 2) -
|
||||||
|
|
||||||
|
4 + 4
|
||||||
|
+ 6
|
||||||
|
/ 2 + (5 / 5 + 1)
|
21
anno2/Sem2/lft/progetto/es3_2.program
Normal file
21
anno2/Sem2/lft/progetto/es3_2.program
Normal file
|
@ -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) }
|
||||||
|
}
|
14
anno2/Sem2/lft/progetto/es5.program
Normal file
14
anno2/Sem2/lft/progetto/es5.program
Normal file
|
@ -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
|
BIN
anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
anno2/Sem2/lft/progetto/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -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
|
172
anno2/Sem2/lft/progetto/gradlew
vendored
Executable file
172
anno2/Sem2/lft/progetto/gradlew
vendored
Executable file
|
@ -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" "$@"
|
84
anno2/Sem2/lft/progetto/gradlew.bat
vendored
Normal file
84
anno2/Sem2/lft/progetto/gradlew.bat
vendored
Normal file
|
@ -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
|
12
anno2/Sem2/lft/progetto/lft.iml
Normal file
12
anno2/Sem2/lft/progetto/lft.iml
Normal file
|
@ -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>
|
4
anno2/Sem2/lft/progetto/programs/1.program
Normal file
4
anno2/Sem2/lft/progetto/programs/1.program
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
max := a;
|
||||||
|
case when(b>max) max := b
|
||||||
|
when(c>max) max := c
|
||||||
|
else max:=a+b+c;
|
13
anno2/Sem2/lft/progetto/programs/2.program
Normal file
13
anno2/Sem2/lft/progetto/programs/2.program
Normal file
|
@ -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)
|
||||||
|
}
|
BIN
anno2/Sem2/lft/progetto/programs/Output.class
Normal file
BIN
anno2/Sem2/lft/progetto/programs/Output.class
Normal file
Binary file not shown.
16
anno2/Sem2/lft/progetto/programs/fib.program
Normal file
16
anno2/Sem2/lft/progetto/programs/fib.program
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
read(max);
|
||||||
|
a:=0;
|
||||||
|
b:=1;
|
||||||
|
while(a<max){
|
||||||
|
print(a);
|
||||||
|
c :=a;
|
||||||
|
a := a+b;
|
||||||
|
b:=c
|
||||||
|
};
|
||||||
|
print(a)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
anno2/Sem2/lft/progetto/programs/jasmin.jar
Normal file
BIN
anno2/Sem2/lft/progetto/programs/jasmin.jar
Normal file
Binary file not shown.
4
anno2/Sem2/lft/progetto/programs/unknownVariable.program
Normal file
4
anno2/Sem2/lft/progetto/programs/unknownVariable.program
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
read(a);
|
||||||
|
read(b);
|
||||||
|
print(a);
|
||||||
|
print(c)
|
2
anno2/Sem2/lft/progetto/settings.gradle
Normal file
2
anno2/Sem2/lft/progetto/settings.gradle
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
rootProject.name = 'lft'
|
||||||
|
|
BIN
anno2/Sem2/lft/progetto/settings.zip
Normal file
BIN
anno2/Sem2/lft/progetto/settings.zip
Normal file
Binary file not shown.
138
anno2/Sem2/lft/progetto/src/main/java/lft/es1_1/es1_1.java
Normal file
138
anno2/Sem2/lft/progetto/src/main/java/lft/es1_1/es1_1.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
72
anno2/Sem2/lft/progetto/src/main/java/lft/es1_10/es1_10.java
Normal file
72
anno2/Sem2/lft/progetto/src/main/java/lft/es1_10/es1_10.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_11/es1_11.java
Normal file
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_11/es1_11.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
73
anno2/Sem2/lft/progetto/src/main/java/lft/es1_2/es1_2.java
Normal file
73
anno2/Sem2/lft/progetto/src/main/java/lft/es1_2/es1_2.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
69
anno2/Sem2/lft/progetto/src/main/java/lft/es1_3/es1_3.java
Normal file
69
anno2/Sem2/lft/progetto/src/main/java/lft/es1_3/es1_3.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
anno2/Sem2/lft/progetto/src/main/java/lft/es1_4/es1_4.java
Normal file
102
anno2/Sem2/lft/progetto/src/main/java/lft/es1_4/es1_4.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
91
anno2/Sem2/lft/progetto/src/main/java/lft/es1_5/es1_5.java
Normal file
91
anno2/Sem2/lft/progetto/src/main/java/lft/es1_5/es1_5.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
80
anno2/Sem2/lft/progetto/src/main/java/lft/es1_6/es1_6.java
Normal file
80
anno2/Sem2/lft/progetto/src/main/java/lft/es1_6/es1_6.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_7/es1_7.java
Normal file
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_7/es1_7.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
83
anno2/Sem2/lft/progetto/src/main/java/lft/es1_8/es1_8.java
Normal file
83
anno2/Sem2/lft/progetto/src/main/java/lft/es1_8/es1_8.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_9/es1_9.java
Normal file
84
anno2/Sem2/lft/progetto/src/main/java/lft/es1_9/es1_9.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
234
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Lexer.java
Normal file
234
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Lexer.java
Normal file
|
@ -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();}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 + ">"; }
|
||||||
|
}
|
9
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Tag.java
Normal file
9
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Tag.java
Normal file
|
@ -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;
|
||||||
|
}
|
18
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Token.java
Normal file
18
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Token.java
Normal file
|
@ -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(';');
|
||||||
|
}
|
25
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Word.java
Normal file
25
anno2/Sem2/lft/progetto/src/main/java/lft/es2_1/Word.java
Normal file
|
@ -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, ">=");
|
||||||
|
}
|
|
@ -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 +"'";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 +"'";
|
||||||
|
}
|
||||||
|
}
|
87
anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser.java
Normal file
87
anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser.java
Normal file
|
@ -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();}
|
||||||
|
}
|
||||||
|
}
|
101
anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser2.java
Normal file
101
anno2/Sem2/lft/progetto/src/main/java/lft/es3/Parser2.java
Normal file
|
@ -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();}
|
||||||
|
}
|
||||||
|
}
|
116
anno2/Sem2/lft/progetto/src/main/java/lft/es4/Translator.java
Normal file
116
anno2/Sem2/lft/progetto/src/main/java/lft/es4/Translator.java
Normal file
|
@ -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();}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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";
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue