diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..f619a53 --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.mylyn/.taskListIndex/segments.gen b/.metadata/.mylyn/.taskListIndex/segments.gen new file mode 100644 index 0000000..63a7ec9 Binary files /dev/null and b/.metadata/.mylyn/.taskListIndex/segments.gen differ diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000..d20a054 Binary files /dev/null and b/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000..afd2154 Binary files /dev/null and b/.metadata/.mylyn/repositories.xml.zip differ diff --git a/.metadata/.mylyn/tasks.xml.zip b/.metadata/.mylyn/tasks.xml.zip new file mode 100644 index 0000000..f825e20 Binary files /dev/null and b/.metadata/.mylyn/tasks.xml.zip differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..10c75e3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 0000000..6f3b1e7 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000..82e6b89 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..dffc6b5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..c8fd235 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,13 @@ +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +fontPropagated=true +org.eclipse.jdt.ui.editor.tab.width= +org.eclipse.jdt.ui.formatterprofiles.version=12 +org.eclipse.jdt.ui.javadoclocations.migrated=true +org.eclipse.jface.textfont=1|Consolas|10.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +proposalOrderMigrated=true +spelling_locale_initialized=true +tabWidthPropagated=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 0000000..67b1d96 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000..43e97e4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000..8d462a6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000..5330e43 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +migrated.task.repositories.secure.store=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs new file mode 100644 index 0000000..f9e585b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +pref_first_startup=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs new file mode 100644 index 0000000..56cd496 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.team.ui.first_time=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 0000000..4c74ce4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,5 @@ +PROBLEMS_FILTERS_MIGRATE=true +eclipse.preferences.version=1 +platformState=1428813606069 +quickStart=false +tipsAndTricks=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs new file mode 100644 index 0000000..08076f2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +showIntro=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 0000000..6316221 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,3 @@ +ENABLED_DECORATORS=org.eclipse.m2e.core.mavenVersionDecorator\:false,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.jdt.ui.override.decorator\:true,org.eclipse.jdt.ui.interface.decorator\:false,org.eclipse.jdt.ui.buildpath.decorator\:true,org.eclipse.m2e.core.maven2decorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.SymlinkDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false, +PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.m2e.discovery; +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..574b3f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2009 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + topLevel + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.wb.core.ui.actionset + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.ant.ui.views.AntView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.views.ResourceNavigator + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.viewSC:org.eclipse.wb.core.StructureView + persp.viewSC:org.eclipse.wb.core.PaletteView + + + + newtablook + org.eclipse.e4.primaryNavigationStack + active + + + + + + + + + + newtablook + + + + + + + + + newtablook + + + + newtablook + org.eclipse.e4.secondaryNavigationStack + + + + + + + + newtablook + org.eclipse.e4.secondaryDataStack + + + + + + + + + + + + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Help + + + + newtablook + org.eclipse.e4.primaryDataStack + EditorStack + + + + + View + categoryTag:Java + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:Ant + + + View + categoryTag:Git + + + View + categoryTag:Java + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:WindowBuilder + + + View + categoryTag:WindowBuilder + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + + + + + TrimStack + + + TrimStack + + + TrimStack + + + TrimStack + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + + + View + categoryTag:Ant + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:Debug + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Maven + + + View + categoryTag:Maven + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Code Recommenders + + + View + categoryTag:Code Recommenders + + + View + categoryTag:Code Recommenders + + + View + categoryTag:Code Recommenders + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:CVS + + + View + categoryTag:CVS + + + View + categoryTag:Team + + + View + categoryTag:Team + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:WindowBuilder + + + View + categoryTag:WindowBuilder + + + View + categoryTag:General + + + View + categoryTag:XML + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..0edae4b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..9e390f5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..9cf5b13 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.m2e.core.ui/dialog_settings.xml new file mode 100644 index 0000000..739d14e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.core.ui/dialog_settings.xml @@ -0,0 +1,15 @@ + +
+
+ + + + + + + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/_0.cfs b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/_0.cfs new file mode 100644 index 0000000..5a30236 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/_0.cfs differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments.gen b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments.gen new file mode 100644 index 0000000..225a55b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments.gen differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments_2 b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments_2 new file mode 100644 index 0000000..44e1d9c Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/segments_2 differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/write.lock b/.metadata/.plugins/org.eclipse.m2e.core/nexus/26522e0d83a422eed93329ece7565cfc/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0.cfs b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0.cfs new file mode 100644 index 0000000..2510e88 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0.cfs differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments.gen b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments.gen new file mode 100644 index 0000000..225a55b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments.gen differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments_2 b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments_2 new file mode 100644 index 0000000..efedb9a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments_2 differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/write.lock b/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/_0.cfs b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/_0.cfs new file mode 100644 index 0000000..21b99fa Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/_0.cfs differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments.gen b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments.gen new file mode 100644 index 0000000..225a55b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments.gen differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments_2 b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments_2 new file mode 100644 index 0000000..0fd3a16 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/segments_2 differ diff --git a/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/write.lock b/.metadata/.plugins/org.eclipse.m2e.core/nexus/d91aba3017ff816c2a31821c02251625/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000..a18b68e Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.5.1.20150109-1820.xml b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.5.1.20150109-1820.xml new file mode 100644 index 0000000..e33758c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.5.1.20150109-1820.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000..43e24dd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,17 @@ + +
+
+ + + + + + + + + + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..ab6edbc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 0000000..ed997e9 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Fri Oct 02 00:07:25 GMT-03:00 2015 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.4.2.v20150204-1700 diff --git a/.project b/.project new file mode 100644 index 0000000..dda840f --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + shapes4learn + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..1c4f5c4 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/SyntacticAnalyzer.java=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/Launcher.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/Launcher.java index 5ebf13b..3ffcb09 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/Launcher.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/Launcher.java @@ -2,6 +2,9 @@ import javax.swing.JOptionPane; +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.SyntacticAnalyzer; +import edu.maimonides.multimedia.shapes4learn.controller.InterpreterController; import edu.maimonides.multimedia.shapes4learn.gui.InterpreterFrame; import edu.maimonides.multimedia.shapes4learn.interpreter.Interpreter; import edu.maimonides.multimedia.shapes4learn.model.impl.BasicShapeAmbient; @@ -29,7 +32,11 @@ public static void main(String[] args) { } InterpreterFrame frame; try { - frame = new InterpreterFrame(createInterpreter(classname), new BasicShapeAmbient()); + LexicalAnalyzer lexAn = new LexicalAnalyzer(); + + SyntacticAnalyzer synAn = new SyntacticAnalyzer(); + + frame = new InterpreterFrame(createInterpreter(classname), new BasicShapeAmbient(), lexAn, synAn ); frame.init(); frame.setVisible(true); } catch (ClassNotFoundException e) { diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/LexicalAnalyzer.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/LexicalAnalyzer.java index ac98a27..9945b70 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/LexicalAnalyzer.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/LexicalAnalyzer.java @@ -1,8 +1,8 @@ package edu.maimonides.multimedia.shapes4learn.analysis; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; - import edu.maimonides.multimedia.shapes4learn.model.Token; /** @@ -14,12 +14,240 @@ * */ public class LexicalAnalyzer { - public List analyze(String code) throws LexicalException { + + String[][] reservada = new String[20][20]; + //String[] aux; + boolean validoNum=false; + //boolean validoId=true; + boolean Operadores=false; + boolean reservada1=false; + boolean id=false; + boolean color=false; + + // Completo la matriz token (lexemas - clase) + + reservada[0][0] = "create"; reservada[0][1] = "crear"; + + reservada[1][0] = "rectangle"; reservada[1][1] = "ShapeRectangulo"; + + reservada[2][0] = "circle"; reservada[2][1] = "ShapeCirculo"; + + reservada[3][0] = ";"; reservada[3][1] = "fin de sentencia"; + + reservada[4][0] = "setbase"; reservada[4][1] = "setear base"; + + reservada[5][0] = "setheight"; reservada[5][1] = "setear altura"; + + reservada[6][0] = "setcolor"; reservada[6][1] = "setear color"; + + reservada[7][0] = "setradius"; reservada[7][1] = "setear radio"; + + reservada[8][0] = "setposition"; reservada[8][1] = "setear posicion"; + + reservada[9][0] = "shape"; reservada[9][1] = "clase shape"; + + reservada[10][0] = ","; reservada[10][1] = "coma"; + + reservada[11][0] = "in"; reservada[11][1] = "in"; + List tokens = new LinkedList<>(); - // TODO Implement. + // Separo los lexemas + String delimitadores= "[\\ \\ \\ \\ \\ \\ \\\n]"; + String lexemas[] = code.split(delimitadores); + + //Recorro los lexemas y encuentro las Lexemas reservadas del lenguaje + for(int i=0; i< lexemas.length; i++) { + + Token tempToken = new Token(); + reservada1=false; + validoNum=false; + //boolean validoId=true; + reservada1=false; + id=false; + color=false; + Operadores=false; + + //System.out.println("\nPosicion: " + i + " <><> Lexema que ingresa: " + lexemas[i]); + + //System.out.println("Token: "); + + for (int j=0;j<=11;j++) + { + + if (lexemas[i].equals(reservada[j][0])) + { + // Cuando lo encuentro, como se pasa a la linkedlisto token???? + + reservada1=true; + + tempToken.lexema = reservada[j][0]; + tempToken.clase = reservada [j][1]; + } + } + // si no es Lexema reservada + + int x=0; + int paso=1; + + // veo si es numero + for (;x iterator = tokens.iterator(); iterator.hasNext();) { + Token token = (Token) iterator.next(); + System.out.println("Lexema: " + token.lexema + " Clase: " + token.clase); + } + return tokens; } } diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/SyntacticAnalyzer.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/SyntacticAnalyzer.java index 66ef34c..dc5b018 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/SyntacticAnalyzer.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/analysis/SyntacticAnalyzer.java @@ -1,8 +1,12 @@ package edu.maimonides.multimedia.shapes4learn.analysis; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import edu.maimonides.multimedia.shapes4learn.model.AST; +import edu.maimonides.multimedia.shapes4learn.model.Figura; import edu.maimonides.multimedia.shapes4learn.model.Token; /** @@ -13,16 +17,975 @@ * @author Matias Giorgio * */ -public class SyntacticAnalyzer { + +public class SyntacticAnalyzer { + + private int linea=0; + private String sentencia; + private String lookahead; + private Token token; + private Iterator iterator; + private AST raiz = new AST(); + private AST expG = new AST(); + private ArrayList figuras; //pasar al semantico + private String s1 = " "; + public SyntacticAnalyzer() { } public AST analyze(List tokens) throws SyntacticException { - AST ast = new AST(); + + List sentencias = new LinkedList<>(); + + sentencia = new String(); + + + for (Iterator iterator = tokens.iterator(); iterator.hasNext();) { + Token token = (Token) iterator.next(); + + if ((token.lexema.charAt(0) == ';')){ + + sentencias.add(sentencia + ';'); + + sentencia = new String(); + + + }else{ + sentencia = sentencia.concat(' ' +token.lexema); + + + + } + + } + + // for (Iterator iterator = sentencias.iterator(); iterator.hasNext();) { + // String sent = iterator.next(); + //System.out.println("Setencia: " + sent); + + //} + + checkSent(tokens); + + validarArbol(raiz); + + return raiz; + } + + public void validarArbol(AST raiz2){ + + + + System.out.println("--- Arboles ----- "); + + + System.out.println("\n"); + +// SETBASE +// + RECTANGLE +//4 4 + + + for (Iterator it = raiz2.listChildren().iterator(); it.hasNext();) { + + + + AST arbol = it.next(); + + + + String lexema = arbol.getToken().getClase(); + + + + System.out.println(" " + lexema); + + String s = " "; + + if (arbol.listChildren().size() != 0 ){ + + for(int a = 0 ; a < arbol.listChildren().size(); a++ ) + + { + + + String tipo = arbol.getChild(a).getToken().getLexema(); + + s = s + tipo + " " ; + + } + + System.out.println(s1 + s); + + for(int a = 0 ; a < arbol.listChildren().size(); a++ ) + + { + validohijo(arbol.getChild(a)); + } + } + + System.out.println("--- Fin arboles ----- "); + + System.out.println("\n"); + } + } + + + //System.out.println ("\n"); + //System.out.println ("--- Comienza Analisis semantico ----- "); + //System.out.println ("\n"); + + /**for (Iterator it = raiz2.listChildren().iterator(); it.hasNext();) { + + AST arbol = it.next(); + + String lexema = arbol.getToken().getClase(); + String tipo = arbol.getChild(0).getToken().getLexema(); + String id = arbol.getChild(1).getToken().getLexema(); + + + + if (lexema.equals("crear")) + { + Figura figuraNueva = new Figura(); + + if(figuras.isEmpty()){ + figuraNueva.setClase(tipo); + figuraNueva.setId(id); + figuras.add(figuraNueva); + + + } + + else + + { + for (Iterator iterator = figuras.iterator(); iterator.hasNext();) { + + + + if(iterator.next().getId().equals(id)){ + + System.out.printf("Ya existe el ID \"%s\" para otra figura", id); + System.exit(0); + + } + + figuraNueva.setClase(tipo); + figuraNueva.setId(id); + System.out.println("Se creo una figura."); + } + + figuras.add(figuraNueva); + } + + } + + + + }**/ + +/** for (Iterator iterator1 = figuras.iterator(); iterator.hasNext();) { + Figura fig = iterator1.next(); + System.out.println("\n"); + + System.out.printf(" Figura creada: %s Clase %s", fig.getId() , fig.getClase()); + + }**/ + + + + + private void validohijo(AST arbol) { + + + + + + //System.out.println("\n"); + s1 = s1 + " "; + String s = " "; + + for(int a = 0 ; a < arbol.listChildren().size(); a++ ) + + { + + //System.out.println("Valido " + arbol.getToken().getLexema() + "Hijos: " + arbol.listChildren().size()); + + if (arbol.getChild(a).listChildren().size() != 0 ){ + //System.out.println("Valido arbol de raiz: " + a); + String tipo = arbol.getChild(a).getToken().getLexema(); + + s = s + tipo + " " ; + + //System.out.println("Valido si es distinto de cero: " + arbol.getChild(a).getToken().getLexema()); + + } + + + else{ + String tipo = arbol.getChild(a).getToken().getLexema(); + + //System.out.println("Valido si es cero: " + arbol.getChild(a).getToken().getLexema()); + + s = s + tipo + " "; + + + } + + } + + + System.out.println(s1 + s); + + for(int a = 0 ; a < arbol.listChildren().size(); a++ ) + + { + validohijo(arbol.getChild(a)); + } + + + + + } + +public void checkSent(List tokens){ + + figuras = new ArrayList<>(); + + for (iterator = tokens.iterator(); iterator.hasNext();) { + + token = (Token) iterator.next(); + + lookahead = token.getClase(); + + //Cambiar clase + + + + linea++; + System.out.println("\n"); + + if (lookahead == "crear"){ + checkCreate(lookahead); + } + + + if (lookahead == "setear color"){ + checkSetColor(lookahead); + } + + if (lookahead == "setear base"){ + checkSetBase(lookahead); + } + + if (lookahead == "setear altura"){ + checkSetHeight(lookahead); + } + + if(lookahead == "setear radio"){ + checkRadio(lookahead); + } + + if(lookahead == "setear posicion"){ + checkPosition(lookahead); + } + } + + + } + + + +private void checkPosition(String string) { + + + AST setposition = new AST(); + setposition.setLinea(linea); + setposition.setToken(token); + + matchSetPosition(string); + + AST position_def = new AST(); + position_def.setLinea(linea); + position_def.setToken(token); + + setposition.addChild(position_def); + + checkExpresion(lookahead); + + matchComa(lookahead); + + AST position_def2 = new AST(); + position_def2.setLinea(linea); + position_def2.setToken(token); + + setposition.addChild(position_def2); + + checkExpresion(lookahead); + + matchIn(lookahead); + matchShape(lookahead); + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + setposition.addChild(id); + + matchId(lookahead); + matchFin(lookahead); + + raiz.addChild(setposition); + + + + } + +private boolean matchComa(String coma) { + + if(coma == "coma"){ + //System.out.println("Es coma"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba coma.", coma); + System.exit(0); + return false; + +} + +private boolean matchSetPosition(String string) { + if(string == "setear posicion"){ + System.out.println("Es setPosition"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba setPosition.", string); + System.exit(0); + return false; + +} + +private void checkRadio(String string) { + +System.out.println("Se espera: setradius [expression] in circle [id] ;"); + AST setradio = new AST(); + setradio.setLinea(linea); + setradio.setToken(token); + + matchSetRadio(string); + + AST radio_def = new AST(); + + radio_def.setLinea(linea); + radio_def.setToken(token); + + setradio.addChild(radio_def); + + checkExpresion(lookahead); + + matchIn(lookahead); + matchCircle(lookahead); + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + setradio.addChild(id); + + matchId(lookahead); + matchFin(lookahead); + + raiz.addChild(setradio); + + + } + + +private boolean matchSetRadio(String string) { + if(string == "setear radio"){ + System.out.println("Es setRadio"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba setRadio.", string); + System.exit(0); + return false; + + } + + // setcolor [color_def] in shape [id]; + + private void checkSetColor(String string) { + + System.out.println("Se espera: setcolor [color_def] in shape [id] ;"); + + AST setcolor = new AST(); + setcolor.setLinea(linea); + setcolor.setToken(token); + + matchSetColor(string); + + AST color_def = new AST(); + color_def.setLinea(linea); + color_def.setToken(token); + + setcolor.addChild(color_def); + + matchColorDef(lookahead); + + matchIn(lookahead); + matchShape(lookahead); + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + setcolor.addChild(id); + + matchId(lookahead); + matchFin(lookahead); + + raiz.addChild(setcolor); + - // TODO Implement. + + } + + private boolean matchShape(String string) { + if(string == "clase shape"){ + System.out.println("Es shape"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba 'shape'", string); + System.exit(0); + return false; + + + } + + private boolean matchIn(String string) { + if(string == "in"){ + System.out.println("Es in"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba 'in'", string); + System.exit(0); + return false; + + + } + + +// setheight [expression] in rectangle [id] ; + + private void checkSetHeight(String string) { + + System.out.println("Se espera: setheight [expression] in rectangle [id] ;"); + + AST setheight = new AST(); + setheight.setLinea(linea); + setheight.setToken(token); + + matchSetHeight(string); + + AST height_def = new AST(); + height_def.setLinea(linea); + height_def.setToken(token); + + setheight.addChild(height_def); + + checkExpresion(lookahead); + + matchIn(lookahead); + matchRectangle(lookahead); + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + setheight.addChild(id); + + matchId(lookahead); + matchFin(lookahead); + + raiz.addChild(setheight); + + + + } + + + + private boolean matchSetHeight(String string) { + if(string == "setear altura"){ + System.out.println("Es setHeight"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba setHeight.", string); + System.exit(0); + return false; + + } + +// setbase [expression] in rectangle [id] ; + + private void checkSetBase(String string) { + + System.out.println("Se espera: setbase [expression] in rectangle [id] ;"); + + AST setbase = new AST(); + setbase.setLinea(linea); + setbase.setToken(token); + + matchSetBase(string); + + setbase.addChild(checkExpresion(lookahead)); + + matchIn(lookahead); + + matchRectangle(lookahead); + + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + + setbase.addChild(id); + + matchId(lookahead); + matchFin(lookahead); + + raiz.addChild(setbase); + + } + + + private boolean matchSetBase(String string) { + if(string == "setear base"){ + System.out.println("Es setBase"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba setBase.", string); + System.exit(0); + return false; + + } + + private AST checkExpresion(String string) { + //System.out.println("CHECK EXPRESION"); + + AST tnode = checkTermino(string); // 4 + AST trnode = checkTerminoR(lookahead); // + 4 + + return createNodo(tnode,trnode); +} + +private AST createNodo(AST tnode, AST trnode) { + + AST op = new AST(); + + AST nodeI = tnode; + + //System.out.println(tnode.getToken().getLexema() + " " + trnode.getToken().getLexema()); + if (trnode != null){ + + System.out.println("Es distinto de null: " + trnode.getToken().getClase()); + + if (trnode.getToken().getClase()=="Adicion"){ + + + op.setToken(trnode.getToken()); + op.setLinea(trnode.getLinea()); + + + AST nodeD = trnode; + + op.addChild(nodeI); + + nodeD = trnode.getChild(0); + + op.addChild(nodeD); + + return op; + + } + + if (trnode.getToken().getClase()=="Producto"){ + + + op.setToken(trnode.getToken()); + op.setLinea(trnode.getLinea()); + +// AST nodeD = trnode.getChild(0); + + AST nodeD = trnode; + + op.addChild(nodeI); + + nodeD = trnode.getChild(0); + + op.addChild(nodeD); + + return op; + + } + } + return nodeI; + } + +private AST checkTerminoR(String string) { + + AST fnode = new AST(); + fnode.setLinea(linea); + fnode.setToken(token); + + System.out.println("CHECK TERMINO R"); + if(matchAdicion(string)){ + + + AST tnode = checkTermino(lookahead); + + AST trnode = checkTerminoR(lookahead); + + AST opnode = new AST(); + + opnode = createNodo(tnode, trnode); + + fnode.addChild(opnode); + + return fnode; + + } + else{ + + if (string=="Numero" || string == "Parentesis A") { + + fnode = checkFactor(string); + return fnode; + }else { + return null; + } + + + + } + + + + +} + +private AST checkFactor(String string) { + + AST fnode = new AST(); + System.out.println("CHECK FACTOR"); + if (string == "Numero"){ + + + fnode.setLinea(linea); + fnode.setToken(token); + + matchNumero(string); + + } + else{ + if(matchAbroP(string)){ + + fnode = checkExpresion(lookahead); + + matchCierroP(lookahead); + + } + + + + } + return fnode; + +} + +private boolean matchNumero(String string) { + if(string == "Numero"){ + System.out.println("Es Numero."); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } else { + + return false; + } + +} + +private boolean matchAdicion(String string) { + + if(string == "Adicion"){ + System.out.println("Es Adicion."); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + + } + return false; + +} + +private boolean matchProducto(String string) { + if(string == "Producto"){ + + System.out.println("Es Producto."); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } else { + return false; + } + +} + +//EXP +//TERM = 4*4 +//TERMR+4 + + +private AST checkTermino(String string) { + System.out.println("CHECK TERMINO"); + AST fnode = checkFactor(string); //4 + AST frnode = checkFactorR(lookahead); //*4 + + + return createNodo(fnode, frnode); + +} + +private AST checkFactorR(String string) { + + System.out.println("CHECK FACTOR R"); + + AST frnode = new AST(); + + frnode.setLinea(linea); + frnode.setToken(token); + + if(matchProducto(string)) + { + AST fnode = checkFactor(lookahead); + + AST fnode2 = checkFactorR(lookahead); + AST opnode = new AST(); + + opnode = createNodo(fnode, fnode2); + frnode.addChild(opnode); + + return frnode; + + }else { + if(string=="Numero" || string == "Parentesis A"){ + + frnode = checkExpresion(string); + return frnode; + + }else{ + return null; + } + } +} + +private boolean matchCierroP(String string) { + if(string == "Parentesis C"){ + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba ')'. \n", string); + System.exit(0); + return false; + +} +//setbase ( 4 ) in rectangle id ; + +private boolean matchAbroP(String string) { + if(string == "Parentesis A"){ + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + + return false; + +} + + + + private void matchFin(String string) { + + if (string == "fin de sentencia"){ + + if (iterator.hasNext()){ + + System.out.println("[;] Fin de sentencia"); + } + else { + System.out.println("[;] Fin de sentencia"); + System.out.println("\n"); + System.out.println("Terminaron las sentencias a analizar"); + System.out.println("\n"); + + } + } + + } + + private boolean matchSetColor(String string) { + if(string == "setear color"){ + System.out.println("Es setColor"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba setcolor \n", string); + System.exit(0); + return false; + + } + + private boolean matchColorDef(String string) { + if(string == "color_def"){ + System.out.println("Es un color"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba un color del tipo #AAA111 \n", string); + System.exit(0); + return false; + + + } + +// create rectangle|circle [id]; + + private void checkCreate(String string) { + + System.out.println("Se espera: create rectangle|circle [id]"); + AST create = new AST(); + create.setLinea(linea); + create.setToken(token); + + matchCreate(string); + + AST shape = checkShape(lookahead); + create.addChild(shape); + + AST id = new AST(); + id.setLinea(linea); + id.setToken(token); + + matchId(lookahead); + + create.addChild(id); + + matchFin(lookahead); + + raiz.addChild(create); + + + } + + + + + private boolean matchId(String string) { + + if(string == "ID"){ + System.out.println("Es ID."); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } else { + System.out.printf("Vino %s, se esperaba un ID valido \n ", string); + System.exit(0); + return false; + } + + } + + private AST checkShape(String string) { + + AST figura = new AST(); + figura.setLinea(linea); + figura.setToken(token); + + if (string == "ShapeCirculo"){ + System.out.println("Es circle"); + matchCircle(lookahead); + }else { + if (string == "ShapeRectangulo"){ + System.out.println("Es rectangle"); + matchRectangle(lookahead); + + } else { + System.out.printf("Vino %s, se esperaba una figura \n ", string); + System.exit(0); + + } + + } + return figura; + + } + + private boolean matchRectangle(String string) { + if(string == "ShapeRectangulo"){ + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } else { + System.out.printf("Vino %s, se esperaba un rectangulo \n ", string); + System.exit(0); + return false; + } + + } + + private boolean matchCircle(String string) { + if(string == "ShapeCirculo"){ + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + + System.out.close(); + return false; + + + } - return ast; + private boolean matchCreate(String string) { + if(string == "crear"){ + System.out.println("Es create"); + token = (Token) iterator.next(); + lookahead = token.getClase(); + return true; + } + System.out.printf("Vino %s, se esperaba 'create' \n ", string); + System.exit(0); + return false; + } -} \ No newline at end of file +} diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/controller/InterpreterController.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/controller/InterpreterController.java new file mode 100644 index 0000000..e40304a --- /dev/null +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/controller/InterpreterController.java @@ -0,0 +1,56 @@ +package edu.maimonides.multimedia.shapes4learn.controller; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalException; +import edu.maimonides.multimedia.shapes4learn.analysis.SyntacticAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.SyntacticException; +import edu.maimonides.multimedia.shapes4learn.interpreter.CodeException; +import edu.maimonides.multimedia.shapes4learn.interpreter.Interpreter; +import edu.maimonides.multimedia.shapes4learn.model.AST; +import edu.maimonides.multimedia.shapes4learn.model.ShapeAmbient; +import edu.maimonides.multimedia.shapes4learn.model.Token; + +public class InterpreterController implements Interpreter{ + + private LexicalAnalyzer la; + private List tk; + private SyntacticAnalyzer sa; + + public InterpreterController(LexicalAnalyzer la, SyntacticAnalyzer sa) { + super(); + this.la = la; + this.sa = sa; + } + + @Override + public void interpret(String code, ShapeAmbient ambient) + throws CodeException { + try { + tk = la.analyze(code); + } catch (LexicalException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + AST ast = sa.analyze(tk); + } catch (SyntacticException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + @Override + public void interpret(InputStream stream, ShapeAmbient ambient) + throws CodeException, IOException { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/gui/InterpreterFrame.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/gui/InterpreterFrame.java index 044062d..2a5f035 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/gui/InterpreterFrame.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/gui/InterpreterFrame.java @@ -15,6 +15,10 @@ import javax.swing.JSplitPane; import javax.swing.JTextArea; +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.SyntacticAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.SyntacticException; +import edu.maimonides.multimedia.shapes4learn.controller.InterpreterController; import edu.maimonides.multimedia.shapes4learn.interpreter.CodeException; import edu.maimonides.multimedia.shapes4learn.interpreter.Interpreter; import edu.maimonides.multimedia.shapes4learn.model.ShapeAmbient; @@ -40,9 +44,20 @@ public class InterpreterFrame extends JFrame { private JMenuBar menuBar; - public InterpreterFrame(Interpreter interpreter, ShapeAmbient ambient) { + private LexicalAnalyzer la; + + private InterpreterController ic; + + private SyntacticAnalyzer sa; + + public InterpreterFrame(Interpreter interpreter, ShapeAmbient ambient, LexicalAnalyzer la, SyntacticAnalyzer sa) { this.ambient = ambient; this.interpreter = interpreter; + this.la = la; + this.sa = sa; + + ic = new InterpreterController(la, sa); + code = new JTextArea("Code here..."); shapesPanel = new ShapesPanel(); shapesPanel.setAmbient(ambient); @@ -101,8 +116,18 @@ public void actionPerformed(ActionEvent e) { } private class RunActionListener implements ActionListener { + + + + @Override public void actionPerformed(ActionEvent e) { + try { + ic.interpret(getInputCode(), ambient); + } catch (CodeException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } clearConsole(); try { interpreter.interpret(getInputCode(), ambient); diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java new file mode 100644 index 0000000..ae31791 --- /dev/null +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java @@ -0,0 +1,139 @@ +package edu.maimonides.multimedia.shapes4learn.interpreter; + +import java.io.IOException; +import java.io.InputStream; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; + +import edu.maimonides.multimedia.shapes4learn.model.ShapeAmbient; +import edu.maimonides.multimedia.shapes4learn.model.shapes.Rectangle; +import edu.maimonides.multimedia.shapes4learn.model.shapes.Shape; +import edu.maimonides.multimedia.shapes4learn.utils.ColorUtils; +import edu.maimonides.multimedia.shapes4learn.utils.ShapeUtils; + +/** + * Hard-coded, regex-based implementation of {@link Interpreter}, mostly for + * testing purposes. + * + * @author Matias Giorgio. + * + */ +public class RegexInterpreter implements Interpreter { + + private static final String NUMBER_PATTERN = "\\d+"; + private static final String SHAPE_TYPE_PATTERN = "[a-zA-Z]+"; + private static final String CREATE_KEYWORD = "create"; + private static final String SET_COLOR_KEYWORD = "setcolor"; + private static final String SET_BASE_KEYWORD = "setbase"; + + private static final String ID_PATTERN = SHAPE_TYPE_PATTERN; + + private Pattern createPattern; + private Pattern setColorPattern; + private Pattern setbasePatternInRectangle; + + public RegexInterpreter() { + createPattern = Pattern.compile(CREATE_KEYWORD + " (" + SHAPE_TYPE_PATTERN + ") (" + ID_PATTERN + ");", Pattern.CASE_INSENSITIVE); + setColorPattern = Pattern.compile(SET_COLOR_KEYWORD + " \\#([0-9a-fA-F]{6,6}) in shape (" + ID_PATTERN + ");", Pattern.CASE_INSENSITIVE); + setbasePatternInRectangle = Pattern.compile(SET_BASE_KEYWORD + " (" + NUMBER_PATTERN + ") in rectangle (" + ID_PATTERN + ");"); + } + + @Override + public void interpret(String code, ShapeAmbient ambient) throws CodeException { + String[] lines = StringUtils.split(code, "\n"); + + for (String line : lines) { + interpretLine(line, ambient); + } + } + + private void interpretLine(String code, ShapeAmbient ambient) throws CodeException { + code = code.trim(); + + if (code.startsWith(CREATE_KEYWORD)) { + processCreateShape(code, ambient); + } else if (code.startsWith(SET_COLOR_KEYWORD)) { + processSetColor(code, ambient); + } else if (code.startsWith(SET_BASE_KEYWORD)) { + processSetBase(code, ambient); + } else { + throw new CodeException("Unexpected code."); + } + } + + private void processSetBase(String code, ShapeAmbient ambient) throws CodeException { + Matcher matcher = setbasePatternInRectangle.matcher(code); + + if (matcher.find()) { + int base = Integer.parseInt(matcher.group(1)); + String id = matcher.group(2); + + if (ambient.contains(id)) { + Rectangle rectangle = (Rectangle) ambient.get(id); + rectangle.setBase(base); + } else { + throw new CodeException("Id " + id + " does not exist."); + } + } else { + throw new CodeException("Unexpected code"); + } + } + + private void processSetColor(String code, ShapeAmbient ambient) throws CodeException { + Matcher matcher = setColorPattern.matcher(code); + + if (matcher.find()) { + String colorDef = matcher.group(1); + String id = matcher.group(2); + + if (ambient.contains(id)) { + Shape shape = ambient.get(id); + shape.setColor(ColorUtils.color(colorDef)); + } else { + throw new CodeException("Unrecognized identifier"); + } + } else { + throw new CodeException("Unexpected code"); + } + } + + private void processCreateShape(String code, ShapeAmbient ambient) throws CodeException { + Matcher matcher = createPattern.matcher(code); + + if (matcher.find()) { + String type = matcher.group(1); + String id = matcher.group(2); + + Shape shape = createShape(type, id); + if (ambient.contains(id)) { + throw new CodeException("Id " + id + " already exists."); + } else { + ambient.add(shape); + } + } else { + throw new CodeException("Unrecognized identifier"); + } + } + + private Shape createShape(String type, String id) throws CodeException { + switch (type) { + case "shape": + return ShapeUtils.shape(id); + case "rectangle": + return ShapeUtils.rectangle(id); + case "circle": + return ShapeUtils.circle(id); + default: + throw new CodeException("Shape type does not exist"); + } + } + + @Override + public void interpret(InputStream stream, ShapeAmbient ambient) throws CodeException, IOException { + this.interpret(IOUtils.toString(stream), ambient); + } + +} diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/model/AST.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/AST.java index 91aed7c..a67acba 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/model/AST.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/AST.java @@ -12,6 +12,25 @@ * */ public class AST { + + public Token token; + public int linea; + + public Token getToken() { + return token; + } + + public void setToken(Token token) { + this.token = token; + } + + public int getLinea() { + return linea; + } + + public void setLinea(int linea) { + this.linea = linea; + } /** * The {@link AST} children. diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Figura.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Figura.java new file mode 100644 index 0000000..b8b834f --- /dev/null +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Figura.java @@ -0,0 +1,32 @@ +package edu.maimonides.multimedia.shapes4learn.model; + +public class Figura { + + public String id; + public String clase; + + + + public String getId() { + return id; + } + + + + public void setId(String id) { + this.id = id; + } + + + + public String getClase() { + return clase; + } + + + + public void setClase(String clase) { + this.clase = clase; + } + +} diff --git a/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Token.java b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Token.java index 9c5f672..7bda945 100644 --- a/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Token.java +++ b/src/main/java/edu/maimonides/multimedia/shapes4learn/model/Token.java @@ -10,6 +10,30 @@ */ public class Token { - // To be implemented. + public String lexema; + public String clase; + + public String getLexema() { + return lexema; + } + public void setLexema(String lexema) { + this.lexema = lexema; + } + public String getClase() { + return clase; + } + public void setClase(String clase) { + this.clase = clase; + } + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Lexema: "); + sb.append(lexema); + sb.append(" ||| Clase: "); + sb.append(clase); + sb.append("\n"); + return sb.toString(); + } } diff --git a/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java b/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java index ae31791..e4630f1 100644 --- a/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java +++ b/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/RegexInterpreter.java @@ -21,7 +21,7 @@ * @author Matias Giorgio. * */ -public class RegexInterpreter implements Interpreter { +/*public class RegexInterpreter implements Interpreter { private static final String NUMBER_PATTERN = "\\d+"; private static final String SHAPE_TYPE_PATTERN = "[a-zA-Z]+"; @@ -136,4 +136,4 @@ public void interpret(InputStream stream, ShapeAmbient ambient) throws CodeExcep this.interpret(IOUtils.toString(stream), ambient); } -} +}*/ diff --git a/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/TestLexicalAnalizer.java b/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/TestLexicalAnalizer.java new file mode 100644 index 0000000..828232d --- /dev/null +++ b/src/test/java/edu/maimonides/multimedia/shapes4learn/interpreter/TestLexicalAnalizer.java @@ -0,0 +1,221 @@ +package edu.maimonides.multimedia.shapes4learn.interpreter; + +import static org.junit.Assert.*; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import org.junit.Test; +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalAnalyzer; +import edu.maimonides.multimedia.shapes4learn.analysis.LexicalException; +import edu.maimonides.multimedia.shapes4learn.model.Token; + +public class TestLexicalAnalizer { + + @Test + public void test() { + + String code1 = "create circle micirculo ; " + + "setradius 5 + 5 in circle micirculo ; " + + "setcolor #aA1234 in shape micirculo ;"; + + //String code1 = "create"; + + List tokenValida = new LinkedList<>(); + + LexicalAnalyzer lex = new LexicalAnalyzer(); + + try { + + List tokens = lex.analyze(code1); + + System.out.println(" TestLexicalAnalizer: \n"); + //Inicializar prueba 1 + Token tok = new Token(); + tok.setLexema("create");tok.setClase("crear");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("circle");tok.setClase("ShapeCirculo");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("micirculo");tok.setClase("ID");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(";");tok.setClase("fin de sentancia");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("setradius");tok.setClase("setear radio");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("5");tok.setClase("Numero");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("+");tok.setClase("Adicion");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("5");tok.setClase("Numero");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("in");tok.setClase("'in'");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("circle");tok.setClase("ShapeCirculo");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("micirculo");tok.setClase("ID");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(";");tok.setClase("fin de sentencia");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("setcolor");tok.setClase("setear color");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("#aA1234");tok.setClase("color_def");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("in");tok.setClase("in");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("shape");tok.setClase("clase shape");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("micirculo");tok.setClase("ID");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(";");tok.setClase("fin de sentancia");tokenValida.add(tok); + + boolean soniguales = false; + + for (int i = 0; i < tokens.size() || i < tokenValida.size(); i++) { + + if (tokens.get(i).getLexema().equals(tokenValida.get(i).getLexema()) + && tokens.get(i).getClase().equals(tokenValida.get(i).getClase())) { + + soniguales=true; + } + } + + assertTrue("Lexema Correcto ", soniguales); + + for (Iterator iterator = tokens.iterator(); iterator.hasNext();) { + Token token = (Token) iterator.next(); + System.out.println("Lexema: " + token.lexema + " Clase: " + token.clase); + } + + }catch(LexicalException e) { + // TODO Auto-generated catch block + fail("Lanzada excepcion no esperada Tokeb caso 1"); + e.printStackTrace(); + } + + } + + @Test + public void test2() { + + String code1 = "create cir4cle micirculo ; #"; + + List tokenValida = new LinkedList<>(); + + LexicalAnalyzer lex = new LexicalAnalyzer(); + + try { + + List tokens = lex.analyze(code1); + + System.out.println("\n"); + System.out.println(" TestLexicalAnalizer: \n"); + + //Inicializar prueba 2 + Token tok = new Token(); + tok.setLexema("create");tok.setClase("crear");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("cir4cle");tok.setClase("Lexema desconocido");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("micirculo");tok.setClase("ID");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(";");tok.setClase("fin de sentancia");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("#");tok.setClase("Lexema desconocido");tokenValida.add(tok); + + boolean soniguales = false; + + for (int i = 0; i < tokens.size() || i < tokenValida.size(); i++) { + + if (tokens.get(i).getLexema().equals(tokenValida.get(i).getLexema()) + && tokens.get(i).getClase().equals(tokenValida.get(i).getClase())) { + + soniguales=true; + } + } + + assertTrue("Lexema Correcto ", soniguales); + + + for (Iterator iterator = tokens.iterator(); iterator.hasNext();) { + Token token = (Token) iterator.next(); + System.out.println("Lexema: " + token.lexema + " Clase: " + token.clase); + } + + }catch(LexicalException e) { + // TODO Auto-generated catch block + fail("Lanzada excepcion no esperada Tokeb caso 1"); + e.printStackTrace(); + } + + } + + @Test + public void test3() { + + String code1 = "setradius ( 5 + 5 ) * 3 in circle micirculo ;"; + + List tokenValida = new LinkedList<>(); + + LexicalAnalyzer lex = new LexicalAnalyzer(); + + try { + + List tokens = lex.analyze(code1); + + System.out.println("\n"); + System.out.println(" TestLexicalAnalizer: \n"); + + //Inicializar prueba 3 + Token tok = new Token(); + tok.setLexema("setradius");tok.setClase("setear radio");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("(");tok.setClase("Parentesis de Apertura");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("5");tok.setClase("Numero");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("+");tok.setClase("Adicion");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("5");tok.setClase("Numero");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(")");tok.setClase("Parentesis de Apertura");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("*");tok.setClase("Producto");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("3");tok.setClase("Numero");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("in");tok.setClase("`in`");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("circle");tok.setClase("ShapeCirculo");tokenValida.add(tok); + tok = new Token(); + tok.setLexema("micirculo");tok.setClase("ID");tokenValida.add(tok); + tok = new Token(); + tok.setLexema(";");tok.setClase("fin de sentancia");tokenValida.add(tok); + + boolean soniguales = false; + + for (int i = 0; i < tokens.size() || i < tokenValida.size(); i++) { + + if (tokens.get(i).getLexema().equals(tokenValida.get(i).getLexema()) + && tokens.get(i).getClase().equals(tokenValida.get(i).getClase())) { + + soniguales=true; + } + } + + assertTrue("Lexema Correcto ", soniguales); + + + for (Iterator iterator = tokens.iterator(); iterator.hasNext();) { + Token token = (Token) iterator.next(); + System.out.println("Lexema: " + token.lexema + " Clase: " + token.clase); + } + + }catch(LexicalException e) { + // TODO Auto-generated catch block + fail("Lanzada excepcion no esperada Tokeb caso 1"); + e.printStackTrace(); + } + + } + +}