diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1b2954b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/dist/
+/build/
+/store
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..89a22f1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+## PG EDITOR
+
+Project developed in 2014
+
+![1](icons/image.png?raw=true "1")
+
+https://sourceforge.net/projects/portugol-editor/
diff --git a/SyntaxPane/.gitignore b/SyntaxPane/.gitignore
new file mode 100644
index 0000000..08bc1a3
--- /dev/null
+++ b/SyntaxPane/.gitignore
@@ -0,0 +1,6 @@
+target/
+lib_managed/
+src_managed/
+project/boot/
+.idea/
+.idea_modules/
diff --git a/SyntaxPane/CHANGELOG.txt b/SyntaxPane/CHANGELOG.txt
new file mode 100644
index 0000000..eb90417
--- /dev/null
+++ b/SyntaxPane/CHANGELOG.txt
@@ -0,0 +1,106 @@
+Version 1.1.3
+ * Fixes various issues with line-numbers-ruler
+ * Fixes some keyboard shortcuts on Mac and Linux
+ * Fixes a NPE when not using scroll-pane
+ * Fixes a bug with undo-buffer and copy/paste
+
+Version 1.1.0
+ * Rename to SyntaxPane
+ * Use fully qualified package name de.sciss.syntaxpane
+ * Enabling/disabling of Undo/Redo actions
+ * Fix multiple OS X shortcuts
+ * Fix some Scala related problems
+ * All tracking of document's dirty state
+
+Original JSyntaxPane Changelog:
+
+Version 0.9.5 - Java Reflection Completions additions
+ * Configuration class overhaul. Each kit now has its own Configuration file
+ which merges the superclass(es) Configurations.
+ * Usable Reflect Completions Dialog (Java with F1 or Menu)
+ * Java ENTER key responds properly to multi line comments
+ * Font can be changed for each Kit
+ * Kits for XHTML and Xpath added. XHTML has a simple Preview Action.
+ * Added Execute Script to JavaScript (can also be used for Groovy if Groovy
+ Scripting support is installed properly).
+ * Hotkeys for actions are displayed in Popup Menus
+ * Word Completion action can also do CamelCase matches
+ * Smart Home Action (and Smart Home Extend Selection)
+ * Enhanced JavaScript support. Issue 115
+ * Better Undo grouping
+ * Replace Dialog Enhancement. Only for updatedable editors and added single replace.
+ * Added append method to SyntaxDocument
+ * Fixed Issue 130 - Compound Undo on multiple lines.
+Version 0.9.4 - IntelliSense additions
+ * Adding IntelliSense to Java with simple List of selectable keywords
+ * Added Toggle Comment Actions using Control SLASH
+ * Fixed Issue 47.
+ * Added Clojure, Scala, DOS Batch and 'nix bash support
+ * Added Configurable Popup menus with default Tango Desktop icons
+ * Added configurable format for the CaretMonitor class
+ * Toggle Comments Action selects the lines affected after being performed
+ * Added multi-line support in ActionUtils.insertMagicString method.
+ * GotoLine dialog responds to ESC key
+Version 0.9.3 - Start of scripts for the document:
+ * Added new methods getLine() to SyntaxDocument
+ * SyntaxDocument getIndexOf methods deprecated, use getMatchers instead
+ * Added Line Numbering to Java
+ * Added CaretMonitor Class
+ * Merged Find And Replace dialogs into one.
+ * Created SyntaxComponent interface and have all UI components implement
+ that interface. DefaultSyntaxKit will use config.properties class to
+ dynamically install these components.
+ * Added Right Margin option and Single Color Selection Options
+ * Added Python, C and C++ Support
+ * Added Ruby Syntax Support
+ * Fixed Issue 37 (NPE for LineNumbersRuler)
+ * Fixed Issue 39 (Highlighting Tokens overrides selection highlights)
+ * Fixed some JavaDoc comments.
+ * Fixed Line Numbers being displayed for the height of the editor and now
+ just for the actual available lines.
+ * Fixed Margin typo in all project. Issue 43
+ * Changing Actions to be more configurable:
+ * SyntaxActions renamed to ActionUtils
+ * Removed all inner classes from SyntaxActions
+ * Will create new SyntaxAction interface that will allow dynamic addition
+ actions (in the addKeyActions of DefaultSyntaxKit
+ * Added Text AA property to SyntaxView
+Version 0.9.2:
+ * Fixing Java Indentation and Un-Indentation Actions
+ * Added and used (in the Tester) clearUndoes on the SyntaxDocument
+ * Added Basic JFlex Syntax
+ * Added getContentTypes to DefaultSyntaxKit to get all registered
+ ContentTypes. This is now also used in the SyntaxTester instead of
+ hardcoding the types.
+ * Cleanup and optimization of Lexers by removing duplicate Java Code
+ (replaced with Regex OR)
+ * Removed calls to deprecated calls in SyntaxView
+ * Modified the SyntaxDOcument to override the fireXXX methods and parse
+ the document at that time instead of overriding the inserUpdate method.
+ This fixes issue 24.
+ * Added Groovy GString expression highlights
+ * Removed getLanguages method from Lexer interface and implementations.
+ * Added WARNING and ERROR TokenTypes and added their default styles.
+ * Moved Keymaps and install methods to SyntaxKits instead of the Lexers
+ * Removed deprecated methods from SyntaxActions class
+ * Split SyntaxActions into new package and moved inner classes to the new
+ package
+ * Added Token HighLighter to Java
+ * Added Pairs Highlighter to Java
+ * Token class made immutable (all final fields)
+ * Added Find and Replace Dialogs and Action to Java (mapped to C-F and
+ C-H )
+ * Added pair matching to XML tags
+ * Added CDATA matching and pair highlights for XML
+ * Added Comment Pair Highlighting in XML
+ * Fixed highlighting with selections so the selection always appears
+ * Merged Find and Replace Dialogs into one
+ * Fixed issue 33 (undoable to add new line after final closing brace for
+ Java)
+ * Added Groovy Multi-Line strings and fixed Comments as Regex issue.
+ * Fixes to empty find text field causing NPE
+Version 0.9.1
+ * Fixed empty strings in XML syntax Issue 29
+ * Fixed TAL lexer using incorrect package name
+Version 0.9.0
+ * Initial version after major overhaul
\ No newline at end of file
diff --git a/SyntaxPane/README.md b/SyntaxPane/README.md
new file mode 100644
index 0000000..dce4a53
--- /dev/null
+++ b/SyntaxPane/README.md
@@ -0,0 +1,22 @@
+# SyntaxPane
+
+SyntaxPane is an extension to Java Swing's JEditorKit component which adds syntax highlighting support for various languages, including Scala and Java. The original project JSyntaxPane can be found [on google-code](http://code.google.com/p/jsyntaxpane/). This is a fork from the 0.9.6 branch.
+
+The original project is (C)opyright by Ayman Al-Sairafi and released under the [Apache License, Version 2.0](http://github.com/Sciss/JSyntaxPane/blob/master/licenses/JSyntaxPane-License.txt).
+
+All changes, reworkings and extensions in SyntaxPane (C)opyright 2011–2014 by Hanns Holger Rutz. Released under that same license.
+
+## linking
+
+The group-id and version have been adjusted to use my name space at Maven Central:
+
+ "de.sciss" % "syntaxpane" % v
+
+The current version `v` is `"1.1.3"`
+
+## building
+
+JSyntaxPane builds with sbt 0.13. The source code is purely Java at the moment, so no Scala compilation is run. The project uses the [sbt-jflex](https://github.com/sbt/sbt-jflex) plugin v0.1-SNAPSHOT, which in turn uses [JFlex](http://jflex.de/) 1.4.3 to generate the lexer Java sources for the supported languages.
+
+To build run `sbt compile`. To run a demo application, run `sbt run`.
+
diff --git a/SyntaxPane/build.sbt b/SyntaxPane/build.sbt
new file mode 100644
index 0000000..85cdcbe
--- /dev/null
+++ b/SyntaxPane/build.sbt
@@ -0,0 +1,56 @@
+name := "SyntaxPane"
+
+version := "1.1.4-SNAPSHOT"
+
+organization := "de.sciss"
+
+description := "An extension of Java Swing's JEditorKit that supports syntax highlighting for several languages."
+
+homepage := Some(url("https://github.com/Sciss/" + name.value))
+
+licenses := Seq("Apache 2.0 License" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
+
+scalaVersion := "2.11.2"
+
+crossPaths := false // this is just a Java project right now!
+
+// retrieveManaged := true
+
+autoScalaLibrary := false
+
+mainClass in Compile := Some("de.sciss.syntaxpane.SyntaxTester")
+
+javacOptions in (Compile, compile) ++= Seq("-g", "-source", "1.6", "-target", "1.6")
+
+// ---- JFlex ----
+
+seq(jflexSettings: _*)
+
+// ---- publishing ----
+
+publishMavenStyle := true
+
+publishTo :=
+ Some(if (isSnapshot.value)
+ "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
+ else
+ "Sonatype Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
+ )
+
+publishArtifact in Test := false
+
+pomIncludeRepository := { _ => false }
+
+pomExtra := { val n = name.value
+Lexer
s we have.
+ * You can call this at initialization, or it will be called when needed.
+ * The method will also add the appropriate EditorKit classes to the
+ * corresponding ContentType of the JEditorPane. After this is called,
+ * you can simply call the editor.setContentType("text/java") on the
+ * control and you will be done.
+ */
+ public synchronized static void initKit() {
+ // attempt to find a suitable default font
+ String defaultFont = getConfig(DefaultSyntaxKit.class).getString("DefaultFont");
+ if (defaultFont != null) {
+ DEFAULT_FONT = Font.decode(defaultFont);
+ } else {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ String[] fonts = ge.getAvailableFontFamilyNames();
+ Arrays.sort(fonts);
+ if (Arrays.binarySearch(fonts, "Courier New") >= 0) {
+ DEFAULT_FONT = new Font("Courier New", Font.PLAIN, 12);
+ } else if (Arrays.binarySearch(fonts, "Courier") >= 0) {
+ DEFAULT_FONT = new Font("Courier", Font.PLAIN, 12);
+ } else if (Arrays.binarySearch(fonts, "Monospaced") >= 0) {
+ DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 13);
+ }
+ }
+
+ // read the Default Kits and their associated types
+ Properties kitsForTypes = JarServiceProvider.readProperties("de/sciss/syntaxpane/kitsfortypes");
+ for (Map.Entry e : kitsForTypes.entrySet()) {
+ String type = e.getKey().toString();
+ String className = e.getValue().toString();
+ registerContentType(type, className);
+ }
+ initialized = true;
+ }
+
+ /**
+ * Registers the given content type to use the given class name as its kit
+ * When this is called, an entry is added into the private HashMap of the
+ * registered editors kits. This is needed so that the SyntaxPane library
+ * has it's own registration of all the EditorKits
+ */
+ public static void registerContentType(String type, String className) {
+ try {
+ // ensure the class is available and that it does supply a no args
+ // constructor. This saves debugging later if the class-name is incorrect
+ // or does not behave correctly:
+ Class c = Class.forName(className);
+ // attempt to create the class, if we cannot with an empty argument
+ // then the class is invalid
+ Object kit = c.newInstance();
+ if (!(kit instanceof EditorKit)) {
+ throw new IllegalArgumentException("Cannot register class: " + className +
+ ". It does not extend EditorKit");
+ }
+ JEditorPane.registerEditorKitForContentType(type, className);
+ CONTENT_TYPES.add(type);
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException("Cannot register class: " + className +
+ ". Ensure it has Default Constructor.", ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException("Cannot register class: " + className, ex);
+ } catch (ClassNotFoundException ex) {
+ throw new IllegalArgumentException("Cannot register class: " + className, ex);
+ } catch (RuntimeException ex) {
+ throw new IllegalArgumentException("Cannot register class: " + className, ex);
+ }
+ }
+
+ /**
+ * Return all the content types supported by this library. This will be the
+ * content types in the file WEB-INF/services/resources/de/sciss/syntaxpane/kitsfortypes
+ * @return sorted array of all registered content types
+ */
+ public static String[] getContentTypes() {
+ String[] types = CONTENT_TYPES.toArray(new String[0]);
+ Arrays.sort(types);
+ return types;
+ }
+
+ /**
+ * Merges the given properties with the configurations for this Object
+ */
+ public void setConfig(Properties config) {
+ getConfig().putAll(config);
+ }
+
+ /**
+ * Sets the given property to the given value. If the kit is not
+ * initialized, then calls initKit
+ */
+ public void setProperty(String key, String value) {
+ getConfig().put(key, value);
+ }
+
+ /**
+ * Return the property with the given key. If the kit is not
+ * initialized, then calls initKit
+ * Be careful when changing property as the default property may be used
+ *
+ * @return value for given key
+ */
+ public String getProperty(String key) {
+ return getConfig().getString(key);
+ }
+
+ /**
+ * Gets the configuration for this Object
+ */
+ public Configuration getConfig() {
+ return getConfig(this.getClass());
+ }
+
+ /**
+ * Returns the Configurations object for a Kit. Perform lazy creation of a
+ * Configuration object if nothing is created.
+ */
+ public static synchronized Configuration getConfig(Class extends DefaultSyntaxKit> kit) {
+ if (CONFIGS == null) {
+ CONFIGS = new WeakHashMapstart
+ *
+ * @return matcher that MUST be offset by start to get the proper
+ * location within the document
+ */
+ public Matcher getMatcher(Pattern pattern, int start) {
+ return getMatcher(pattern, start, getLength() - start);
+ }
+
+ /**
+ * Returns a matcher that matches the given pattern in the part of the
+ * document starting at offset start and ending at start + length.
+ * Note that the matcher will have
+ * offset starting from start
+ *
+ * @return matcher that MUST be offset by start to get the proper location within the document
+ */
+ public Matcher getMatcher(Pattern pattern, int start, int length) {
+ Matcher matcher = null;
+ if (getLength() == 0) {
+ return null;
+ }
+ if (start >= getLength()) {
+ return null;
+ }
+ try {
+ if (start < 0) {
+ start = 0;
+ }
+ if (start + length > getLength()) {
+ length = getLength() - start;
+ }
+ Segment seg = new Segment();
+ getText(start, length, seg);
+ matcher = pattern.matcher(seg);
+ } catch (BadLocationException ex) {
+ log.log(Level.SEVERE, "Requested offset: " + ex.offsetRequested(), ex);
+ }
+ return matcher;
+ }
+
+ /**
+ * Gets the line at given position. The line returned will NOT include
+ * the line terminator '\n'
+ * @param pos Position (usually from text.getCaretPosition()
+ * @return the STring of text at given position
+ * @throws BadLocationException
+ */
+ public String getLineAt(int pos) throws BadLocationException {
+ Element e = getParagraphElement(pos);
+ Segment seg = new Segment();
+ getText(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), seg);
+ char last = seg.last();
+ if (last == '\n' || last == '\r') {
+ seg.count--;
+ }
+ return seg.toString();
+ }
+
+ /**
+ * Deletes the line at given position
+ *
+ * @throws javax.swing.text.BadLocationException
+ */
+ public void removeLineAt(int pos)
+ throws BadLocationException {
+ Element e = getParagraphElement(pos);
+ remove(e.getStartOffset(), getElementLength(e));
+ }
+
+ /**
+ * Replaces the line at given position with the given string, which can span
+ * multiple lines
+ *
+ * @throws javax.swing.text.BadLocationException
+ */
+ public void replaceLineAt(int pos, String newLines)
+ throws BadLocationException {
+ Element e = getParagraphElement(pos);
+ replace(e.getStartOffset(), getElementLength(e), newLines, null);
+ }
+
+ /*
+ * Helper method to get the length of an element and avoid getting
+ * a too long element at the end of the document
+ */
+ private int getElementLength(Element e) {
+ int end = e.getEndOffset();
+ if (end >= (getLength() - 1)) {
+ end--;
+ }
+ return end - e.getStartOffset();
+ }
+
+ /**
+ * Gets the text without the comments. For example for the string
+ * { // it's a comment
this method will return "{ ".
+ * @param aStart start of the text.
+ * @param anEnd end of the text.
+ * @return String for the line without comments (if exists).
+ */
+ public synchronized String getUncommentedText(int aStart, int anEnd) {
+ readLock();
+ StringBuilder result = new StringBuilder();
+ Iteratorclass_path
will be replaced by the name of the
+ * Configuration (usually ClassName) with "." replaced by "/", and then
+ * converted to all lowercaseclass_simpleName
The read(data)
method for class {@link ByteBufferQueue}
+ * has the same effect as:
read(data, 0, data.length)
+ * @param data byte array, where will be read bytes stored
+ * @return count of read bytes
+ */
+ public int read(byte[] data) {
+ if (data != null) {
+ return read(data, 0, data.length);
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Reads up to length
bytes of data from the buffer into an array of
+ * bytes. An attempt is made to read as many as length
bytes, but a
+ * smaller number may be read, possibly zero. The number of bytes actually read is
+ * returned as an integer.
+ *
+ * @param data byte array, where will be read bytes stored
+ * @param offset the start offset in array data
at which the data is written.
+ * @param length the maximum number of bytes to read
+ * @return the total number of bytes read into the buffer
+ */
+ public int read(byte[] data, int offset, int length) {
+ if (data == null) {
+ return 0;
+ }
+ if (data.length < offset + length) {
+ throw new RuntimeException("array index out of bounds. offset + length extends beyond the length of the array.");
+ }
+
+ int readlength = 0;
+
+ try {
+ readsem.acquire();
+ } catch (InterruptedException e) {
+ return 0;
+ }
+
+ // We need to acquire the semaphore so that this.head doesn't change.
+ for (int i = 0; i < length; i++) {
+ if (i == count) {
+ break;
+ }
+ data[i + offset] = buff[(i + head) % this.size];
+ readlength++;
+ }
+
+ this.head = (readlength + this.head) % this.size;
+
+ try {
+ countsem.acquire();
+ } catch (InterruptedException e) {
+ readsem.release();
+ return 0;
+ }
+
+ // We need to acquire the semaphore so that this.count doesn't change.
+ this.count = this.count - readlength;
+
+ countsem.release();
+ readsem.release();
+
+ return readlength;
+ }
+
+ /**
+ * Reads some number of bytes from the input stream and stores them into
+ * the array data
. After the reading, read bytes remain in the
+ * buffer. The number of bytes actually read is returned as an integer.
+ *
+ * The peak(data)
method for class {@link ByteBufferQueue}
+ * has the same effect as:
peak(data, 0, data.length)
+ * @param data byte array, where will be read bytes stored
+ * @return count of read bytes
+ */
+ public int peek(byte[] data) {
+ if (data != null) {
+ return peek(data, 0, data.length);
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Reads up to length
bytes of data from the buffer into an array of
+ * bytes. After the reading, read bytes remain in the buffer. An attempt is made to
+ * read as many as length
bytes, but a smaller number may be read,
+ * possibly zero. The number of bytes actually read is returned as an integer.
+ *
+ * @param data byte array, where will be read bytes stored
+ * @param offset the start offset in array data
at which the data is written.
+ * @param length the maximum number of bytes to read
+ * @return the total number of bytes read into the buffer
+ */
+ public int peek(byte[] data, int offset, int length) {
+ if (data == null) {
+ return 0;
+ }
+
+ if (data.length < offset + length) {
+ throw new RuntimeException("array index out of bounds. offset + length extends beyond the length of the array.");
+ }
+
+ int readlength = 0;
+
+ try {
+ readsem.acquire();
+ } catch (InterruptedException e) {
+ return 0;
+ }
+
+ // We need to acquire the semaphore so that this.head doesn't change.
+ for (int i = 0; i < length; i++) {
+ if (i == count) {
+ break;
+ }
+ data[i + offset] = buff[(i + head) % this.size];
+ readlength++;
+ }
+
+ readsem.release();
+
+ return readlength;
+ }
+
+ /**
+ * Read the whole buffer a return it as byte array.
+ * @return array of bytes
+ */
+ public byte[] readBytes() {
+
+ byte[] data = new byte[count];
+ try {
+ read(data);
+ } catch (Exception ex) {
+ }
+ return data;
+ }
+}
\ No newline at end of file
diff --git a/Test/br/com/console/CaretConsole.java b/Test/br/com/console/CaretConsole.java
new file mode 100644
index 0000000..2bbf625
--- /dev/null
+++ b/Test/br/com/console/CaretConsole.java
@@ -0,0 +1,90 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package br.com.console;
+
+/**
+ *
+ * @author SIMONETO-2
+ */
+// CornerCaret.java
+// A custom caret class.
+//
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultCaret;
+import javax.swing.text.JTextComponent;
+
+public class CaretConsole extends DefaultCaret {
+
+ //private String mark = "<";
+ public CaretConsole() {
+ setBlinkRate(500);
+ }
+
+ @Override
+ protected synchronized void damage(Rectangle r) {
+ if (r == null) {
+ return;
+ }
+
+ JTextComponent comp = getComponent();
+ FontMetrics fm = comp.getFontMetrics(comp.getFont());
+ int textWidth = fm.stringWidth(">");
+ int textHeight = fm.getHeight();
+ x = r.x;
+ y = r.y;
+ width = textWidth;
+ height = textHeight;
+ repaint(); // calls getComponent().repaint(x, y, width, height)
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ JTextComponent comp = getComponent();
+ if (comp == null) {
+ return;
+ }
+
+ int dot = getDot();
+ Rectangle r = null;
+ try {
+ r = comp.modelToView(dot);
+ } catch (BadLocationException e) {
+ return;
+ }
+ if (r == null) {
+ return;
+ }
+
+ if ((x != r.x) || (y != r.y)) {
+ repaint(); // erase previous location of caret
+ damage(r);
+ }
+
+ if (isVisible()) {
+ FontMetrics fm = comp.getFontMetrics(comp.getFont());
+ int textWidth = fm.stringWidth(">");
+ int textHeight = fm.getHeight();
+
+ g.setColor(comp.getCaretColor());
+ g.fillRect(r.x, r.y, 8, r.height);
+ }
+ }
+
+ @Override
+ public void mousePressed(MouseEvent evt) {
+ evt.consume();
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ e.consume();
+ }
+
+}
diff --git a/Test/br/com/console/Console.form b/Test/br/com/console/Console.form
new file mode 100644
index 0000000..aea8432
--- /dev/null
+++ b/Test/br/com/console/Console.form
@@ -0,0 +1,80 @@
+
+
+
diff --git a/Test/br/com/console/Console.java b/Test/br/com/console/Console.java
new file mode 100644
index 0000000..7e1c4b1
--- /dev/null
+++ b/Test/br/com/console/Console.java
@@ -0,0 +1,129 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package br.com.console;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+import com.forms.Editor;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Andrew
+ */
+public class Console extends javax.swing.JFrame {
+ //public static JConsole JConsole = new JConsole();
+ public static Thread codeEXEC;
+ public static ConsoleIO _console;
+
+ /**
+ * Creates new form Console
+ */
+ public Console() {
+ initComponents();
+ }
+
+ static void t() {
+ codeEXEC = new Thread() {
+ @Override
+ public void run() {
+ try {
+ _console.print("Digite seu nome: ");
+ String nome = _console.writeString();
+ _console.print("Qua a sua idade: ");
+ int idade = _console.writeInt();
+ _console.print("Qua a sua massa: ");
+ float massa = _console.writeFloat();
+ _console.print("Seu nome é " + nome + ", sua idade " + idade + ", sua massa " + massa);
+ } catch (Exception ex) {
+ Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ };
+ codeEXEC.start();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\1\11\4\1\2\0\1\11\2\1"+
+ "\1\0\1\1\1\0\15\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[29];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 108) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 6: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 7: break;
+ case 3:
+ { /* IGNORE */
+ }
+ case 8: break;
+ case 4:
+ { return newSym(sym.STRING, yytext().substring(1, yylength()-1));
+ }
+ case 9: break;
+ case 5:
+ { return newSym(sym.ALGORITMO,yytext());
+ }
+ case 10: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/algoritmoName/Yylex.java~ b/Test/com/analizador/algoritmoName/Yylex.java~
new file mode 100644
index 0000000..2cb5f5b
--- /dev/null
+++ b/Test/com/analizador/algoritmoName/Yylex.java~
@@ -0,0 +1,665 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+package com.analizador.exe_expressao;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/Andrew/Documents/NetBeansProjects/portugol-projeto/Test/com/analizador/algoritmoName/AlgoritmoName.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\3\1\6\1\30\1\30\1\7\22\0\1\3\1\0\1\5"+
+ "\15\0\12\2\7\0\1\20\5\1\1\22\1\1\1\25\2\1\1\21"+
+ "\1\27\1\1\1\23\2\1\1\24\1\1\1\26\6\1\1\0\1\4"+
+ "\2\0\1\2\1\0\1\10\5\1\1\12\1\1\1\15\2\1\1\11"+
+ "\1\17\1\1\1\13\2\1\1\14\1\1\1\16\6\1\12\0\1\30"+
+ "\u1fa2\0\1\30\1\30\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\1\3\1\1\1\3\2\2\2\0"+
+ "\1\4\2\2\1\0\1\4\1\0\14\2\1\5";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[29];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\31\0\62\0\31\0\113\0\144\0\175\0\226"+
+ "\0\113\0\257\0\31\0\310\0\341\0\372\0\113\0\u0113"+
+ "\0\u012c\0\u0145\0\u015e\0\u0177\0\u0190\0\u01a9\0\u01c2\0\u01db"+
+ "\0\u01f4\0\u020d\0\u0226\0\u023f\0\62";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[29];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\2\1\4\1\2\1\5\1\4\1\6"+
+ "\1\7\7\3\1\10\7\3\33\0\2\3\5\0\20\3"+
+ "\1\0\4\11\1\12\1\13\2\0\21\11\6\0\1\4"+
+ "\23\0\2\3\5\0\1\3\1\14\16\3\2\0\2\3"+
+ "\5\0\11\3\1\15\6\3\1\0\3\11\1\16\1\12"+
+ "\1\17\2\20\21\11\1\0\2\3\5\0\2\3\1\21"+
+ "\15\3\2\0\2\3\5\0\12\3\1\22\5\3\1\0"+
+ "\3\11\1\16\1\12\1\13\2\20\21\11\3\0\1\20"+
+ "\1\11\1\0\2\20\22\0\2\3\5\0\3\3\1\23"+
+ "\14\3\2\0\2\3\5\0\13\3\1\24\4\3\2\0"+
+ "\2\3\5\0\4\3\1\25\13\3\2\0\2\3\5\0"+
+ "\14\3\1\26\3\3\2\0\2\3\5\0\5\3\1\27"+
+ "\12\3\2\0\2\3\5\0\15\3\1\30\2\3\2\0"+
+ "\2\3\5\0\6\3\1\31\11\3\2\0\2\3\5\0"+
+ "\16\3\1\32\1\3\2\0\2\3\5\0\7\3\1\33"+
+ "\10\3\2\0\2\3\5\0\17\3\1\34\2\0\2\3"+
+ "\5\0\3\3\1\35\14\3\2\0\2\3\5\0\13\3"+
+ "\1\35\4\3\1\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[600];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\1\11\4\1\2\0\1\11\2\1"+
+ "\1\0\1\1\1\0\15\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[29];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 108) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 6: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 7: break;
+ case 3:
+ { /* IGNORE */
+ }
+ case 8: break;
+ case 4:
+ { return newSym(sym.STRING, yytext().substring(1, yylength()-1));
+ }
+ case 9: break;
+ case 5:
+ { return newSym(sym.ALGORITMO,yytext());
+ }
+ case 10: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/algoritmoName/java_cup.jar b/Test/com/analizador/algoritmoName/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/algoritmoName/java_cup.jar differ
diff --git a/Test/com/analizador/algoritmoName/parser.java b/Test/com/analizador/algoritmoName/parser.java
new file mode 100644
index 0000000..8cc4f58
--- /dev/null
+++ b/Test/com/analizador/algoritmoName/parser.java
@@ -0,0 +1,198 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 21:54:45 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.algoritmoName;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Fri Jun 20 21:54:45 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\006\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\002\003\000\002\003\004\000\002\003\004" +
+ "" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\011\000\006\003\004\004\006\001\002\000\006\002" +
+ "\ufffe\004\ufffe\001\002\000\006\002\uffff\004\uffff\001\002" +
+ "\000\006\005\012\006\013\001\002\000\006\002\011\004" +
+ "\006\001\002\000\006\002\001\004\001\001\002\000\004" +
+ "\002\000\001\002\000\006\002\ufffd\004\ufffd\001\002\000" +
+ "\006\002\ufffc\004\ufffc\001\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\011\000\006\002\006\003\004\001\001\000\002\001" +
+ "\001\000\002\001\001\000\002\001\001\000\004\003\007" +
+ "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+ "\001\000\002\001\001" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // instanciacao ::= ALGORITMO STRING
+ {
+ Object RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Object e = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ System.out.println("String ALGORITMO = \""+e+"\";");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // instanciacao ::= ALGORITMO ID
+ {
+ Object RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Object e = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ System.out.println("String ALGORITMO = \""+e+"\";");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // algoritmo ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // algoritmo ::= instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= algoritmo EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // algoritmo ::= algoritmo instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/algoritmoName/sym.java b/Test/com/analizador/algoritmoName/sym.java
new file mode 100644
index 0000000..1219291
--- /dev/null
+++ b/Test/com/analizador/algoritmoName/sym.java
@@ -0,0 +1,18 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 21:54:45 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.algoritmoName;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int ID = 3;
+ public static final int STRING = 4;
+ public static final int error = 1;
+ public static final int ALGORITMO = 2;
+ public static final int EOF = 0;
+}
+
diff --git a/Test/com/analizador/exe_expressao/Exemplo.txt b/Test/com/analizador/exe_expressao/Exemplo.txt
new file mode 100644
index 0000000..44a475e
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/Exemplo.txt
@@ -0,0 +1 @@
+2+(5*2)+4;
\ No newline at end of file
diff --git a/Test/com/analizador/exe_expressao/Expressao.cup b/Test/com/analizador/exe_expressao/Expressao.cup
new file mode 100644
index 0000000..951fab0
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/Expressao.cup
@@ -0,0 +1,44 @@
+package com.analizador.exe_expressao;
+
+import java_cup.runtime.*;
+
+parser code
+{:
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+:}
+
+/* Terminals (tokens returned by the scanner). */
+terminal SEMI, PLUS, MINUS, TIMES, DIVIDE, MOD;
+terminal UMINUS, LPAREN, RPAREN;
+terminal Integer NUMBER;
+
+/* Non-terminals */
+non terminal expr_list, expr_part;
+non terminal Integer expr;
+
+/* Precedences */
+precedence left PLUS, MINUS;
+precedence left TIMES, DIVIDE, MOD;
+precedence left UMINUS;
+
+/* The grammar */
+expr_list ::= expr_list expr_part |
+ expr_part |
+ error {::} ;
+
+expr_part ::= expr:e SEMI {: System.out.println("= " + e); :};
+
+
+expr ::= expr:e1 PLUS expr:e2 {: RESULT = new Integer(e1.intValue() + e2.intValue()); :} |
+ expr:e1 MINUS expr:e2 {: RESULT = new Integer(e1.intValue() - e2.intValue()); :} |
+ expr:e1 TIMES expr:e2 {: RESULT = new Integer(e1.intValue() * e2.intValue()); :} |
+ expr:e1 DIVIDE expr:e2 {: RESULT = new Integer(e1.intValue() / e2.intValue()); :} |
+ expr:e1 MOD expr:e2 {: RESULT = new Integer(e1.intValue() % e2.intValue()); :} |
+ NUMBER:n {: RESULT = n; :} |
+ MINUS expr:e {: RESULT = new Integer(0 - e.intValue()); :} %prec UMINUS |
+ LPAREN expr:e RPAREN {: RESULT = e; :} ;
\ No newline at end of file
diff --git a/Test/com/analizador/exe_expressao/Expressao.flex b/Test/com/analizador/exe_expressao/Expressao.flex
new file mode 100644
index 0000000..f2ec872
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/Expressao.flex
@@ -0,0 +1,46 @@
+package com.analizador.exe_expressao;
+
+import java_cup.runtime.*;
+
+
+%%
+/*
+* LEXICAL FUNCTIONS:
+*/
+%cup
+%line
+%char
+%column
+
+%{
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+%}
+
+
+/*-*
+ * PATTERN DEFINITIONS:
+ */
+digit = [0-9]
+integer = {digit}+
+
+
+%%
+{integer} {return newSym(sym.NUMBER, new Integer(yytext()));}
+";" {return newSym(sym.SEMI);}
+"+" {return newSym(sym.PLUS);}
+"-" {return newSym(sym.MINUS);}
+"*" {return newSym(sym.TIMES);}
+"/" {return newSym(sym.DIVIDE);}
+"%" {return newSym(sym.MOD);}
+"(" {return newSym(sym.LPAREN);}
+")" {return newSym(sym.RPAREN);}
+<aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\10\11";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[11];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 50) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error);
+ }
+ case 11: break;
+ case 2:
+ { return newSym(sym.NUMBER, new Integer(yytext()));
+ }
+ case 12: break;
+ case 3:
+ { return newSym(sym.SEMI);
+ }
+ case 13: break;
+ case 4:
+ { return newSym(sym.PLUS);
+ }
+ case 14: break;
+ case 5:
+ { return newSym(sym.MINUS);
+ }
+ case 15: break;
+ case 6:
+ { return newSym(sym.TIMES);
+ }
+ case 16: break;
+ case 7:
+ { return newSym(sym.DIVIDE);
+ }
+ case 17: break;
+ case 8:
+ { return newSym(sym.MOD);
+ }
+ case 18: break;
+ case 9:
+ { return newSym(sym.LPAREN);
+ }
+ case 19: break;
+ case 10:
+ { return newSym(sym.RPAREN);
+ }
+ case 20: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/exe_expressao/Yylex.java~ b/Test/com/analizador/exe_expressao/Yylex.java~
new file mode 100644
index 0000000..0b6c252
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/Yylex.java~
@@ -0,0 +1,663 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+package com.analizador.expressao;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/Test/com/analizador/expressao/flex.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\12\0\1\12\1\12\1\12\1\12\27\0\1\7\2\0\1\10\1\11"+
+ "\1\5\1\3\1\0\1\4\1\0\1\6\12\1\1\0\1\2\111\0"+
+ "\1\12\u1fa2\0\1\12\1\12\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+
+ "\1\10\1\11\1\12";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[11];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\13\0\26\0\13\0\13\0\13\0\13\0\13"+
+ "\0\13\0\13\0\13";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[11];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11"+
+ "\1\12\1\13\15\0\1\3\11\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[33];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\10\11";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[11];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 50) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { System.out.println("Illegal char, '" + yytext() +"' line: " + yyline + ", column: " + yychar);
+ }
+ case 11: break;
+ case 2:
+ { return newSym(sym.NUMBER, new Integer(yytext()));
+ }
+ case 12: break;
+ case 3:
+ { return newSym(sym.SEMI);
+ }
+ case 13: break;
+ case 4:
+ { return newSym(sym.PLUS);
+ }
+ case 14: break;
+ case 5:
+ { return newSym(sym.MINUS);
+ }
+ case 15: break;
+ case 6:
+ { return newSym(sym.TIMES);
+ }
+ case 16: break;
+ case 7:
+ { return newSym(sym.DIVIDE);
+ }
+ case 17: break;
+ case 8:
+ { return newSym(sym.MOD);
+ }
+ case 18: break;
+ case 9:
+ { return newSym(sym.LPAREN);
+ }
+ case 19: break;
+ case 10:
+ { return newSym(sym.RPAREN);
+ }
+ case 20: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/exe_expressao/java_cup.jar b/Test/com/analizador/exe_expressao/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/exe_expressao/java_cup.jar differ
diff --git a/Test/com/analizador/exe_expressao/parser.java b/Test/com/analizador/exe_expressao/parser.java
new file mode 100644
index 0000000..66b78a8
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/parser.java
@@ -0,0 +1,325 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 14:14:23 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.exe_expressao;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Fri Jun 20 14:14:23 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\015\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\002\003\000\002\003\004\000\002\004\005" +
+ "\000\002\004\005\000\002\004\005\000\002\004\005\000" +
+ "\002\004\005\000\002\004\003\000\002\004\004\000\002" +
+ "\004\005" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\030\000\012\003\004\006\007\013\010\015\006\001" +
+ "\002\000\012\002\ufffe\006\ufffe\013\ufffe\015\ufffe\001\002" +
+ "\000\012\002\uffff\006\uffff\013\uffff\015\uffff\001\002\000" +
+ "\020\004\ufff7\005\ufff7\006\ufff7\007\ufff7\010\ufff7\011\ufff7" +
+ "\014\ufff7\001\002\000\010\006\007\013\010\015\006\001" +
+ "\002\000\010\006\007\013\010\015\006\001\002\000\012" +
+ "\002\027\006\007\013\010\015\006\001\002\000\016\004" +
+ "\016\005\014\006\015\007\020\010\017\011\013\001\002" +
+ "\000\010\006\007\013\010\015\006\001\002\000\010\006" +
+ "\007\013\010\015\006\001\002\000\010\006\007\013\010" +
+ "\015\006\001\002\000\012\002\ufffd\006\ufffd\013\ufffd\015" +
+ "\ufffd\001\002\000\010\006\007\013\010\015\006\001\002" +
+ "\000\010\006\007\013\010\015\006\001\002\000\020\004" +
+ "\ufffa\005\ufffa\006\ufffa\007\ufffa\010\ufffa\011\ufffa\014\ufffa" +
+ "\001\002\000\020\004\ufff9\005\ufff9\006\ufff9\007\ufff9\010" +
+ "\ufff9\011\ufff9\014\ufff9\001\002\000\020\004\ufffb\005\ufffb" +
+ "\006\ufffb\007\020\010\017\011\013\014\ufffb\001\002\000" +
+ "\020\004\ufffc\005\ufffc\006\ufffc\007\020\010\017\011\013" +
+ "\014\ufffc\001\002\000\020\004\ufff8\005\ufff8\006\ufff8\007" +
+ "\ufff8\010\ufff8\011\ufff8\014\ufff8\001\002\000\012\002\001" +
+ "\006\001\013\001\015\001\001\002\000\004\002\000\001" +
+ "\002\000\016\005\014\006\015\007\020\010\017\011\013" +
+ "\014\031\001\002\000\020\004\ufff5\005\ufff5\006\ufff5\007" +
+ "\ufff5\010\ufff5\011\ufff5\014\ufff5\001\002\000\020\004\ufff6" +
+ "\005\ufff6\006\ufff6\007\ufff6\010\ufff6\011\ufff6\014\ufff6\001" +
+ "\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\030\000\010\002\010\003\004\004\011\001\001\000" +
+ "\002\001\001\000\002\001\001\000\002\001\001\000\004" +
+ "\004\031\001\001\000\004\004\027\001\001\000\006\003" +
+ "\025\004\011\001\001\000\002\001\001\000\004\004\024" +
+ "\001\001\000\004\004\023\001\001\000\004\004\022\001" +
+ "\001\000\002\001\001\000\004\004\021\001\001\000\004" +
+ "\004\020\001\001\000\002\001\001\000\002\001\001\000" +
+ "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
+ "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+ "\001\000\002\001\001" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 12: // expr ::= LPAREN expr RPAREN
+ {
+ Integer RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Integer e = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = e;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 11: // expr ::= MINUS expr
+ {
+ Integer RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(0 - e.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 10: // expr ::= NUMBER
+ {
+ Integer RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer n = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 9: // expr ::= expr MOD expr
+ {
+ Integer RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ Integer e1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(e1.intValue() % e2.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 8: // expr ::= expr DIVIDE expr
+ {
+ Integer RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ Integer e1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(e1.intValue() / e2.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 7: // expr ::= expr TIMES expr
+ {
+ Integer RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ Integer e1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(e1.intValue() * e2.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 6: // expr ::= expr MINUS expr
+ {
+ Integer RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ Integer e1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(e1.intValue() - e2.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // expr ::= expr PLUS expr
+ {
+ Integer RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ Integer e1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Integer e2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = new Integer(e1.intValue() + e2.intValue());
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // expr_part ::= expr SEMI
+ {
+ Object RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Integer e = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ System.out.println("= " + e);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_part",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // expr_list ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_list",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // expr_list ::= expr_part
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_list",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= expr_list EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // expr_list ::= expr_list expr_part
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_list",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/exe_expressao/sym.java b/Test/com/analizador/exe_expressao/sym.java
new file mode 100644
index 0000000..fa633c8
--- /dev/null
+++ b/Test/com/analizador/exe_expressao/sym.java
@@ -0,0 +1,25 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 14:14:23 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.exe_expressao;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int MINUS = 4;
+ public static final int DIVIDE = 6;
+ public static final int UMINUS = 8;
+ public static final int NUMBER = 11;
+ public static final int MOD = 7;
+ public static final int SEMI = 2;
+ public static final int EOF = 0;
+ public static final int PLUS = 3;
+ public static final int error = 1;
+ public static final int RPAREN = 10;
+ public static final int TIMES = 5;
+ public static final int LPAREN = 9;
+}
+
diff --git a/Test/com/analizador/exp_condicional/Condicionais.cup b/Test/com/analizador/exp_condicional/Condicionais.cup
new file mode 100644
index 0000000..6c1af9c
--- /dev/null
+++ b/Test/com/analizador/exp_condicional/Condicionais.cup
@@ -0,0 +1,75 @@
+////////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE EXPRESSOES EM PORTUGOL (ANALIZADOR E COMPILADOR). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////////
+
+package com.analizador.exp_condicional;
+
+import java_cup.runtime.*;
+
+parser code
+{:
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+:}
+
+
+terminal SE,ENTAO;
+terminal CONDICIONAL,CONDICIONAL_ESPECIAL,CONDICIONAL_ADITIVA;
+terminal OPERADOR;
+terminal ABRIR_PARENTESE, FECHAR_PARENTESE;
+terminal String NUMERO,ID,STRING;
+
+
+/*
+* PARA OPERACOES DENTRO DA CONDICIONAL.: EX-> (a+b > a+c)
+*/
+non terminal gramatica,instanciacao_global;
+non terminal String instanciacao_ligativa,instanciacao_fragmental,instanciacao_operativa;
+
+non terminal String instanciacao_ligativa_string,instanciacao_string;
+
+
+
+precedence left CONDICIONAL_ADITIVA,CONDICIONAL_ESPECIAL,CONDICIONAL;
+precedence left ABRIR_PARENTESE,FECHAR_PARENTESE;
+precedence left OPERADOR;
+
+
+gramatica ::= gramatica instanciacao_global | instanciacao_global | error {::};
+
+
+
+instanciacao_global ::= SE instanciacao_ligativa:x ENTAO {: System.out.println("if(" + x + ")"); :};
+
+
+/*
+* PARA IDS,NUMEROS (RELIZAM OPERACOES)
+*/
+instanciacao_ligativa ::= instanciacao_ligativa:x1 CONDICIONAL_ADITIVA:y instanciacao_ligativa:x2 {: RESULT = x1 + " " + y + " " + x2; :} |
+ ABRIR_PARENTESE instanciacao_ligativa:x FECHAR_PARENTESE {: RESULT = "("+x+")"; :} |
+ instanciacao_fragmental:z {: RESULT = z; System.out.println("instanciacao_fragmental:z = "+z); :};
+
+instanciacao_fragmental ::= instanciacao_fragmental:x1 CONDICIONAL:y instanciacao_fragmental:x2 {: RESULT = x1 + " " + y + " " + x2; :} |
+ instanciacao_fragmental:x1 CONDICIONAL_ESPECIAL:y instanciacao_fragmental:x2 {: RESULT = x1 + " " + y + " " + x2; :} |
+ instanciacao_operativa:e {: RESULT = e;System.out.println("instanciacao_operativa:e = "+e); :};
+
+
+instanciacao_operativa ::= instanciacao_operativa:e1 OPERADOR:op instanciacao_operativa:e2 {: RESULT = e1+" "+op+" "+e2; :} |
+ ABRIR_PARENTESE instanciacao_operativa:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} |
+ NUMERO:n {: RESULT = n; System.out.println("NUMERO:n = "+n); :} |
+ ID:n {: RESULT = n; System.out.println("ID:n = "+n); :};
+
+/*
+* PARA STRINGS (CASO ESPECIFICO (SOMENTE = E <> ))
+*/
+instanciacao_string ::= instanciacao_string:x1 CONDICIONAL_ESPECIAL:x instanciacao_string:x2 {: RESULT = x1+" "+x+" "+x2; :} |
+ ABRIR_PARENTESE instanciacao_string:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} |
+ STRING:n {: RESULT = "\""+n+"\""; :};
\ No newline at end of file
diff --git a/Test/com/analizador/exp_condicional/Condicionais.flex b/Test/com/analizador/exp_condicional/Condicionais.flex
new file mode 100644
index 0000000..2e488c3
--- /dev/null
+++ b/Test/com/analizador/exp_condicional/Condicionais.flex
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+package com.analizador.exp_condicional;
+
+import java_cup.runtime.*;
+
+
+%%
+%cup
+%line
+%char
+%column
+
+%{
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+%}
+
+caracters = [A-Za-z]
+numerais = [0-9]
+alphanumeric = {caracters}|{numerais}
+outros = [_]
+ids = {caracters}({alphanumeric}|{outros})*
+espaco = [\n\r\ \t]
+nova_linha = \r|\n|\r\n
+inteiro = {numerais}+
+string_content = (\\\"|[^\n\r\"]|\\{espaco}+\\)*
+string_literal = {double_qoute}{string_content}{double_qoute}
+double_qoute = \"
+
+
+%%
+/* PARA TESTE LIMITADOR */
+
+(se|SE) { return newSym(sym.SE,yytext());}
+(entao|ENTAO) { return newSym(sym.ENTAO,yytext());}
+
+(e|E) { return newSym(sym.CONDICIONAL_E,"&&");}
+(ou|OU) { return newSym(sym.CONDICIONAL_OU,"||");}
+
+
+"<" { return newSym(sym.CONDICIONAL,yytext());}
+"<=" { return newSym(sym.CONDICIONAL,yytext());}
+">" { return newSym(sym.CONDICIONAL,yytext());}
+">=" { return newSym(sym.CONDICIONAL,yytext());}
+
+
+
+"<>" { return newSym(sym.CONDICIONAL_ESPECIAL,"!=");}
+"=" {return newSym(sym.CONDICIONAL_ESPECIAL,"==");}
+
+
+
+"+" {return newSym(sym.OPERADOR,yytext());}
+"-" {return newSym(sym.OPERADOR,yytext());}
+"*" {return newSym(sym.OPERADOR,yytext());}
+"/" {return newSym(sym.OPERADOR,yytext());}
+"%" {return newSym(sym.OPERADOR,"%");}
+
+
+
+"(" {return newSym(sym.ABRIR_PARENTESE);}
+")" {return newSym(sym.FECHAR_PARENTESE);}
+
+
+
+{string_literal} { return newSym(sym.STRING, (String) yytext().substring(1, yylength()-1)); }
+{inteiro} {return newSym(sym.NUMERO,(String) yytext());}
+{ids} {return newSym(sym.ID,yytext());}
+{espaco} {/* IGNORAR */}
+{nova_linha} {/* IGNORAR */}
+
+
+<aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\11\1\1\11\1\1\4\11"+
+ "\2\0\1\11\4\1\2\11\2\0\6\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[37];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 120) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 17: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 18: break;
+ case 3:
+ { return newSym(sym.NUMERO,(String) yytext());
+ }
+ case 19: break;
+ case 4:
+ { /* IGNORAR */
+ }
+ case 20: break;
+ case 5:
+ { return newSym(sym.CONDICIONAL_ADITIVA,"&&");
+ }
+ case 21: break;
+ case 6:
+ { return newSym(sym.CONDICIONAL,yytext());
+ }
+ case 22: break;
+ case 7:
+ { return newSym(sym.CONDICIONAL_ESPECIAL,"==");
+ }
+ case 23: break;
+ case 8:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 24: break;
+ case 9:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 25: break;
+ case 10:
+ { return newSym(sym.ABRIR_PARENTESE);
+ }
+ case 26: break;
+ case 11:
+ { return newSym(sym.FECHAR_PARENTESE);
+ }
+ case 27: break;
+ case 12:
+ { return newSym(sym.STRING, (String) yytext().substring(1, yylength()-1));
+ }
+ case 28: break;
+ case 13:
+ { return newSym(sym.SE,yytext());
+ }
+ case 29: break;
+ case 14:
+ { return newSym(sym.CONDICIONAL_ADITIVA,"||");
+ }
+ case 30: break;
+ case 15:
+ { return newSym(sym.CONDICIONAL_ESPECIAL,"!=");
+ }
+ case 31: break;
+ case 16:
+ { return newSym(sym.ENTAO,yytext());
+ }
+ case 32: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/exp_condicional/Yylex.java~ b/Test/com/analizador/exp_condicional/Yylex.java~
new file mode 100644
index 0000000..23230f0
--- /dev/null
+++ b/Test/com/analizador/exp_condicional/Yylex.java~
@@ -0,0 +1,719 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+package com.analizador.exp_condicional;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/Test/com/analizador/exp_condicional/Condicionais.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\4\1\6\1\36\1\36\1\5\22\0\1\4\1\0\1\10"+
+ "\2\0\1\33\2\0\1\34\1\35\1\32\1\32\1\0\1\32\1\0"+
+ "\1\32\12\2\2\0\1\27\1\30\1\31\2\0\1\23\3\1\1\14"+
+ "\10\1\1\21\1\24\3\1\1\13\1\22\1\26\5\1\1\0\1\7"+
+ "\2\0\1\3\1\0\1\17\3\1\1\12\10\1\1\15\1\20\3\1"+
+ "\1\11\1\16\1\25\5\1\12\0\1\36\u1fa2\0\1\36\1\36\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\1\3\2\4\1\1\1\2\1\5"+
+ "\1\2\1\5\2\2\1\6\1\7\1\6\1\10\1\11"+
+ "\1\12\1\13\2\0\1\14\1\15\2\2\1\16\1\6"+
+ "\1\17\2\0\1\14\4\2\1\20";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[37];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\37\0\76\0\135\0\37\0\174\0\233\0\272"+
+ "\0\331\0\370\0\u0117\0\u0136\0\u0155\0\u0174\0\37\0\u0193"+
+ "\0\37\0\37\0\37\0\37\0\233\0\u01b2\0\37\0\76"+
+ "\0\u01d1\0\u01f0\0\76\0\37\0\37\0\u020f\0\u022e\0\233"+
+ "\0\u024d\0\u026c\0\u028b\0\u02aa\0\76";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[37];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\4\1\2\1\5\1\6\1\5\1\2"+
+ "\1\7\1\10\1\11\1\12\1\13\3\3\1\14\3\3"+
+ "\1\15\2\3\1\16\1\17\1\20\1\21\1\22\1\23"+
+ "\1\24\41\0\3\3\5\0\16\3\12\0\1\4\42\0"+
+ "\1\5\30\0\5\25\2\0\1\26\1\27\26\25\1\0"+
+ "\3\3\5\0\1\3\1\30\14\3\11\0\3\3\5\0"+
+ "\4\3\1\31\11\3\11\0\3\3\5\0\3\3\1\30"+
+ "\12\3\11\0\3\3\5\0\10\3\1\32\5\3\11\0"+
+ "\3\3\5\0\14\3\1\33\1\3\11\0\3\3\5\0"+
+ "\15\3\1\33\40\0\1\34\1\35\35\0\1\34\6\0"+
+ "\4\25\1\36\2\37\1\26\1\40\26\25\1\0\3\3"+
+ "\5\0\5\3\1\41\10\3\11\0\3\3\5\0\11\3"+
+ "\1\42\4\3\10\0\4\25\1\36\2\37\1\26\1\27"+
+ "\26\25\4\0\3\37\1\25\30\0\3\3\5\0\6\3"+
+ "\1\43\7\3\11\0\3\3\5\0\12\3\1\44\3\3"+
+ "\11\0\3\3\5\0\7\3\1\45\6\3\11\0\3\3"+
+ "\5\0\13\3\1\45\2\3\10\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[713];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\11\1\1\11\1\1\4\11"+
+ "\2\0\1\11\4\1\2\11\2\0\6\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[37];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 120) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 17: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 18: break;
+ case 3:
+ { return newSym(sym.NUMERO,(String) yytext());
+ }
+ case 19: break;
+ case 4:
+ { /* IGNORAR */
+ }
+ case 20: break;
+ case 5:
+ { return newSym(sym.CONDICIONAL_ADITIVA,"&&");
+ }
+ case 21: break;
+ case 6:
+ { return newSym(sym.CONDICIONAL,yytext());
+ }
+ case 22: break;
+ case 7:
+ { return newSym(sym.CONDICIONAL_ESPECIAL,"==");
+ }
+ case 23: break;
+ case 8:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 24: break;
+ case 9:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 25: break;
+ case 10:
+ { return newSym(sym.ABRIR_PARENTESE);
+ }
+ case 26: break;
+ case 11:
+ { return newSym(sym.FECHAR_PARENTESE);
+ }
+ case 27: break;
+ case 12:
+ { return newSym(sym.STRING, (String) yytext().substring(1, yylength()-1));
+ }
+ case 28: break;
+ case 13:
+ { return newSym(sym.SE,yytext());
+ }
+ case 29: break;
+ case 14:
+ { return newSym(sym.CONDICIONAL_ADITIVA,"||");
+ }
+ case 30: break;
+ case 15:
+ { return newSym(sym.CONDICIONAL_ESPECIAL,"!=");
+ }
+ case 31: break;
+ case 16:
+ { return newSym(sym.ENTAO,yytext());
+ }
+ case 32: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/exp_condicional/java_cup.jar b/Test/com/analizador/exp_condicional/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/exp_condicional/java_cup.jar differ
diff --git a/Test/com/analizador/exp_condicional/parser.java b/Test/com/analizador/exp_condicional/parser.java
new file mode 100644
index 0000000..108ea70
--- /dev/null
+++ b/Test/com/analizador/exp_condicional/parser.java
@@ -0,0 +1,424 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Tue Jun 24 15:37:09 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.exp_condicional;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Tue Jun 24 15:37:09 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\023\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\002\003\000\002\003\005\000\002\004\005" +
+ "\000\002\004\005\000\002\004\003\000\002\004\003\000" +
+ "\002\005\005\000\002\005\005\000\002\005\003\000\002" +
+ "\006\005\000\002\006\005\000\002\006\003\000\002\006" +
+ "\003\000\002\007\005\000\002\007\005\000\002\007\003" +
+ "" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\044\000\006\003\005\004\007\001\002\000\006\002" +
+ "\046\004\007\001\002\000\006\002\ufffe\004\ufffe\001\002" +
+ "\000\006\002\uffff\004\uffff\001\002\000\012\012\016\014" +
+ "\012\015\010\016\014\001\002\000\016\005\ufff2\006\ufff2" +
+ "\007\ufff2\010\ufff2\011\ufff2\013\ufff2\001\002\000\012\005" +
+ "\ufff9\007\033\010\ufff9\013\ufff9\001\002\000\016\005\ufff3" +
+ "\006\ufff3\007\ufff3\010\ufff3\011\ufff3\013\ufff3\001\002\000" +
+ "\014\005\ufffa\006\042\007\041\010\ufffa\013\ufffa\001\002" +
+ "\000\012\005\uffef\007\uffef\010\uffef\013\uffef\001\002\000" +
+ "\006\005\040\010\030\001\002\000\012\012\016\014\012" +
+ "\015\010\016\014\001\002\000\016\005\ufff6\006\ufff6\007" +
+ "\ufff6\010\ufff6\011\020\013\ufff6\001\002\000\010\012\021" +
+ "\014\012\015\010\001\002\000\010\012\021\014\012\015" +
+ "\010\001\002\000\016\005\ufff5\006\ufff5\007\ufff5\010\ufff5" +
+ "\011\ufff5\013\ufff5\001\002\000\006\011\020\013\024\001" +
+ "\002\000\016\005\ufff4\006\ufff4\007\ufff4\010\ufff4\011\ufff4" +
+ "\013\ufff4\001\002\000\010\007\033\010\ufff9\013\034\001" +
+ "\002\000\006\010\030\013\031\001\002\000\014\006\ufff6" +
+ "\007\ufff6\010\ufff6\011\020\013\024\001\002\000\012\012" +
+ "\016\014\012\015\010\016\014\001\002\000\010\005\ufffb" +
+ "\010\ufffb\013\ufffb\001\002\000\010\005\ufffc\010\ufffc\013" +
+ "\ufffc\001\002\000\006\012\036\016\014\001\002\000\012" +
+ "\005\ufff0\007\ufff0\010\ufff0\013\ufff0\001\002\000\012\005" +
+ "\ufff1\007\ufff1\010\ufff1\013\ufff1\001\002\000\006\012\036" +
+ "\016\014\001\002\000\006\007\033\013\034\001\002\000" +
+ "\006\002\ufffd\004\ufffd\001\002\000\010\012\021\014\012" +
+ "\015\010\001\002\000\010\012\021\014\012\015\010\001" +
+ "\002\000\014\005\ufff8\006\ufff8\007\ufff8\010\ufff8\013\ufff8" +
+ "\001\002\000\014\005\ufff7\006\ufff7\007\ufff7\010\ufff7\013" +
+ "\ufff7\001\002\000\006\002\001\004\001\001\002\000\004" +
+ "\002\000\001\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\044\000\006\002\003\003\005\001\001\000\004\003" +
+ "\044\001\001\000\002\001\001\000\002\001\001\000\012" +
+ "\004\014\005\012\006\016\007\010\001\001\000\002\001" +
+ "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
+ "\000\002\001\001\000\002\001\001\000\012\004\025\005" +
+ "\012\006\026\007\024\001\001\000\002\001\001\000\004" +
+ "\006\021\001\001\000\004\006\022\001\001\000\002\001" +
+ "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
+ "\000\002\001\001\000\002\001\001\000\012\004\031\005" +
+ "\012\006\016\007\010\001\001\000\002\001\001\000\002" +
+ "\001\001\000\004\007\034\001\001\000\002\001\001\000" +
+ "\002\001\001\000\004\007\036\001\001\000\002\001\001" +
+ "\000\002\001\001\000\006\005\043\006\016\001\001\000" +
+ "\006\005\042\006\016\001\001\000\002\001\001\000\002" +
+ "\001\001\000\002\001\001\000\002\001\001" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 18: // instanciacao_string ::= STRING
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = "\""+n+"\"";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_string",5, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 17: // instanciacao_string ::= ABRIR_PARENTESE instanciacao_string FECHAR_PARENTESE
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = "("+e+")";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_string",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 16: // instanciacao_string ::= instanciacao_string CONDICIONAL_ESPECIAL instanciacao_string
+ {
+ String RESULT =null;
+ int x1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int x1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object x = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int x2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int x2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String x2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = x1+" "+x+" "+x2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_string",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 15: // instanciacao_operativa ::= ID
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n; System.out.println("ID:n = "+n);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_operativa",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 14: // instanciacao_operativa ::= NUMERO
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n; System.out.println("NUMERO:n = "+n);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_operativa",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 13: // instanciacao_operativa ::= ABRIR_PARENTESE instanciacao_operativa FECHAR_PARENTESE
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = "("+e+")";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_operativa",4, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 12: // instanciacao_operativa ::= instanciacao_operativa OPERADOR instanciacao_operativa
+ {
+ String RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int opleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int opright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object op = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = e1+" "+op+" "+e2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_operativa",4, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 11: // instanciacao_fragmental ::= instanciacao_operativa
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = e;System.out.println("instanciacao_operativa:e = "+e);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_fragmental",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 10: // instanciacao_fragmental ::= instanciacao_fragmental CONDICIONAL_ESPECIAL instanciacao_fragmental
+ {
+ String RESULT =null;
+ int x1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int x1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int yleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int yright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object y = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int x2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int x2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String x2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = x1 + " " + y + " " + x2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_fragmental",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 9: // instanciacao_fragmental ::= instanciacao_fragmental CONDICIONAL instanciacao_fragmental
+ {
+ String RESULT =null;
+ int x1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int x1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int yleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int yright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object y = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int x2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int x2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String x2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = x1 + " " + y + " " + x2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_fragmental",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 8: // instanciacao_ligativa ::= instanciacao_string
+ {
+ String RESULT =null;
+ int zleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int zright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String z = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = z; System.out.println("instanciacao_fragmental:z = "+z);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_ligativa",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 7: // instanciacao_ligativa ::= instanciacao_fragmental
+ {
+ String RESULT =null;
+ int zleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int zright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String z = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = z; System.out.println("instanciacao_fragmental:z = "+z);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_ligativa",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 6: // instanciacao_ligativa ::= ABRIR_PARENTESE instanciacao_ligativa FECHAR_PARENTESE
+ {
+ String RESULT =null;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = "("+x+")";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_ligativa",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // instanciacao_ligativa ::= instanciacao_ligativa CONDICIONAL_ADITIVA instanciacao_ligativa
+ {
+ String RESULT =null;
+ int x1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int x1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int yleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int yright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object y = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int x2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int x2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String x2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = x1 + " " + y + " " + x2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_ligativa",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // instanciacao_global ::= SE instanciacao_ligativa ENTAO
+ {
+ Object RESULT =null;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ System.out.println("if(" + x + ")");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_global",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // gramatica ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // gramatica ::= instanciacao_global
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= gramatica EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // gramatica ::= gramatica instanciacao_global
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/exp_condicional/sym.java b/Test/com/analizador/exp_condicional/sym.java
new file mode 100644
index 0000000..1c39b12
--- /dev/null
+++ b/Test/com/analizador/exp_condicional/sym.java
@@ -0,0 +1,26 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Tue Jun 24 15:37:09 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.exp_condicional;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int OPERADOR = 7;
+ public static final int SE = 2;
+ public static final int CONDICIONAL_ESPECIAL = 5;
+ public static final int CONDICIONAL_ADITIVA = 6;
+ public static final int ABRIR_PARENTESE = 8;
+ public static final int STRING = 12;
+ public static final int EOF = 0;
+ public static final int NUMERO = 10;
+ public static final int ID = 11;
+ public static final int CONDICIONAL = 4;
+ public static final int error = 1;
+ public static final int FECHAR_PARENTESE = 9;
+ public static final int ENTAO = 3;
+}
+
diff --git a/Test/com/analizador/expressao/Exemplo.txt b/Test/com/analizador/expressao/Exemplo.txt
new file mode 100644
index 0000000..f67595d
--- /dev/null
+++ b/Test/com/analizador/expressao/Exemplo.txt
@@ -0,0 +1 @@
+variavel <- ((a+2)/2)
\ No newline at end of file
diff --git a/Test/com/analizador/expressao/Expressao.cup b/Test/com/analizador/expressao/Expressao.cup
new file mode 100644
index 0000000..2d6ed12
--- /dev/null
+++ b/Test/com/analizador/expressao/Expressao.cup
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE EXPRESSOES EM PORTUGOL (ANALIZADOR E COMPILADOR). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////////
+
+package com.analizador.expressao;
+
+import java_cup.runtime.*;
+
+parser code
+{:
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+:}
+
+
+terminal ATRIBUIR;
+terminal OPERADOR;
+terminal ABRIR_PARENTESE, FECHAR_PARENTESE;
+terminal String NUMERO,ID,STRING;
+
+
+non terminal gramatica, instanciacao;
+non terminal String valor;
+
+
+precedence left OPERADOR;
+
+gramatica ::= gramatica instanciacao |
+ instanciacao |
+ error {::} ;
+
+instanciacao ::= ID:x ATRIBUIR valor:e {: System.out.println(x+" = "+e); :} | ID:x ATRIBUIR STRING:e {: System.out.println(x+" = \""+e+"\""); :};
+
+
+valor ::= valor:e1 OPERADOR:op valor:e2 {: RESULT = (String) e1+" "+op+" "+e2; :} |
+ ABRIR_PARENTESE valor:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} |
+ NUMERO:n {: RESULT = n; :} |
+ ID:n {: RESULT = n; :} ;
\ No newline at end of file
diff --git a/Test/com/analizador/expressao/Expressao.flex b/Test/com/analizador/expressao/Expressao.flex
new file mode 100644
index 0000000..b547758
--- /dev/null
+++ b/Test/com/analizador/expressao/Expressao.flex
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE EXPRESSOES EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+
+package com.analizador.expressao;
+
+import java_cup.runtime.*;
+
+
+%%
+%cup
+%line
+%column
+
+%{
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+%}
+
+caracters = [A-Za-z]
+numerais = [0-9]
+alphanumeric = {caracters}|{numerais}
+outros = [_]
+ids = {caracters}({alphanumeric}|{outros})*
+espaco = [\n\r\ \t]
+nova_linha = \r|\n|\r\n
+inteiro = {numerais}+
+
+
+string_content = (\\\"|[^\n\r\"]|\\{espaco}+\\)*
+string_literal = {double_qoute}{string_content}{double_qoute}
+double_qoute = \"
+%%
+
+/*
+* PARA TESTE
+*/
+"<-" { return newSym(sym.ATRIBUIR,yytext());}
+":=" { return newSym(sym.ATRIBUIR,yytext());}
+
+
+
+{string_literal} { return newSym(sym.STRING, yytext().substring(1, yylength()-1)); }
+{inteiro} {return newSym(sym.NUMERO,(String) yytext());}
+{ids} {return newSym(sym.ID,yytext());}
+{espaco} {/* IGNORAR */}
+{nova_linha} {/* IGNORAR */}
+"+" {return newSym(sym.OPERADOR,yytext());}
+"-" {return newSym(sym.OPERADOR,yytext());}
+"*" {return newSym(sym.OPERADOR,yytext());}
+"/" {return newSym(sym.OPERADOR,yytext());}
+"%" {return newSym(sym.OPERADOR,"%");}
+"(" {return newSym(sym.ABRIR_PARENTESE,yytext());}
+")" {return newSym(sym.FECHAR_PARENTESE,yytext());}
+<aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\3\1\1\11\1\1\3\11"+
+ "\2\0\2\11\2\0\1\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[20];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 80) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 11: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 12: break;
+ case 3:
+ { return newSym(sym.NUMERO,(String) yytext());
+ }
+ case 13: break;
+ case 4:
+ { /* IGNORAR */
+ }
+ case 14: break;
+ case 5:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 15: break;
+ case 6:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 16: break;
+ case 7:
+ { return newSym(sym.ABRIR_PARENTESE,yytext());
+ }
+ case 17: break;
+ case 8:
+ { return newSym(sym.FECHAR_PARENTESE,yytext());
+ }
+ case 18: break;
+ case 9:
+ { return newSym(sym.STRING, yytext().substring(1, yylength()-1));
+ }
+ case 19: break;
+ case 10:
+ { return newSym(sym.ATRIBUIR,yytext());
+ }
+ case 20: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/expressao/Yylex.java~ b/Test/com/analizador/expressao/Yylex.java~
new file mode 100644
index 0000000..31e671e
--- /dev/null
+++ b/Test/com/analizador/expressao/Yylex.java~
@@ -0,0 +1,678 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE EXPRESSOES EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 20/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+
+package com.analizador.expressao;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/Test/com/analizador/expressao/Expressao.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\4\1\6\1\21\1\21\1\5\22\0\1\4\1\0\1\10"+
+ "\2\0\1\16\2\0\1\17\1\20\1\15\1\15\1\0\1\12\1\0"+
+ "\1\15\12\2\1\13\1\0\1\11\1\14\3\0\32\1\1\0\1\7"+
+ "\2\0\1\3\1\0\32\1\12\0\1\21\u1fa2\0\1\21\1\21\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\1\3\2\4\2\1\1\5\1\1"+
+ "\1\6\1\7\1\10\2\0\1\11\1\12\2\0\1\11";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[20];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\22\0\44\0\66\0\22\0\110\0\132\0\154"+
+ "\0\22\0\176\0\22\0\22\0\22\0\132\0\220\0\22"+
+ "\0\22\0\242\0\264\0\132";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[20];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\4\1\2\1\5\1\6\1\5\1\2"+
+ "\1\7\1\10\1\11\1\12\1\2\1\11\1\13\1\14"+
+ "\1\15\24\0\3\3\20\0\1\4\25\0\1\5\13\0"+
+ "\5\16\2\0\1\17\1\20\11\16\12\0\1\21\23\0"+
+ "\1\21\5\0\4\16\1\22\2\23\1\17\1\24\15\16"+
+ "\1\22\2\23\1\17\1\20\11\16\4\0\3\23\1\16"+
+ "\12\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[198];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\3\1\1\11\1\1\3\11"+
+ "\2\0\2\11\2\0\1\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[20];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 80) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 11: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 12: break;
+ case 3:
+ { return newSym(sym.NUMERO,(String) yytext());
+ }
+ case 13: break;
+ case 4:
+ { /* IGNORAR */
+ }
+ case 14: break;
+ case 5:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 15: break;
+ case 6:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 16: break;
+ case 7:
+ { return newSym(sym.ABRIR_PARENTESE,yytext());
+ }
+ case 17: break;
+ case 8:
+ { return newSym(sym.FECHAR_PARENTESE,yytext());
+ }
+ case 18: break;
+ case 9:
+ { return newSym(sym.STRING, yytext().substring(1, yylength()-1));
+ }
+ case 19: break;
+ case 10:
+ { return newSym(sym.ATRIBUIR,yytext());
+ }
+ case 20: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/expressao/java_cup.jar b/Test/com/analizador/expressao/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/expressao/java_cup.jar differ
diff --git a/Test/com/analizador/expressao/parser.java b/Test/com/analizador/expressao/parser.java
new file mode 100644
index 0000000..0ad1ae7
--- /dev/null
+++ b/Test/com/analizador/expressao/parser.java
@@ -0,0 +1,269 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Sat Jun 21 09:26:22 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.expressao;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Sat Jun 21 09:26:22 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\012\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\002\003\000\002\003\005\000\002\003\005" +
+ "\000\002\004\005\000\002\004\005\000\002\004\003\000" +
+ "\002\004\003" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\021\000\006\003\006\011\004\001\002\000\004\004" +
+ "\012\001\002\000\006\002\011\011\004\001\002\000\006" +
+ "\002\ufffe\011\ufffe\001\002\000\006\002\uffff\011\uffff\001" +
+ "\002\000\006\002\001\011\001\001\002\000\004\002\000" +
+ "\001\002\000\012\006\016\010\014\011\013\012\015\001" +
+ "\002\000\012\002\ufff8\005\ufff8\007\ufff8\011\ufff8\001\002" +
+ "\000\012\002\ufff9\005\ufff9\007\ufff9\011\ufff9\001\002\000" +
+ "\006\002\ufffc\011\ufffc\001\002\000\010\006\016\010\014" +
+ "\011\013\001\002\000\010\002\ufffd\005\020\011\ufffd\001" +
+ "\002\000\010\006\016\010\014\011\013\001\002\000\012" +
+ "\002\ufffb\005\ufffb\007\ufffb\011\ufffb\001\002\000\006\005" +
+ "\020\007\023\001\002\000\012\002\ufffa\005\ufffa\007\ufffa" +
+ "\011\ufffa\001\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\021\000\006\002\004\003\006\001\001\000\002\001" +
+ "\001\000\004\003\007\001\001\000\002\001\001\000\002" +
+ "\001\001\000\002\001\001\000\002\001\001\000\004\004" +
+ "\016\001\001\000\002\001\001\000\002\001\001\000\002" +
+ "\001\001\000\004\004\021\001\001\000\002\001\001\000" +
+ "\004\004\020\001\001\000\002\001\001\000\002\001\001" +
+ "\000\002\001\001" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 9: // valor ::= ID
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 8: // valor ::= NUMERO
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 7: // valor ::= ABRIR_PARENTESE valor FECHAR_PARENTESE
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = "("+e+")";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 6: // valor ::= valor OPERADOR valor
+ {
+ String RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int opleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int opright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object op = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = (String) e1+" "+op+" "+e2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // instanciacao ::= ID ATRIBUIR STRING
+ {
+ Object RESULT =null;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ System.out.println(x+" = \""+e+"\"");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // instanciacao ::= ID ATRIBUIR valor
+ {
+ Object RESULT =null;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ System.out.println(x+" = "+e);
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // gramatica ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // gramatica ::= instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= gramatica EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // gramatica ::= gramatica instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/expressao/sym.java b/Test/com/analizador/expressao/sym.java
new file mode 100644
index 0000000..c518b83
--- /dev/null
+++ b/Test/com/analizador/expressao/sym.java
@@ -0,0 +1,22 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Sat Jun 21 09:26:22 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.expressao;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int OPERADOR = 3;
+ public static final int ABRIR_PARENTESE = 4;
+ public static final int STRING = 8;
+ public static final int EOF = 0;
+ public static final int NUMERO = 6;
+ public static final int ID = 7;
+ public static final int error = 1;
+ public static final int FECHAR_PARENTESE = 5;
+ public static final int ATRIBUIR = 2;
+}
+
diff --git a/Test/com/analizador/inicializacao/Exemplo.txt b/Test/com/analizador/inicializacao/Exemplo.txt
new file mode 100644
index 0000000..e69de29
diff --git a/Test/com/analizador/inicializacao/Inicializador.java b/Test/com/analizador/inicializacao/Inicializador.java
new file mode 100644
index 0000000..c652aea
--- /dev/null
+++ b/Test/com/analizador/inicializacao/Inicializador.java
@@ -0,0 +1,26 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.analizador.inicializacao;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ *
+ * @author Andrew
+ */
+public class Inicializador {
+
+
+ public static void main(String[] args) throws IOException, Exception {
+ //Yylex lexer = new Yylex(new StringReader("2+9"));
+ File f = new File("C:\\Users\\Andrew\\Documents\\NetBeansProjects\\portugol-projeto\\Test\\com\\analizador\\inicializacao\\Exemplo.txt");
+
+
+
+ }
+}
diff --git a/Test/com/analizador/separadorLoop/Exemplo.txt b/Test/com/analizador/separadorLoop/Exemplo.txt
new file mode 100644
index 0000000..7f22d84
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/Exemplo.txt
@@ -0,0 +1 @@
+escreva("massa menor: ",(massa_menor/100)*5,"\n","massa maior",massa_maior)
\ No newline at end of file
diff --git a/Test/com/analizador/separadorLoop/Inicializador.java b/Test/com/analizador/separadorLoop/Inicializador.java
new file mode 100644
index 0000000..cd102c5
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/Inicializador.java
@@ -0,0 +1,34 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.analizador.separadorLoop;
+
+import java.io.IOException;
+import java_cup.runtime.Symbol;
+
+/**
+ *
+ * @author Andrew
+ */
+public class Inicializador {
+
+ public static void main(String[] args) throws IOException, Exception {
+ Yylex lexer = new Yylex(Inicializador.class.getResourceAsStream("Exemplo.txt"));
+
+ //Yylex lexer = new Yylex(new StringReader("teste1,teste2,teste3,testeN : caracter"));
+ /*
+ Symbol sym;
+ for (sym = lexer.next_token(); sym.sym != 0; sym = lexer.next_token()) {
+ System.out.println("Token " + sym.sym + ", with value = " + sym.value + "; at line " + sym.left + ", column " + sym.right);
+ }
+ */
+
+
+ parser p = new parser(lexer);
+ p.parse();
+
+ }
+
+}
diff --git a/Test/com/analizador/separadorLoop/Separador.cup b/Test/com/analizador/separadorLoop/Separador.cup
new file mode 100644
index 0000000..87e999b
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/Separador.cup
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE FUNCAO COM LOOP EM PORTUGOL (ANALIZADOR E COMPILADOR). ////
+* BY: ANDREW NETO ////
+* 19/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////////////////
+package com.analizador.separadorLoop;
+
+import java_cup.runtime.*;
+
+parser code
+{:
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+:}
+
+
+terminal ESCREVA;
+terminal SEPARADOR,ABRIR_PARENTESE,FECHAR_PARENTESE, OPERADOR;
+terminal String ID,STRING,NUMERO;
+
+
+
+non terminal gramatica,instanciacao;
+non terminal String instanciacao_loop,valor;
+
+precedence left SEPARADOR,OPERADOR;
+precedence left ABRIR_PARENTESE,FECHAR_PARENTESE;
+
+
+gramatica ::= gramatica instanciacao | instanciacao | error {::};
+
+
+instanciacao ::= ESCREVA ABRIR_PARENTESE instanciacao_loop:e FECHAR_PARENTESE {: System.out.println("System.out.print("+e+");"); :};
+
+instanciacao_loop ::= instanciacao_loop:e1 SEPARADOR instanciacao_loop:e2 {: RESULT = e1 + " + " + e2; :} |
+ valor:e {: RESULT = e; :} |
+ STRING:e {: RESULT = "\""+e+"\""; :};
+
+
+valor ::= valor:e1 OPERADOR:op valor:e2 {: RESULT = (String) e1+" "+op+" "+e2; :} |
+ ABRIR_PARENTESE valor:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} |
+ NUMERO:n {: RESULT = n; :} |
+ ID:n {: RESULT = n; :} ;
\ No newline at end of file
diff --git a/Test/com/analizador/separadorLoop/Separador.flex b/Test/com/analizador/separadorLoop/Separador.flex
new file mode 100644
index 0000000..b0e6e1d
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/Separador.flex
@@ -0,0 +1,74 @@
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 19/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+package com.analizador.separadorLoop;
+
+import java_cup.runtime.*;
+
+
+%%
+%cup
+%line
+%char
+%column
+
+%{
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+%}
+
+caracters = [A-Za-z]
+numerais = [0-9]
+alphanumeric = {caracters}|{numerais}
+outros = [_]
+ids = {caracters}({alphanumeric}|{outros})*
+espaco = [\n\r\ \t]
+nova_linha = \r|\n|\r\n
+
+inteiro = {numerais}+
+
+string_content = (\\\"|[^\n\r\"]|\\{espaco}+\\)*
+string_literal = {double_qoute}{string_content}{double_qoute}
+double_qoute = \"
+
+
+
+%%
+
+(escreva|ESCREVA) { return newSym(sym.ESCREVA,yytext());}
+
+
+"," { return newSym(sym.SEPARADOR,yytext());}
+
+
+"(" {return newSym(sym.ABRIR_PARENTESE);}
+")" {return newSym(sym.FECHAR_PARENTESE);}
+
+"+" {return newSym(sym.OPERADOR,yytext());}
+"-" {return newSym(sym.OPERADOR,yytext());}
+"*" {return newSym(sym.OPERADOR,yytext());}
+"/" {return newSym(sym.OPERADOR,yytext());}
+"%" {return newSym(sym.OPERADOR,"%");}
+
+{inteiro} {return newSym(sym.NUMERO,yytext());}
+{string_literal} { return newSym(sym.STRING,yytext().substring(1, yylength()-1)); }
+{ids} { return newSym(sym.ID,yytext());}
+{espaco} {/*IGNORAR*/}
+{nova_linha} {/*IGNORAR*/}
+
+
+
+<aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\4\1\5\11\2\0\1\11"+
+ "\2\1\2\0\12\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[31];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 112) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 12: break;
+ case 2:
+ { return newSym(sym.ID,yytext());
+ }
+ case 13: break;
+ case 3:
+ { return newSym(sym.NUMERO,yytext());
+ }
+ case 14: break;
+ case 4:
+ { /*IGNORAR*/
+ }
+ case 15: break;
+ case 5:
+ { return newSym(sym.SEPARADOR,yytext());
+ }
+ case 16: break;
+ case 6:
+ { return newSym(sym.ABRIR_PARENTESE);
+ }
+ case 17: break;
+ case 7:
+ { return newSym(sym.FECHAR_PARENTESE);
+ }
+ case 18: break;
+ case 8:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 19: break;
+ case 9:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 20: break;
+ case 10:
+ { return newSym(sym.STRING,yytext().substring(1, yylength()-1));
+ }
+ case 21: break;
+ case 11:
+ { return newSym(sym.ESCREVA,yytext());
+ }
+ case 22: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/separadorLoop/Yylex.java~ b/Test/com/analizador/separadorLoop/Yylex.java~
new file mode 100644
index 0000000..3d1082d
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/Yylex.java~
@@ -0,0 +1,695 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 19/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+package com.analizador.separadorLoop;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/Test/com/analizador/separadorLoop/Separador.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\4\1\6\1\32\1\32\1\5\22\0\1\4\1\0\1\10"+
+ "\2\0\1\31\2\0\1\26\1\27\1\30\1\30\1\25\1\30\1\0"+
+ "\1\30\12\2\7\0\1\24\1\1\1\21\1\1\1\17\14\1\1\22"+
+ "\1\20\2\1\1\23\4\1\1\0\1\7\2\0\1\3\1\0\1\16"+
+ "\1\1\1\13\1\1\1\11\14\1\1\14\1\12\2\1\1\15\4\1"+
+ "\12\0\1\32\u1fa2\0\1\32\1\32\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\1\3\2\4\1\1\2\2\1\5"+
+ "\1\6\1\7\1\10\1\11\2\0\1\12\2\2\2\0"+
+ "\1\12\10\2\1\13";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[31];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\33\0\66\0\121\0\33\0\154\0\207\0\242"+
+ "\0\275\0\33\0\33\0\33\0\33\0\33\0\207\0\330"+
+ "\0\33\0\363\0\u010e\0\u0129\0\u0144\0\207\0\u015f\0\u017a"+
+ "\0\u0195\0\u01b0\0\u01cb\0\u01e6\0\u0201\0\u021c\0\66";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[31];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\4\1\2\1\5\1\6\1\5\1\2"+
+ "\1\7\1\10\5\3\1\11\5\3\1\12\1\13\1\14"+
+ "\1\15\1\16\35\0\3\3\5\0\14\3\10\0\1\4"+
+ "\36\0\1\5\24\0\5\17\2\0\1\20\1\21\22\17"+
+ "\1\0\3\3\5\0\1\3\1\22\12\3\7\0\3\3"+
+ "\5\0\7\3\1\23\4\3\6\0\4\17\1\24\2\25"+
+ "\1\20\1\26\22\17\1\0\3\3\5\0\2\3\1\27"+
+ "\11\3\7\0\3\3\5\0\10\3\1\30\3\3\6\0"+
+ "\4\17\1\24\2\25\1\20\1\21\22\17\4\0\3\25"+
+ "\1\17\24\0\3\3\5\0\3\3\1\31\10\3\7\0"+
+ "\3\3\5\0\11\3\1\32\2\3\7\0\3\3\5\0"+
+ "\1\33\13\3\7\0\3\3\5\0\6\3\1\34\5\3"+
+ "\7\0\3\3\5\0\4\3\1\35\7\3\7\0\3\3"+
+ "\5\0\12\3\1\36\1\3\7\0\3\3\5\0\5\3"+
+ "\1\37\6\3\7\0\3\3\5\0\13\3\1\37\6\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[567];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\2\1\1\11\4\1\5\11\2\0\1\11"+
+ "\2\1\2\0\12\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[31];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 112) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { return newSym(sym.error,yytext());
+ }
+ case 12: break;
+ case 2:
+ { return newSym(sym.ID,(String) yytext());
+ }
+ case 13: break;
+ case 3:
+ { return newSym(sym.NUMERO,(String) yytext());
+ }
+ case 14: break;
+ case 4:
+ { /*IGNORAR*/
+ }
+ case 15: break;
+ case 5:
+ { return newSym(sym.SEPARADOR,yytext());
+ }
+ case 16: break;
+ case 6:
+ { return newSym(sym.ABRIR_PARENTESE);
+ }
+ case 17: break;
+ case 7:
+ { return newSym(sym.FECHAR_PARENTESE);
+ }
+ case 18: break;
+ case 8:
+ { return newSym(sym.OPERADOR,yytext());
+ }
+ case 19: break;
+ case 9:
+ { return newSym(sym.OPERADOR,"%");
+ }
+ case 20: break;
+ case 10:
+ { return newSym(sym.STRING, (String) yytext().substring(1, yylength()-1));
+ }
+ case 21: break;
+ case 11:
+ { return newSym(sym.ESCREVA,yytext());
+ }
+ case 22: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/separadorLoop/java_cup.jar b/Test/com/analizador/separadorLoop/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/separadorLoop/java_cup.jar differ
diff --git a/Test/com/analizador/separadorLoop/parser.java b/Test/com/analizador/separadorLoop/parser.java
new file mode 100644
index 0000000..8254c1c
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/parser.java
@@ -0,0 +1,294 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Thu Jun 26 11:55:25 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.separadorLoop;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Thu Jun 26 11:55:25 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\014\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\002\003\000\002\003\006\000\002\004\005" +
+ "\000\002\004\003\000\002\004\003\000\002\005\005\000" +
+ "\002\005\005\000\002\005\003\000\002\005\003" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\025\000\006\003\006\004\004\001\002\000\004\006" +
+ "\012\001\002\000\006\002\011\004\004\001\002\000\006" +
+ "\002\ufffe\004\ufffe\001\002\000\006\002\uffff\004\uffff\001" +
+ "\002\000\006\002\001\004\001\001\002\000\004\002\000" +
+ "\001\002\000\012\006\016\011\013\012\015\013\014\001" +
+ "\002\000\010\005\ufff6\007\ufff6\010\ufff6\001\002\000\010" +
+ "\005\ufff7\007\ufff7\010\ufff7\001\002\000\006\005\ufffa\007" +
+ "\ufffa\001\002\000\010\006\016\011\013\013\014\001\002" +
+ "\000\010\005\ufffb\007\ufffb\010\024\001\002\000\006\005" +
+ "\021\007\022\001\002\000\012\006\016\011\013\012\015" +
+ "\013\014\001\002\000\006\002\ufffd\004\ufffd\001\002\000" +
+ "\006\005\ufffc\007\ufffc\001\002\000\010\006\016\011\013" +
+ "\013\014\001\002\000\010\005\ufff9\007\ufff9\010\ufff9\001" +
+ "\002\000\006\007\027\010\024\001\002\000\010\005\ufff8" +
+ "\007\ufff8\010\ufff8\001\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\025\000\006\002\004\003\006\001\001\000\002\001" +
+ "\001\000\004\003\007\001\001\000\002\001\001\000\002" +
+ "\001\001\000\002\001\001\000\002\001\001\000\006\004" +
+ "\017\005\016\001\001\000\002\001\001\000\002\001\001" +
+ "\000\002\001\001\000\004\005\025\001\001\000\002\001" +
+ "\001\000\002\001\001\000\006\004\022\005\016\001\001" +
+ "\000\002\001\001\000\002\001\001\000\004\005\024\001" +
+ "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
+ "" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 11: // valor ::= ID
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 10: // valor ::= NUMERO
+ {
+ String RESULT =null;
+ int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = n;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 9: // valor ::= ABRIR_PARENTESE valor FECHAR_PARENTESE
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = "("+e+")";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 8: // valor ::= valor OPERADOR valor
+ {
+ String RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int opleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int opright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object op = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = (String) e1+" "+op+" "+e2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("valor",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 7: // instanciacao_loop ::= STRING
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = "\""+e+"\"";
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_loop",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 6: // instanciacao_loop ::= valor
+ {
+ String RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = e;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_loop",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // instanciacao_loop ::= instanciacao_loop SEPARADOR instanciacao_loop
+ {
+ String RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = e1 + " + " + e2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_loop",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // instanciacao ::= ESCREVA ABRIR_PARENTESE instanciacao_loop FECHAR_PARENTESE
+ {
+ Object RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ System.out.println("System.out.print("+e+");");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // gramatica ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // gramatica ::= instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= gramatica EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // gramatica ::= gramatica instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("gramatica",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/separadorLoop/sym.java b/Test/com/analizador/separadorLoop/sym.java
new file mode 100644
index 0000000..4ff55de
--- /dev/null
+++ b/Test/com/analizador/separadorLoop/sym.java
@@ -0,0 +1,23 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Thu Jun 26 11:55:25 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.separadorLoop;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int OPERADOR = 6;
+ public static final int ABRIR_PARENTESE = 4;
+ public static final int STRING = 8;
+ public static final int EOF = 0;
+ public static final int NUMERO = 9;
+ public static final int SEPARADOR = 3;
+ public static final int ID = 7;
+ public static final int error = 1;
+ public static final int FECHAR_PARENTESE = 5;
+ public static final int ESCREVA = 2;
+}
+
diff --git a/Test/com/analizador/var/AnalizerP2.java b/Test/com/analizador/var/AnalizerP2.java
new file mode 100644
index 0000000..e133038
--- /dev/null
+++ b/Test/com/analizador/var/AnalizerP2.java
@@ -0,0 +1,24 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.analizador.var;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ *
+ * @author Andrew
+ */
+public class AnalizerP2 {
+ public AnalizerP2() throws FileNotFoundException, Exception{
+ File f = new File("C:\\Users\\Andrew\\Documents\\NetBeansProjects\\portugol-projeto\\Test\\com\\analizador\\var\\Exemplo.txt");
+ Yylex lexer = new Yylex(new FileInputStream(f));
+ parser p = new parser(lexer);
+ p.parse();
+ }
+}
diff --git a/Test/com/analizador/var/Exemplo.txt b/Test/com/analizador/var/Exemplo.txt
new file mode 100644
index 0000000..ad01560
--- /dev/null
+++ b/Test/com/analizador/var/Exemplo.txt
@@ -0,0 +1,4 @@
+var
+ Nome,sobrenome : caracter
+ idade : inteiro
+ massa : real
\ No newline at end of file
diff --git a/Test/com/analizador/var/Inicializador.java b/Test/com/analizador/var/Inicializador.java
new file mode 100644
index 0000000..e1d3805
--- /dev/null
+++ b/Test/com/analizador/var/Inicializador.java
@@ -0,0 +1,33 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.analizador.var;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Andrew
+ */
+public class Inicializador {
+
+ public static void main(String[] args) throws IOException, Exception {
+ Yylex lexer = new Yylex(Inicializador.class.getResourceAsStream("Exemplo.txt"));
+
+ //Yylex lexer = new Yylex(new StringReader("teste1,teste2,teste3,testeN : caracter"));
+ /*
+ Symbol sym;
+ for (sym = lexer.next_token(); sym.sym != 0; sym = lexer.next_token()) {
+ System.out.println("Token " + sym.sym + ", with value = " + sym.value + "; at line " + sym.left + ", column " + sym.right);
+ }
+ */
+
+
+ parser p = new parser(lexer);
+ p.parse();
+
+ }
+
+}
diff --git a/Test/com/analizador/var/Var.cup b/Test/com/analizador/var/Var.cup
new file mode 100644
index 0000000..18039cb
--- /dev/null
+++ b/Test/com/analizador/var/Var.cup
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR E COMPILADOR). ////
+* BY: ANDREW NETO ////
+* 19/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////////
+package com.analizador.var;
+
+import java_cup.runtime.*;
+
+parser code
+{:
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+:}
+
+terminal VAR;
+terminal ID;
+terminal TIPO_VARIAVEL, ADD_ATTR_VAR, SEPARADOR;
+
+
+non terminal estrutura,variaveis, instanciacao;
+non terminal String listagem;
+
+
+/* ELIMINAR CONFLIO */
+precedence left SEPARADOR;
+
+
+estrutura ::= VAR variaveis | error {: System.out.println("Detalhe: Erro de estruturacao. Exemplo de estruturacao.: var variavel1,variavel2 : tipo_de_variavel"); :};
+
+variaveis ::= variaveis instanciacao | instanciacao | error {: :};
+
+instanciacao ::= listagem:e ADD_ATTR_VAR TIPO_VARIAVEL:x {: System.out.println(x+" "+ e +";"); :} ;
+
+listagem ::= listagem:e1 SEPARADOR listagem:e2 {: RESULT = (String) e1+","+e2; :} | ID:value /* PARA ATRIBUIR O VALOR DO ID EM LISTAGEM */ {: RESULT = (String) value; :};
\ No newline at end of file
diff --git a/Test/com/analizador/var/Var.flex b/Test/com/analizador/var/Var.flex
new file mode 100644
index 0000000..bac016d
--- /dev/null
+++ b/Test/com/analizador/var/Var.flex
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////
+/* ////
+* DECLARACAO DE VARIAVEIS EM PORTUGOL (ANALIZADOR LEXICO). ////
+* BY: ANDREW NETO ////
+* 19/06/2014 ////
+*/ ////
+////////////////////////////////////////////////////////////////////
+
+package com.analizador.var;
+
+import java_cup.runtime.*;
+
+
+%%
+%cup
+%line
+%char
+%column
+
+%{
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+%}
+
+caracters = [A-Za-z]
+numerais = [0-9]
+alphanumeric = {caracters}|{numerais}
+outros = [_]
+ids = {caracters}({alphanumeric}|{outros})*
+espaco = [\n\r\ \t]
+nova_linha = \r|\n|\r\n
+
+
+%%
+
+(var|VAR) { return newSym(sym.VAR,yytext());}
+
+(inteiro|INTEIRO) { return newSym(sym.TIPO_VARIAVEL,"int");}
+(real|REAL) { return newSym(sym.TIPO_VARIAVEL,"float");}
+(caracter|CARACTER) { return newSym(sym.TIPO_VARIAVEL,"String");}
+
+":" { return newSym(sym.ADD_ATTR_VAR,yytext());}
+"," { return newSym(sym.SEPARADOR,yytext());}
+
+{ids} { return newSym(sym.ID,(String) yytext());}
+{espaco} {/*IGNORAR*/}
+{nova_linha} {/*IGNORAR*/}
+
+<aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\1\11\11\1\2\11\40\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[47];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 122) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { System.out.println("Illegal char, '" + yytext() +"' line: " + yyline + ", column: " + yychar);
+ }
+ case 10: break;
+ case 2:
+ { return newSym(sym.ID,(String) yytext());
+ }
+ case 11: break;
+ case 3:
+ { /*IGNORAR*/
+ }
+ case 12: break;
+ case 4:
+ { return newSym(sym.ADD_ATTR_VAR,yytext());
+ }
+ case 13: break;
+ case 5:
+ { return newSym(sym.SEPARADOR,yytext());
+ }
+ case 14: break;
+ case 6:
+ { return newSym(sym.VAR,yytext());
+ }
+ case 15: break;
+ case 7:
+ { return newSym(sym.TIPO_VARIAVEL,"float");
+ }
+ case 16: break;
+ case 8:
+ { return newSym(sym.TIPO_VARIAVEL,"int");
+ }
+ case 17: break;
+ case 9:
+ { return newSym(sym.TIPO_VARIAVEL,"String");
+ }
+ case 18: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/var/Yylex.java~ b/Test/com/analizador/var/Yylex.java~
new file mode 100644
index 0000000..f571a73
--- /dev/null
+++ b/Test/com/analizador/var/Yylex.java~
@@ -0,0 +1,696 @@
+/* The following code was generated by JFlex 1.5.1 */
+
+package com.anailizador.var;
+
+import java_cup.runtime.*;
+
+
+
+/**
+ * This class is a scanner generated by
+ * JFlex 1.5.1
+ * from the specification file C:/Users/Andrew/Documents/NetBeansProjects/portugol-projeto/Test/com/anailizador/var/var.flex
+ */
+class Yylex implements java_cup.runtime.Scanner {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\3\1\5\1\34\1\34\1\4\22\0\1\3\13\0\1\33"+
+ "\3\0\12\2\1\32\6\0\1\12\1\1\1\31\1\1\1\24\3\1"+
+ "\1\21\2\1\1\27\1\1\1\22\1\25\2\1\1\13\1\1\1\23"+
+ "\1\1\1\11\4\1\4\0\1\2\1\0\1\7\1\1\1\30\1\1"+
+ "\1\17\3\1\1\14\2\1\1\26\1\1\1\15\1\20\2\1\1\10"+
+ "\1\1\1\16\1\1\1\6\4\1\12\0\1\34\u1fa2\0\1\34\1\34"+
+ "\udfd6\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\1\0\1\1\1\2\2\3\10\2\1\4\1\5\10\2"+
+ "\1\6\6\2\1\7\14\2\1\10\2\2\1\11";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[47];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\35\0\72\0\35\0\127\0\164\0\221\0\256"+
+ "\0\313\0\350\0\u0105\0\u0122\0\u013f\0\35\0\35\0\u015c"+
+ "\0\u0179\0\u0196\0\u01b3\0\u01d0\0\u01ed\0\u020a\0\u0227\0\72"+
+ "\0\u0244\0\u0261\0\u027e\0\u029b\0\u02b8\0\u02d5\0\72\0\u02f2"+
+ "\0\u030f\0\u032c\0\u0349\0\u0366\0\u0383\0\u03a0\0\u03bd\0\u03da"+
+ "\0\u03f7\0\u0414\0\u0431\0\72\0\u044e\0\u046b\0\72";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[47];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\1\2\1\3\1\2\1\4\1\5\1\4\1\6\1\3"+
+ "\1\7\1\10\1\3\1\11\1\12\4\3\1\13\6\3"+
+ "\1\14\1\15\1\16\1\17\37\0\2\3\3\0\24\3"+
+ "\10\0\1\4\30\0\2\3\3\0\1\3\1\20\22\3"+
+ "\4\0\2\3\3\0\11\3\1\21\12\3\4\0\2\3"+
+ "\3\0\4\3\1\22\17\3\4\0\2\3\3\0\16\3"+
+ "\1\23\5\3\4\0\2\3\3\0\7\3\1\24\14\3"+
+ "\4\0\2\3\3\0\14\3\1\25\7\3\4\0\2\3"+
+ "\3\0\1\3\1\26\22\3\4\0\2\3\3\0\4\3"+
+ "\1\27\17\3\4\0\2\3\3\0\2\3\1\30\21\3"+
+ "\4\0\2\3\3\0\1\3\1\31\22\3\4\0\2\3"+
+ "\3\0\5\3\1\30\16\3\4\0\2\3\3\0\4\3"+
+ "\1\32\17\3\4\0\2\3\3\0\10\3\1\33\13\3"+
+ "\4\0\2\3\3\0\15\3\1\34\6\3\4\0\2\3"+
+ "\3\0\2\3\1\35\21\3\4\0\2\3\3\0\5\3"+
+ "\1\36\16\3\4\0\2\3\3\0\20\3\1\37\3\3"+
+ "\4\0\2\3\3\0\21\3\1\37\2\3\4\0\2\3"+
+ "\3\0\11\3\1\40\12\3\4\0\2\3\3\0\16\3"+
+ "\1\41\5\3\4\0\2\3\3\0\1\3\1\42\22\3"+
+ "\4\0\2\3\3\0\4\3\1\43\17\3\4\0\2\3"+
+ "\3\0\6\3\1\44\15\3\4\0\2\3\3\0\13\3"+
+ "\1\45\10\3\4\0\2\3\3\0\22\3\1\46\1\3"+
+ "\4\0\2\3\3\0\23\3\1\47\4\0\2\3\3\0"+
+ "\2\3\1\50\21\3\4\0\2\3\3\0\5\3\1\51"+
+ "\16\3\4\0\2\3\3\0\10\3\1\52\13\3\4\0"+
+ "\2\3\3\0\15\3\1\53\6\3\4\0\2\3\3\0"+
+ "\12\3\1\54\11\3\4\0\2\3\3\0\17\3\1\54"+
+ "\4\3\4\0\2\3\3\0\11\3\1\55\12\3\4\0"+
+ "\2\3\3\0\16\3\1\56\5\3\4\0\2\3\3\0"+
+ "\2\3\1\57\21\3\4\0\2\3\3\0\5\3\1\57"+
+ "\16\3\3\0";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[1160];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\1\0\1\11\1\1\1\11\11\1\2\11\40\1";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[47];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /* user code: */
+
+ Symbol newSym(int tokenId) {
+ return new Symbol(tokenId , yyline, yycolumn);
+ }
+
+ Symbol newSym(int tokenId, Object value) {
+ return new Symbol(tokenId , yyline, yycolumn, value);
+ }
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ Yylex(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ Yylex(java.io.InputStream in) {
+ this(new java.io.InputStreamReader
+ (in, java.nio.charset.Charset.forName("UTF-8")));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 122) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return false
, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * cannot be reused (internal buffer is discarded and lost).
+ * Lexical state is set to ZZ_INITIAL.
+ *
+ * Internal scan buffer is resized down to its initial length, if it has grown.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ if (zzBuffer.length > ZZ_BUFFERSIZE)
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position pos from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void zzDoEOF() throws java.io.IOException {
+ if (!zzEOFDone) {
+ zzEOFDone = true;
+ yyclose();
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ boolean zzR = false;
+ for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
+ zzCurrentPosL++) {
+ switch (zzBufferL[zzCurrentPosL]) {
+ case '\u000B':
+ case '\u000C':
+ case '\u0085':
+ case '\u2028':
+ case '\u2029':
+ yyline++;
+ yycolumn = 0;
+ zzR = false;
+ break;
+ case '\r':
+ yyline++;
+ yycolumn = 0;
+ zzR = true;
+ break;
+ case '\n':
+ if (zzR)
+ zzR = false;
+ else {
+ yyline++;
+ yycolumn = 0;
+ }
+ break;
+ default:
+ zzR = false;
+ yycolumn++;
+ }
+ }
+
+ if (zzR) {
+ // peek one character ahead if it is \n (if we have counted one line too much)
+ boolean zzPeek;
+ if (zzMarkedPosL < zzEndReadL)
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ else if (zzAtEOF)
+ zzPeek = false;
+ else {
+ boolean eof = zzRefill();
+ zzEndReadL = zzEndRead;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ if (eof)
+ zzPeek = false;
+ else
+ zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+ }
+ if (zzPeek) yyline--;
+ }
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+ // set up zzAction for empty match case:
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ }
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 1:
+ { System.out.println("Illegal char, '" + yytext() +"' line: " + yyline + ", column: " + yychar);
+ }
+ case 10: break;
+ case 2:
+ { return newSym(sym.ID,(String) yytext());
+ }
+ case 11: break;
+ case 3:
+ { /*IGNORAR*/
+ }
+ case 12: break;
+ case 4:
+ { return newSym(sym.ADD_ATTR_VAR);
+ }
+ case 13: break;
+ case 5:
+ { return newSym(sym.SEPARADOR);
+ }
+ case 14: break;
+ case 6:
+ { return newSym(sym.VAR);
+ }
+ case 15: break;
+ case 7:
+ { return newSym(sym.TIPO_VARIAVEL,"float");
+ }
+ case 16: break;
+ case 8:
+ { return newSym(sym.TIPO_VARIAVEL,"int");
+ }
+ case 17: break;
+ case 9:
+ { return newSym(sym.TIPO_VARIAVEL,"String");
+ }
+ case 18: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ zzDoEOF();
+ {
+ return newSym(sym.EOF);
+ }
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/Test/com/analizador/var/java_cup.jar b/Test/com/analizador/var/java_cup.jar
new file mode 100644
index 0000000..73ffa0b
Binary files /dev/null and b/Test/com/analizador/var/java_cup.jar differ
diff --git a/Test/com/analizador/var/parser.java b/Test/com/analizador/var/parser.java
new file mode 100644
index 0000000..f1f61c0
--- /dev/null
+++ b/Test/com/analizador/var/parser.java
@@ -0,0 +1,239 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 12:54:33 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.var;
+
+import java_cup.runtime.*;
+
+/** CUP v0.11a beta 20060608 generated parser.
+ * @version Fri Jun 20 12:54:33 BRT 2014
+ */
+public class parser extends java_cup.runtime.lr_parser {
+
+ /** Default constructor. */
+ public parser() {super();}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s) {super(s);}
+
+ /** Constructor which sets the default scanner. */
+ public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+ /** Production table. */
+ protected static final short _production_table[][] =
+ unpackFromStrings(new String[] {
+ "\000\011\000\002\002\004\000\002\002\004\000\002\002" +
+ "\003\000\002\003\004\000\002\003\003\000\002\003\003" +
+ "\000\002\004\005\000\002\005\005\000\002\005\003" });
+
+ /** Access to production table. */
+ public short[][] production_table() {return _production_table;}
+
+ /** Parse-action table. */
+ protected static final short[][] _action_table =
+ unpackFromStrings(new String[] {
+ "\000\017\000\006\003\005\004\004\001\002\000\006\003" +
+ "\012\005\010\001\002\000\004\002\uffff\001\002\000\004" +
+ "\002\007\001\002\000\004\002\000\001\002\000\006\007" +
+ "\ufff9\010\ufff9\001\002\000\006\002\ufffd\005\ufffd\001\002" +
+ "\000\006\002\ufffc\005\ufffc\001\002\000\006\002\001\005" +
+ "\010\001\002\000\006\007\016\010\015\001\002\000\004" +
+ "\005\010\001\002\000\004\006\017\001\002\000\006\002" +
+ "\ufffb\005\ufffb\001\002\000\006\007\ufffa\010\ufffa\001\002" +
+ "\000\006\002\ufffe\005\ufffe\001\002" });
+
+ /** Access to parse-action table. */
+ public short[][] action_table() {return _action_table;}
+
+ /** reduce_goto
table. */
+ protected static final short[][] _reduce_table =
+ unpackFromStrings(new String[] {
+ "\000\017\000\004\002\005\001\001\000\010\003\012\004" +
+ "\010\005\013\001\001\000\002\001\001\000\002\001\001" +
+ "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
+ "\002\001\001\000\006\004\020\005\013\001\001\000\002" +
+ "\001\001\000\004\005\017\001\001\000\002\001\001\000" +
+ "\002\001\001\000\002\001\001\000\002\001\001" });
+
+ /** Access to reduce_goto
table. */
+ public short[][] reduce_table() {return _reduce_table;}
+
+ /** Instance of action encapsulation class. */
+ protected CUP$parser$actions action_obj;
+
+ /** Action encapsulation object initializer. */
+ protected void init_actions()
+ {
+ action_obj = new CUP$parser$actions(this);
+ }
+
+ /** Invoke a user supplied parse action. */
+ public java_cup.runtime.Symbol do_action(
+ int act_num,
+ java_cup.runtime.lr_parser parser,
+ java.util.Stack stack,
+ int top)
+ throws java.lang.Exception
+ {
+ /* call code in generated class */
+ return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
+ }
+
+ /** Indicates start state. */
+ public int start_state() {return 0;}
+ /** Indicates start production. */
+ public int start_production() {return 1;}
+
+ /** EOF
Symbol index. */
+ public int EOF_sym() {return 0;}
+
+ /** error
Symbol index. */
+ public int error_sym() {return 1;}
+
+
+
+ public static void main(String args[]) throws Exception{
+ new parser(new Yylex(System.in)).parse();
+ }
+ public void syntax_error(Symbol s){
+ report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: \""+s.value+"\"",null);
+ }
+
+}
+
+/** Cup generated class to encapsulate user supplied action code.*/
+class CUP$parser$actions {
+ private final parser parser;
+
+ /** Constructor */
+ CUP$parser$actions(parser parser) {
+ this.parser = parser;
+ }
+
+ /** Method with the actual generated action code. */
+ public final java_cup.runtime.Symbol CUP$parser$do_action(
+ int CUP$parser$act_num,
+ java_cup.runtime.lr_parser CUP$parser$parser,
+ java.util.Stack CUP$parser$stack,
+ int CUP$parser$top)
+ throws java.lang.Exception
+ {
+ /* Symbol object for return from actions */
+ java_cup.runtime.Symbol CUP$parser$result;
+
+ /* select the action based on the action number */
+ switch (CUP$parser$act_num)
+ {
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 8: // listagem ::= ID
+ {
+ String RESULT =null;
+ int valueleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int valueright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Object value = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = (String) value;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("listagem",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 7: // listagem ::= listagem SEPARADOR listagem
+ {
+ String RESULT =null;
+ int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ RESULT = (String) e1+","+e2;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("listagem",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 6: // instanciacao ::= listagem ADD_ATTR_VAR TIPO_VARIAVEL
+ {
+ Object RESULT =null;
+ int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
+ int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
+ String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
+ int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
+ int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
+ Object x = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
+ System.out.println(x+" "+ e +";");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 5: // variaveis ::= error
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("variaveis",1, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 4: // variaveis ::= instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("variaveis",1, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 3: // variaveis ::= variaveis instanciacao
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("variaveis",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 2: // estrutura ::= error
+ {
+ Object RESULT =null;
+ System.out.println("Detalhe: Erro de estruturacao. Exemplo de estruturacao.: var variavel1,variavel2 : tipo_de_variavel");
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("estrutura",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 1: // $START ::= estrutura EOF
+ {
+ Object RESULT =null;
+ int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
+ int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
+ Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
+ RESULT = start_val;
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ /* ACCEPT */
+ CUP$parser$parser.done_parsing();
+ return CUP$parser$result;
+
+ /*. . . . . . . . . . . . . . . . . . . .*/
+ case 0: // estrutura ::= VAR variaveis
+ {
+ Object RESULT =null;
+
+ CUP$parser$result = parser.getSymbolFactory().newSymbol("estrutura",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
+ }
+ return CUP$parser$result;
+
+ /* . . . . . .*/
+ default:
+ throw new Exception(
+ "Invalid action number found in internal parse table");
+
+ }
+ }
+}
+
diff --git a/Test/com/analizador/var/sym.java b/Test/com/analizador/var/sym.java
new file mode 100644
index 0000000..7b044d0
--- /dev/null
+++ b/Test/com/analizador/var/sym.java
@@ -0,0 +1,20 @@
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11a beta 20060608
+// Fri Jun 20 12:54:33 BRT 2014
+//----------------------------------------------------
+
+package com.analizador.var;
+
+/** CUP generated class containing symbol constants. */
+public class sym {
+ /* terminals */
+ public static final int ID = 3;
+ public static final int VAR = 2;
+ public static final int error = 1;
+ public static final int SEPARADOR = 6;
+ public static final int TIPO_VARIAVEL = 4;
+ public static final int ADD_ATTR_VAR = 5;
+ public static final int EOF = 0;
+}
+
diff --git a/Test/com/classes/editor/EditorTxT.java b/Test/com/classes/editor/EditorTxT.java
new file mode 100644
index 0000000..3a6d264
--- /dev/null
+++ b/Test/com/classes/editor/EditorTxT.java
@@ -0,0 +1,169 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.classes.editor;
+
+import com.classes.editor.HighlightingStyledDocument;
+import com.classes.editor.LinePainter;
+import com.classes.editor.TextLineNumber;
+import com.classes.editor.UndoAndRedo;
+import static com.forms.Editor.tab;
+import java.awt.Color;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+import javax.swing.event.UndoableEditEvent;
+import javax.swing.event.UndoableEditListener;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyleContext;
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+import javax.swing.undo.UndoManager;
+
+/**
+ *
+ * @author SIMONETO-2
+ */
+public class EditorTxT {
+
+ /*
+ * VARIAVEIS
+ */
+ private JTextPane campo = null;
+ private final int tabSize = 5;
+ private TextLineNumber tln = null;
+ private final HighlightingStyledDocument highlight = new HighlightingStyledDocument();
+ private LinePainter painter = null;
+ private UndoAndRedo undoRedo = null;
+
+ private UndoManager undoManager = new UndoManager();
+ /*
+ * FUNCAO PRINCIPAL
+ */
+
+ public EditorTxT(final JTextPane campo, JScrollPane scroll) {
+ //SETANDO CAMPO VARIAVEL
+ this.campo = campo;
+
+ //MUDANDO COR DO CURSOR
+ this.campo.setCaretColor(Color.WHITE);
+
+ //APLICANDO A NUMERCAO DE LINHAS
+ tln = new TextLineNumber(this.campo, 2);
+ scroll.setRowHeaderView(tln);
+
+ //APLICANDO O FUCUS DE LINHA
+ painter = new LinePainter(this.campo);
+ painter.setColor(Color.decode("#353535"));
+
+
+ //CONFIGURACOES DE COR E ESTILO DO EDTITOR
+ SimpleAttributeSet syle_comentario = new SimpleAttributeSet();
+ syle_comentario.addAttribute(StyleConstants.Foreground, Color.decode("#8f908a"));
+ //syle_comentario.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
+
+ SimpleAttributeSet style_key_principais = new SimpleAttributeSet();
+ style_key_principais.addAttribute(StyleConstants.Foreground, Color.decode("#66d9ef"));
+ style_key_principais.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
+
+ SimpleAttributeSet style_funcoes = new SimpleAttributeSet();
+ style_funcoes.addAttribute(StyleConstants.Foreground, Color.decode("#f92672"));
+ //style_funcoes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
+
+ SimpleAttributeSet syle_string = new SimpleAttributeSet();
+ syle_string.addAttribute(StyleConstants.Foreground, Color.decode("#e6db74"));
+
+ SimpleAttributeSet style_default = new SimpleAttributeSet();
+ style_default.addAttribute(StyleConstants.Foreground, Color.WHITE);
+
+ highlight.setCommentStyle(syle_comentario);
+ highlight.setDefaultStyle(style_default);
+ highlight.setKeywordStyle(style_key_principais);
+ highlight.setEnvironmentWordStyle(style_funcoes);
+ highlight.setStringStyle(syle_string);
+
+
+ this.campo.setDocument(highlight);
+
+ //SETANDO TAMANHO DA TAB
+ setTabSize(this.campo, tabSize);
+
+ //SETANDO O UNDO MANAGE
+ this.campo.getDocument().addUndoableEditListener(new UndoableEditListener() {
+ @Override
+ public void undoableEditHappened(UndoableEditEvent e) {
+ undoManager.addEdit(e.getEdit());
+ updateUndoRedo();
+ }
+ });
+
+ /*
+ //EVENTO DE MODIFICAO DO TXT
+ this.campo.getDocument().addDocumentListener(new DocumentListener() {
+
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ //System.out.println("nao modificado "+campo.getName());
+ }
+
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ //System.out.println("modificado "+campo.getName());
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent arg0) {
+ //System.out.println("modificado "+campo.getName());
+ }
+ });
+ */
+ }
+
+ /*
+ * FUNCOES PARA SETAR O CTRL+Z E CTRL+V
+ */
+ public void setUndo(){
+ if(undoManager.canUndo()) undoManager.undo();
+ }
+ public void setRedo(){
+ if(undoManager.canRedo()) undoManager.redo();
+ }
+
+ public boolean canUndo(){
+ return undoManager.canUndo();
+ }
+
+ public boolean canRedo(){
+ return undoManager.canRedo();
+ }
+ public void updateUndoRedo(){
+ //System.out.println(canUndo());
+ //jMenuItem8.setEnabled(canRedo());
+ //jMenuItem7.setEnabled(canUndo());
+ }
+
+
+ /*
+ * FUNCAO PARA SETAR O TABSIZE
+ */
+ public void setTabSize(JTextPane pane, int size) {
+ String tab = "";
+ for (int i = 0; i < size; i++) {
+ tab += " ";
+ }
+ float f = (float) pane.getFontMetrics(pane.getFont()).stringWidth(tab);
+ TabStop[] tabs = new TabStop[500]; // this sucks
+
+ for (int i = 0; i < tabs.length; i++) {
+ tabs[i] = new TabStop(f * (i + 1), TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
+ }
+
+ TabSet tabset = new TabSet(tabs);
+ StyleContext sc = StyleContext.getDefaultStyleContext();
+ AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
+ pane.setParagraphAttributes(aset, false);
+ }
+}
diff --git a/Test/com/classes/editor/HighlightingStyledDocument.java b/Test/com/classes/editor/HighlightingStyledDocument.java
new file mode 100644
index 0000000..c77c141
--- /dev/null
+++ b/Test/com/classes/editor/HighlightingStyledDocument.java
@@ -0,0 +1,342 @@
+package com.classes.editor;
+
+import static com.forms.Editor.files_opens;
+import static com.forms.Editor.tab;
+import java.awt.Color;
+import java.util.*;
+import java.util.regex.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+/**
+ * Highlights jython syntax in a Document Created for the Jython Environment for
+ * Students (JES) Hilghights keywords and environment words that are defined for
+ * it. It will also highlight single-line comments that start with '#', and
+ * single-line strings that start with "'" or '"'.
+ *
+ * @author Adam Wilson, awilson@cc.gatech.edu
+ */
+public class HighlightingStyledDocument extends DefaultStyledDocument {
+
+
+ //Portugol port = new Portugol();
+
+
+ /* Keyword text style */
+ private SimpleAttributeSet keywordStyle = new SimpleAttributeSet();
+
+ /* Environment word text style */
+ private SimpleAttributeSet environmentWordStyle = new SimpleAttributeSet();
+
+ /* Comment Style */
+ private SimpleAttributeSet commentStyle = new SimpleAttributeSet();
+
+ /* String style */
+ private SimpleAttributeSet stringStyle = new SimpleAttributeSet();
+
+ /* Default Style */
+ private SimpleAttributeSet defaultStyle = new SimpleAttributeSet();
+
+ /* Jython keywords */
+ private Vector keywords = new Vector();
+
+ /* Gutters */
+ private Vector gutters = new Vector();
+
+ /* Jython environment words */
+ private Vector environmentWords = new Vector();
+
+ /* Generated Regular expression for keywords */
+ private Pattern keyReg = Pattern.compile("");
+
+ /* Generated regular expression for environment words */
+ private Pattern envReg = Pattern.compile("inteiro|caracter|real|leia|se|entao|fimse|senao|enquanto|escreva");
+
+ /* Regular Expression for comments */
+ private Pattern commentReg = Pattern.compile("#++[^\n]*");
+
+ /* Regular Expression for double quote Strings */
+ private Pattern doubleStringReg = Pattern.compile("\"[^\n\"]*\"");
+
+ /* Regular Expression for single quote strings */
+ private Pattern singleStringReg = Pattern.compile("'[^\n']*'");
+
+ /* Regular Expression for string & comments */
+ /* "\\\"" - why not?!? \p" */
+ private Pattern stringComments = Pattern.compile("(\\/\\/[^\n]*|\"([^\n\"\\x5c]|(\\x5c\")|(\\x5c))*\"|'([^\n'\\x5c]|(\\x5c')|(\\x5c))*')");
+
+ /* Regular Expression to match multi-line strings */
+ private Pattern mlString = Pattern.compile("\"\"\".*\"\"\"", Pattern.DOTALL);
+
+ /* Regular Expression to match triple qoutes */
+ private Pattern triQuote = Pattern.compile("\"\"\"");
+
+ /**
+ * insertString Overrides the default method from DefaultStyledDocument.
+ * Calls appropriate syntax highlighting code and then class super.
+ * @throws javax.swing.text.BadLocationException
+ */
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ super.insertString(offs, str, a);
+ updateHighlightingInRange(offs, str.length());
+ }
+
+ /**
+ * fireRemoveUpdate Overrides the default method from DefaultStyledDocument.
+ * Calls appropriate syntax highlighting code and then class super.
+ *
+ * @param e the DocumentEvent
+ */
+ @Override
+ protected void fireRemoveUpdate(DocumentEvent e) {
+ int offset = e.getOffset();
+ int length = e.getLength();
+ updateHighlightingInRange(offset - 1, 0);
+ super.fireRemoveUpdate(e);
+ }
+
+ /**
+ * Method: updateHighlightingInRange Looks at a given range of text in a
+ * document and highlights it according to keywords, environment, strings,
+ * and comments.
+ *
+ * @param offset Where in the document the change started
+ * @param length The length of change measured from the offset
+ */
+ public void updateHighlightingInRange(int offset, int length) {
+ try {
+ String textAll = getText(0, getLength());
+ int start = getLineStart(textAll, offset);
+ int end = getLineEnd(textAll, offset + length);
+ String text = getText(start, end - start);
+ setCharacterAttributes(start, end - start, defaultStyle, true);
+
+ //Do Block Highlighting:
+ //Find and highlight keywords:
+ Matcher m = keyReg.matcher(text);
+ while (m.find()) {
+ setCharacterAttributes(start + m.start(), m.end() - m.start(), keywordStyle, true);
+ }
+
+ //Find and highlight keywords:
+ m = envReg.matcher(text);
+ while (m.find()) {
+ setCharacterAttributes(start + m.start(), m.end() - m.start(), environmentWordStyle, true);
+ }
+
+ //Find and highlight Comments and strings:
+ m = stringComments.matcher(text);
+ while (m.find()) {
+ //System.out.println("Matched: " + getText(start + m.start(), m.end() - m.start()));
+ if (text.charAt(m.start()) == '/') {
+ setCharacterAttributes(start + m.start(), m.end() - m.start(), commentStyle, true);
+ }
+ if (text.charAt(m.start()) == '\'' || text.charAt(m.start()) == '"') {
+ setCharacterAttributes(start + m.start(), m.end() - m.start(), stringStyle, true);
+ }
+ }
+ //Matches Multi-line strings starting with triple quotes:
+ /*m = mlString.matcher(textAll);
+ while(m.find())
+ setCharacterAttributes(m.start(), m.end() - m.start(), stringStyle, true);*/
+ } catch (BadLocationException e) {
+ }
+ }
+
+ /**
+ * getLineStart Finds the start of a line in a document. Takes in an offset
+ * and finds the index of the beginning of that line.
+ *
+ * @param text The text to find the start of the line in
+ * @param offset An index of a character on that line
+ */
+ private int getLineStart(String text, int offset) {
+ while (offset > 0) {
+ if (text.charAt(offset) == '\n') {
+ return (offset + 1);
+ }
+ offset--;
+ }
+ return offset;
+ }
+
+ /**
+ * getLineEnd Takes in an index and finds the offset of the end of the line
+ *
+ * @param text The text to find the end of the line in
+ * @param offset An index of a character on that line.
+ */
+ private int getLineEnd(String text, int offset) {
+ while (offset < text.length()) {
+ if (text.charAt(offset) == '\n') {
+ return (offset);
+ }
+ offset++;
+ }
+ return offset;
+ }
+
+ /**
+ * Method: isString Looks at a location in the given document and determines
+ * if that location is inside a string. Supports """ for multi-line strings.
+ *
+ * @param doc The document to look in for the text
+ * @param offset The location to check for string-ness
+ * @return True for is a string, false for is not a string
+ */
+ private boolean isString(int offset) {
+ return false;
+ }
+
+ /**
+ * Method: isComment Looks at a location inside a document and determines if
+ * it is a comment.
+ *
+ * @param doc The document to look in for the text
+ * @param offset The location to check for stringness
+ * @return True for is a comment, false for is not a comment
+ */
+ private boolean isComment(int offset) {
+ return false;
+ }
+
+ /**
+ * Method: setKeywords Sets a collection of keywords to highlight.
+ *
+ * @param words An array of all the words
+ */
+ public void setKeywords(String[] words) {
+ keywords.clear();
+ for (int i = 0; i < words.length; i++) {
+ keywords.add(words[i]);
+ }
+ compileKeywords();
+ }
+
+ /**
+ * Method: setEnvironmentWords Sets a collection of environment words to
+ * highlight.
+ *
+ * @param words An array of all the words
+ */
+ public void setEnvironmentWords(String[] words) {
+ environmentWords.clear();
+ for (int i = 0; i < words.length; i++) {
+ environmentWords.add(words[i]);
+ }
+ compileEnvironmentWords();
+ }
+
+ /**
+ * Method: addKeyword Adds a keyword to the Vector of keywords.
+ *
+ * @param word The word to add
+ */
+ public void addKeyword(String word) {
+ keywords.add(word);
+ compileKeywords();
+ }
+
+ /**
+ * Method: addEnvironmentWord Adds an environment word to the Vector of
+ * environment words.
+ *
+ * @param word The word to add
+ */
+ public void addEnvironmentWord(String word) {
+ environmentWords.add(word);
+ compileEnvironmentWords();
+ }
+
+ /**
+ * Method: setKeywordStyle Sets the style of text to use for keywords
+ *
+ * @param style The new text style
+ */
+ public void setKeywordStyle(SimpleAttributeSet style) {
+ keywordStyle = style;
+ }
+
+ /**
+ * Method: setEnvironmentWordStyle Sets the style of text to use for
+ * environment words
+ *
+ * @param style The new text style
+ */
+ public void setEnvironmentWordStyle(SimpleAttributeSet style) {
+ environmentWordStyle = style;
+ }
+
+ /**
+ * Method: setCommentStyle Sets the style of text to use for comments
+ *
+ * @param style The new text style
+ */
+ public void setCommentStyle(SimpleAttributeSet style) {
+ commentStyle = style;
+ }
+
+ /**
+ * Method: setStringStyle Sets the style of text to use for strings
+ *
+ * @param style The new text style
+ */
+ public void setStringStyle(SimpleAttributeSet style) {
+ stringStyle = style;
+ }
+
+ /**
+ * Method: setDefaultStyle Sets the default style of text to use
+ *
+ * @param style The new text style
+ */
+ public void setDefaultStyle(SimpleAttributeSet style) {
+ defaultStyle = style;
+ }
+
+ /**
+ * compileKeywords Recompiles the regular expression used for matching key
+ * words. Takes the collection of keywords and generates a regular
+ * expression string. It then compiles that string into the Pattern class
+ * and stores it in keyReg. Example: if the keywords were "if" and "for",
+ * the regular expression would be: "\W(if|for)\W". The \W isolate the
+ * keywords by non-word characters.
+ */
+ private void compileKeywords() {
+ String exp = new String();
+ exp = "\\b("; //Start the expression to match non-word characters,
+ //i.e. [^a-zA-Z0-9], and then start the OR block.
+ for (int i = 0; i < keywords.size(); i++) {
+ if (i == 0) {
+ exp = exp + ((String) keywords.elementAt(i)).trim();
+ }
+ exp = exp + "|" + ((String) keywords.elementAt(i)).trim();
+ }
+ exp = exp + ")\\b";
+ keyReg = Pattern.compile(exp);
+ }
+
+ /**
+ * compileEnvironmentWords Recompiles the regular expression used for
+ * matching environment words. Takes the collection of environment words and
+ * generates a regular expression string. It then compiles that string into
+ * the Pattern class and stores it in envReg. Example: if the envwords were
+ * "if" and "for", the regular expression would be: "\W(if|for)\W". The \W
+ * isolate the envwords by non-word characters.
+ */
+ private void compileEnvironmentWords() {
+ String exp = new String();
+ exp = "\\b("; //Start the expression to match non-word characters,
+ //i.e. [^a-zA-Z0-9], and then start the OR block.
+ for (int i = 0; i < environmentWords.size(); i++) {
+ if (i == 0) {
+ exp = exp + ((String) environmentWords.elementAt(i)).trim();
+ }
+ exp = exp + "|" + ((String) environmentWords.elementAt(i)).trim();
+ }
+ exp = exp + ")\\b";
+ envReg = Pattern.compile(exp);
+ }
+
+}//END OF HighlightingStyledDocument Class
diff --git a/Test/com/classes/editor/LinePainter.java b/Test/com/classes/editor/LinePainter.java
new file mode 100644
index 0000000..bce86fe
--- /dev/null
+++ b/Test/com/classes/editor/LinePainter.java
@@ -0,0 +1,166 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.classes.editor;
+
+/**
+ *
+ * @author SIMONETO-2
+ */
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+/*
+ * Track the movement of the Caret by painting a background line at the
+ * current caret position.
+ */
+public class LinePainter
+ implements Highlighter.HighlightPainter, CaretListener, MouseListener, MouseMotionListener
+{
+ private JTextComponent component;
+
+ private Color color;
+
+ private Rectangle lastView;
+
+ /*
+ * The line color will be calculated automatically by attempting
+ * to make the current selection lighter by a factor of 1.2.
+ *
+ * @param component text component that requires background line painting
+ */
+ public LinePainter(JTextComponent component)
+ {
+ this(component, null);
+ setLighter(component.getSelectionColor());
+ }
+
+ /*
+ * Manually control the line color
+ *
+ * @param component text component that requires background line painting
+ * @param color the color of the background line
+ */
+ public LinePainter(JTextComponent component, Color color)
+ {
+ this.component = component;
+ setColor( color );
+
+ // Add listeners so we know when to change highlighting
+
+ component.addCaretListener( this );
+ component.addMouseListener( this );
+ component.addMouseMotionListener( this );
+
+ // Turn highlighting on by adding a dummy highlight
+
+ try
+ {
+ component.getHighlighter().addHighlight(0, 0, this);
+ }
+ catch(BadLocationException ble) {}
+ }
+
+ /*
+ * You can reset the line color at any time
+ *
+ * @param color the color of the background line
+ */
+ public void setColor(Color color)
+ {
+ this.color = color;
+ }
+
+ /*
+ * Calculate the line color by making the selection color lighter
+ *
+ * @return the color of the background line
+ */
+ public void setLighter(Color color)
+ {
+ int red = Math.min(255, (int)(color.getRed() * 1.2));
+ int green = Math.min(255, (int)(color.getGreen() * 1.2));
+ int blue = Math.min(255, (int)(color.getBlue() * 1.2));
+ setColor(new Color(red, green, blue));
+ }
+
+ // Paint the background highlight
+
+ public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c)
+ {
+ try
+ {
+ Rectangle r = c.modelToView(c.getCaretPosition());
+ g.setColor( color );
+ g.fillRect(0, r.y, c.getWidth(), r.height);
+
+ if (lastView == null)
+ lastView = r;
+ }
+ catch(BadLocationException ble) {System.out.println(ble);}
+ }
+
+ /*
+ * Caret position has changed, remove the highlight
+ */
+ private void resetHighlight()
+ {
+ // Use invokeLater to make sure updates to the Document are completed,
+ // otherwise Undo processing causes the modelToView method to loop.
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ int offset = component.getCaretPosition();
+ Rectangle currentView = component.modelToView(offset);
+
+ // Remove the highlighting from the previously highlighted line
+
+ if (lastView.y != currentView.y)
+ {
+ component.repaint(0, lastView.y, component.getWidth(), lastView.height);
+ lastView = currentView;
+ }
+ }
+ catch(BadLocationException ble) {}
+ }
+ });
+ }
+
+ // Implement CaretListener
+
+ public void caretUpdate(CaretEvent e)
+ {
+ resetHighlight();
+ }
+
+ // Implement MouseListener
+
+ public void mousePressed(MouseEvent e)
+ {
+ resetHighlight();
+ }
+
+ public void mouseClicked(MouseEvent e) {}
+ public void mouseEntered(MouseEvent e) {}
+ public void mouseExited(MouseEvent e) {}
+ public void mouseReleased(MouseEvent e) {}
+
+ // Implement MouseMotionListener
+
+ public void mouseDragged(MouseEvent e)
+ {
+ resetHighlight();
+ }
+
+ public void mouseMoved(MouseEvent e) {}
+}
diff --git a/Test/com/classes/editor/TextLineNumber.java b/Test/com/classes/editor/TextLineNumber.java
new file mode 100644
index 0000000..3045aad
--- /dev/null
+++ b/Test/com/classes/editor/TextLineNumber.java
@@ -0,0 +1,455 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.classes.editor;
+
+/**
+ *
+ * @author SIMONETO-2
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.*;
+import java.util.HashMap;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+/**
+ * This class will display line numbers for a related text component. The text
+ * component must use the same line height for each line. TextLineNumber
+ * supports wrapped lines and will highlight the line number of the current line
+ * in the text component.
+ *
+ * This class was designed to be used as a component added to the row header of
+ * a JScrollPane.
+ */
+public class TextLineNumber extends JPanel
+ implements CaretListener, DocumentListener, PropertyChangeListener {
+
+ public final static float LEFT = 0.0f;
+ public final static float CENTER = 0.5f;
+ public final static float RIGHT = 1.0f;
+
+ private final static Border OUTER = new MatteBorder(0, 0, 0, 0, Color.BLACK);
+
+ private final static int HEIGHT = Integer.MAX_VALUE - 1000000;
+
+ // Text component this TextTextLineNumber component is in sync with
+ private JTextComponent component;
+
+ // Properties that can be changed
+ private boolean updateFont;
+ private int borderGap;
+
+ private Color LineForeground;
+ private Color currentLineForeground;
+ private Color background;
+
+
+ private float digitAlignment;
+ private int minimumDisplayDigits;
+
+ // Keep history information to reduce the number of times the component
+ // needs to be repainted
+ private int lastDigits;
+ private int lastHeight;
+ private int lastLine;
+
+ private HashMapJFontChooser
class is a swing component
+ * for font selection.
+ * This class has JFileChooser
like APIs.
+ * The following code pops up a font chooser dialog.
+ * + * JFontChooser fontChooser = new JFontChooser(); + * int result = fontChooser.showDialog(parent); + * if (result == JFontChooser.OK_OPTION) + * { + * Font font = fontChooser.getSelectedFont(); + * System.out.println("Selected Font : " + font); + * } + *+ **/ +public class JFontChooser extends JComponent +{ + // class variables + /** + * Return value fromshowDialog()
. + * @see #showDialog + **/ + public static final int OK_OPTION = 0; + /** + * Return value fromshowDialog()
. + * @see #showDialog + **/ + public static final int CANCEL_OPTION = 1; + /** + * Return value fromshowDialog()
. + * @see #showDialog + **/ + //new java.awt.Font("Tahoma", 1, 11) + public static final int ERROR_OPTION = -1; + private static final Font DEFAULT_SELECTED_FONT = new Font("Tahoma", Font.PLAIN, 11); + private static final Font DEFAULT_FONT = new Font("Tahoma", Font.PLAIN, 11); + private static final int[] FONT_STYLE_CODES = + { + Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC + }; + private static final String[] DEFAULT_FONT_SIZE_STRINGS = + { + "8", "9", "10", "11", "12", "14", "16", "18", "20", + "22", "24", "26", "28", "36", "48", "72", + }; + + // instance variables + protected int dialogResultValue = ERROR_OPTION; + + + + private String[] fontStyleNames = null; + private String[] fontFamilyNames = null; + private String[] fontSizeStrings = null; + private JTextField fontFamilyTextField = null; + private JTextField fontStyleTextField = null; + private JTextField fontSizeTextField = null; + private JList fontNameList = null; + private JList fontStyleList = null; + private JList fontSizeList = null; + private JPanel fontNamePanel = null; + private JPanel fontStylePanel = null; + private JPanel fontSizePanel = null; + private JPanel samplePanel = null; + private JTextField sampleText = null; + + /** + * Constructs aJFontChooser
object. + **/ + public JFontChooser() + { + this(DEFAULT_FONT_SIZE_STRINGS); + } + + /** + * Constructs aJFontChooser
object using the given font size array. + * @param fontSizeStrings the array of font size string. + **/ + public JFontChooser(String[] fontSizeStrings) + { + if (fontSizeStrings == null) + { + fontSizeStrings = DEFAULT_FONT_SIZE_STRINGS; + } + this.fontSizeStrings = fontSizeStrings; + + JPanel selectPanel = new JPanel(); + selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.X_AXIS)); + selectPanel.add(getFontFamilyPanel()); + //selectPanel.add(getFontStylePanel()); + selectPanel.add(getFontSizePanel()); + + JPanel contentsPanel = new JPanel(); + contentsPanel.setLayout(new GridLayout(2, 1)); + contentsPanel.add(selectPanel, BorderLayout.NORTH); + contentsPanel.add(getSamplePanel(), BorderLayout.CENTER); + + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + this.add(contentsPanel); + this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + this.setSelectedFont(DEFAULT_SELECTED_FONT); + } + + public JTextField getFontFamilyTextField() + { + if (fontFamilyTextField == null) + { + fontFamilyTextField = new JTextField(); + fontFamilyTextField.addFocusListener( + new TextFieldFocusHandlerForTextSelection(fontFamilyTextField)); + fontFamilyTextField.addKeyListener( + new TextFieldKeyHandlerForListSelectionUpDown(getFontFamilyList())); + fontFamilyTextField.getDocument().addDocumentListener( + new ListSearchTextFieldDocumentHandler(getFontFamilyList())); + fontFamilyTextField.setFont(DEFAULT_FONT); + + } + return fontFamilyTextField; + } + + public JTextField getFontStyleTextField() + { + if (fontStyleTextField == null) + { + fontStyleTextField = new JTextField(); + fontStyleTextField.addFocusListener( + new TextFieldFocusHandlerForTextSelection(fontStyleTextField)); + fontStyleTextField.addKeyListener( + new TextFieldKeyHandlerForListSelectionUpDown(getFontStyleList())); + fontStyleTextField.getDocument().addDocumentListener( + new ListSearchTextFieldDocumentHandler(getFontStyleList())); + fontStyleTextField.setFont(DEFAULT_FONT); + } + return fontStyleTextField; + } + + public JTextField getFontSizeTextField() + { + if (fontSizeTextField == null) + { + fontSizeTextField = new JTextField(); + fontSizeTextField.addFocusListener( + new TextFieldFocusHandlerForTextSelection(fontSizeTextField)); + fontSizeTextField.addKeyListener( + new TextFieldKeyHandlerForListSelectionUpDown(getFontSizeList())); + fontSizeTextField.getDocument().addDocumentListener( + new ListSearchTextFieldDocumentHandler(getFontSizeList())); + fontSizeTextField.setFont(DEFAULT_FONT); + } + return fontSizeTextField; + } + + public JList getFontFamilyList() + { + if (fontNameList == null) + { + fontNameList = new JList(getFontFamilies()); + fontNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + fontNameList.addListSelectionListener( + new ListSelectionHandler(getFontFamilyTextField())); + fontNameList.setSelectedIndex(0); + fontNameList.setFont(DEFAULT_FONT); + fontNameList.setFocusable(false); + } + return fontNameList; + } + + public JList getFontStyleList() + { + if (fontStyleList == null) + { + fontStyleList = new JList(getFontStyleNames()); + fontStyleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + fontStyleList.addListSelectionListener( + new ListSelectionHandler(getFontStyleTextField())); + fontStyleList.setSelectedIndex(0); + fontStyleList.setFont(DEFAULT_FONT); + fontStyleList.setFocusable(false); + } + return fontStyleList; + } + + public JList getFontSizeList() + { + if (fontSizeList == null) + { + fontSizeList = new JList(this.fontSizeStrings); + fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + fontSizeList.addListSelectionListener( + new ListSelectionHandler(getFontSizeTextField())); + fontSizeList.setSelectedIndex(0); + fontSizeList.setFont(DEFAULT_FONT); + fontSizeList.setFocusable(false); + } + return fontSizeList; + } + + /** + * Get the family name of the selected font. + * @return the font family of the selected font. + * + * @see #setSelectedFontFamily + **/ + public String getSelectedFontFamily() + { + String fontName = (String) getFontFamilyList().getSelectedValue(); + return fontName; + } + + /** + * Get the style of the selected font. + * @return the style of the selected font. + *Font.PLAIN
,Font.BOLD
, + *Font.ITALIC
,Font.BOLD|Font.ITALIC
+ * + * @see java.awt.Font#PLAIN + * @see java.awt.Font#BOLD + * @see java.awt.Font#ITALIC + * @see #setSelectedFontStyle + **/ + public int getSelectedFontStyle() + { + int index = getFontStyleList().getSelectedIndex(); + return FONT_STYLE_CODES[index]; + } + + /** + * Get the size of the selected font. + * @return the size of the selected font + * + * @see #setSelectedFontSize + **/ + public int getSelectedFontSize() + { + int fontSize = 1; + String fontSizeString = getFontSizeTextField().getText(); + while (true) + { + try + { + fontSize = Integer.parseInt(fontSizeString); + break; + } + catch (NumberFormatException e) + { + fontSizeString = (String) getFontSizeList().getSelectedValue(); + getFontSizeTextField().setText(fontSizeString); + } + } + + return fontSize; + } + + /** + * Get the selected font. + * @return the selected font + * + * @see #setSelectedFont + * @see java.awt.Font + **/ + public Font getSelectedFont() + { + Font font = new Font(getSelectedFontFamily(), + getSelectedFontStyle(), getSelectedFontSize()); + return font; + } + + /** + * Set the family name of the selected font. + * @param name the family name of the selected font. + * + * @see getSelectedFontFamily + **/ + public void setSelectedFontFamily(String name) + { + String[] names = getFontFamilies(); + for (int i = 0; i < names.length; i++) + { + if (names[i].toLowerCase().equals(name.toLowerCase())) + { + getFontFamilyList().setSelectedIndex(i); + break; + } + } + updateSampleFont(); + } + + /** + * Set the style of the selected font. + * @param style the size of the selected font. + *Font.PLAIN
,Font.BOLD
, + *Font.ITALIC
, or + *Font.BOLD|Font.ITALIC
. + * + * @see java.awt.Font#PLAIN + * @see java.awt.Font#BOLD + * @see java.awt.Font#ITALIC + * @see #getSelectedFontStyle + **/ + public void setSelectedFontStyle(int style) + { + for (int i = 0; i < FONT_STYLE_CODES.length; i++) + { + if (FONT_STYLE_CODES[i] == style) + { + getFontStyleList().setSelectedIndex(i); + break; + } + } + updateSampleFont(); + } + + /** + * Set the size of the selected font. + * @param size the size of the selected font + * + * @see #getSelectedFontSize + **/ + public void setSelectedFontSize(int size) + { + String sizeString = String.valueOf(size); + for (int i = 0; i < this.fontSizeStrings.length; i++) + { + if (this.fontSizeStrings[i].equals(sizeString)) + { + getFontSizeList().setSelectedIndex(i); + break; + } + } + getFontSizeTextField().setText(sizeString); + updateSampleFont(); + } + + /** + * Set the selected font. + * @param font the selected font + * + * @see #getSelectedFont + * @see java.awt.Font + **/ + public void setSelectedFont(Font font) + { + setSelectedFontFamily(font.getFamily()); + setSelectedFontStyle(font.getStyle()); + setSelectedFontSize(font.getSize()); + } + + public String getVersionString() + { + return ("Version"); + } + + /** + * Show font selection dialog. + * @param parent Dialog's Parent component. + * @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION + * + * @see #OK_OPTION + * @see #CANCEL_OPTION + * @see #ERROR_OPTION + **/ + public int showDialog(Component parent) + { + dialogResultValue = ERROR_OPTION; + JDialog dialog = createDialog(parent); + dialog.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + dialogResultValue = CANCEL_OPTION; + } + }); + + dialog.setVisible(true); + dialog.dispose(); + dialog = null; + + return dialogResultValue; + } + + protected class ListSelectionHandler implements ListSelectionListener + { + private JTextComponent textComponent; + + ListSelectionHandler(JTextComponent textComponent) + { + this.textComponent = textComponent; + } + + public void valueChanged(ListSelectionEvent e) + { + if (e.getValueIsAdjusting() == false) + { + JList list = (JList) e.getSource(); + String selectedValue = (String) list.getSelectedValue(); + + String oldValue = textComponent.getText(); + textComponent.setText(selectedValue); + if (!oldValue.equalsIgnoreCase(selectedValue)) + { + textComponent.selectAll(); + textComponent.requestFocus(); + } + + updateSampleFont(); + } + } + } + + protected class TextFieldFocusHandlerForTextSelection extends FocusAdapter + { + private JTextComponent textComponent; + + public TextFieldFocusHandlerForTextSelection(JTextComponent textComponent) + { + this.textComponent = textComponent; + } + + public void focusGained(FocusEvent e) + { + textComponent.selectAll(); + } + + public void focusLost(FocusEvent e) + { + textComponent.select(0, 0); + updateSampleFont(); + } + } + + protected class TextFieldKeyHandlerForListSelectionUpDown extends KeyAdapter + { + private JList targetList; + + public TextFieldKeyHandlerForListSelectionUpDown(JList list) + { + this.targetList = list; + } + + public void keyPressed(KeyEvent e) + { + int i = targetList.getSelectedIndex(); + switch (e.getKeyCode()) + { + case KeyEvent.VK_UP: + i = targetList.getSelectedIndex() - 1; + if (i < 0) + { + i = 0; + } + targetList.setSelectedIndex(i); + break; + case KeyEvent.VK_DOWN: + int listSize = targetList.getModel().getSize(); + i = targetList.getSelectedIndex() + 1; + if (i >= listSize) + { + i = listSize - 1; + } + targetList.setSelectedIndex(i); + break; + default: + break; + } + } + } + + protected class ListSearchTextFieldDocumentHandler implements DocumentListener + { + JList targetList; + + public ListSearchTextFieldDocumentHandler(JList targetList) + { + this.targetList = targetList; + } + + public void insertUpdate(DocumentEvent e) + { + update(e); + } + + public void removeUpdate(DocumentEvent e) + { + update(e); + } + + public void changedUpdate(DocumentEvent e) + { + update(e); + } + + private void update(DocumentEvent event) + { + String newValue = ""; + try + { + Document doc = event.getDocument(); + newValue = doc.getText(0, doc.getLength()); + } + catch (BadLocationException e) + { + e.printStackTrace(); + } + + if (newValue.length() > 0) + { + int index = targetList.getNextMatch(newValue, 0, Position.Bias.Forward); + if (index < 0) + { + index = 0; + } + targetList.ensureIndexIsVisible(index); + + String matchedName = targetList.getModel().getElementAt(index).toString(); + if (newValue.equalsIgnoreCase(matchedName)) + { + if (index != targetList.getSelectedIndex()) + { + SwingUtilities.invokeLater(new ListSelector(index)); + } + } + } + } + + public class ListSelector implements Runnable + { + private int index; + + public ListSelector(int index) + { + this.index = index; + } + + public void run() + { + targetList.setSelectedIndex(this.index); + } + } + } + + protected class DialogOKAction extends AbstractAction + { + protected static final String ACTION_NAME = "OK"; + private JDialog dialog; + + protected DialogOKAction(JDialog dialog) + { + this.dialog = dialog; + putValue(Action.DEFAULT, ACTION_NAME); + putValue(Action.ACTION_COMMAND_KEY, ACTION_NAME); + putValue(Action.NAME, (ACTION_NAME)); + } + + public void actionPerformed(ActionEvent e) + { + dialogResultValue = OK_OPTION; + dialog.setVisible(false); + } + } + + protected class DialogCancelAction extends AbstractAction + { + protected static final String ACTION_NAME = "Cancel"; + private JDialog dialog; + + protected DialogCancelAction(JDialog dialog) + { + this.dialog = dialog; + putValue(Action.DEFAULT, ACTION_NAME); + putValue(Action.ACTION_COMMAND_KEY, ACTION_NAME); + putValue(Action.NAME, (ACTION_NAME)); + } + + public void actionPerformed(ActionEvent e) + { + dialogResultValue = CANCEL_OPTION; + dialog.setVisible(false); + } + } + + protected JDialog createDialog(Component parent) + { + Frame frame = parent instanceof Frame ? (Frame) parent + : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); + JDialog dialog = new JDialog(frame, ("Seletor de fonte"), true); + + Action okAction = new DialogOKAction(dialog); + Action cancelAction = new DialogCancelAction(dialog); + + JButton okButton = new JButton(okAction); + okButton.setFont(DEFAULT_FONT); + JButton cancelButton = new JButton(cancelAction); + cancelButton.setFont(DEFAULT_FONT); + + JPanel buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new GridLayout(2, 1)); + buttonsPanel.add(okButton); + buttonsPanel.add(cancelButton); + buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10)); + + ActionMap actionMap = buttonsPanel.getActionMap(); + actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction); + actionMap.put(okAction.getValue(Action.DEFAULT), okAction); + InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT)); + inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT)); + + JPanel dialogEastPanel = new JPanel(); + dialogEastPanel.setLayout(new BorderLayout()); + dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH); + + dialog.getContentPane().add(this, BorderLayout.CENTER); + dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST); + dialog.pack(); + dialog.setLocationRelativeTo(frame); + return dialog; + } + + protected void updateSampleFont() + { + Font font = getSelectedFont(); + getSampleTextField().setFont(font); + } + + protected JPanel getFontFamilyPanel() + { + if (fontNamePanel == null) + { + fontNamePanel = new JPanel(); + fontNamePanel.setLayout(new BorderLayout()); + fontNamePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + fontNamePanel.setPreferredSize(new Dimension(180, 130)); + + JScrollPane scrollPane = new JScrollPane(getFontFamilyList()); + scrollPane.getVerticalScrollBar().setFocusable(false); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + p.add(getFontFamilyTextField(), BorderLayout.NORTH); + p.add(scrollPane, BorderLayout.CENTER); + + JLabel label = new JLabel(("Nome da fonte")); + label.setHorizontalAlignment(JLabel.LEFT); + label.setHorizontalTextPosition(JLabel.LEFT); + label.setLabelFor(getFontFamilyTextField()); + label.setDisplayedMnemonic('F'); + + fontNamePanel.add(label, BorderLayout.NORTH); + fontNamePanel.add(p, BorderLayout.CENTER); + + } + return fontNamePanel; + } + + protected JPanel getFontStylePanel() + { + if (fontStylePanel == null) + { + fontStylePanel = new JPanel(); + fontStylePanel.setLayout(new BorderLayout()); + fontStylePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + fontStylePanel.setPreferredSize(new Dimension(140, 130)); + + JScrollPane scrollPane = new JScrollPane(getFontStyleList()); + scrollPane.getVerticalScrollBar().setFocusable(false); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + p.add(getFontStyleTextField(), BorderLayout.NORTH); + p.add(scrollPane, BorderLayout.CENTER); + + JLabel label = new JLabel(("Font Style")); + label.setHorizontalAlignment(JLabel.LEFT); + label.setHorizontalTextPosition(JLabel.LEFT); + label.setLabelFor(getFontStyleTextField()); + label.setDisplayedMnemonic('Y'); + + fontStylePanel.add(label, BorderLayout.NORTH); + fontStylePanel.add(p, BorderLayout.CENTER); + } + return fontStylePanel; + } + + protected JPanel getFontSizePanel() + { + if (fontSizePanel == null) + { + fontSizePanel = new JPanel(); + fontSizePanel.setLayout(new BorderLayout()); + fontSizePanel.setPreferredSize(new Dimension(70, 130)); + fontSizePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + + JScrollPane scrollPane = new JScrollPane(getFontSizeList()); + scrollPane.getVerticalScrollBar().setFocusable(false); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + p.add(getFontSizeTextField(), BorderLayout.NORTH); + p.add(scrollPane, BorderLayout.CENTER); + + JLabel label = new JLabel(("Tamanho da fonte")); + label.setHorizontalAlignment(JLabel.LEFT); + label.setHorizontalTextPosition(JLabel.LEFT); + label.setLabelFor(getFontSizeTextField()); + label.setDisplayedMnemonic('S'); + + fontSizePanel.add(label, BorderLayout.NORTH); + fontSizePanel.add(p, BorderLayout.CENTER); + } + return fontSizePanel; + } + + protected JPanel getSamplePanel() + { + if (samplePanel == null) + { + Border titledBorder = BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), ("Amostra")); + Border empty = BorderFactory.createEmptyBorder(5, 10, 10, 10); + Border border = BorderFactory.createCompoundBorder(titledBorder, empty); + + samplePanel = new JPanel(); + samplePanel.setLayout(new BorderLayout()); + samplePanel.setBorder(border); + + samplePanel.add(getSampleTextField(), BorderLayout.CENTER); + } + return samplePanel; + } + + protected JTextField getSampleTextField() + { + if (sampleText == null) + { + Border lowered = BorderFactory.createLoweredBevelBorder(); + + sampleText = new JTextField(("AaBbYyZz")); + sampleText.setBorder(lowered); + sampleText.setPreferredSize(new Dimension(300, 100)); + } + return sampleText; + } + + protected String[] getFontFamilies() + { + if (fontFamilyNames == null) + { + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + fontFamilyNames = env.getAvailableFontFamilyNames(); + } + return fontFamilyNames; + } + + protected String[] getFontStyleNames() + { + if (fontStyleNames == null) + { + int i = 0; + fontStyleNames = new String[4]; + fontStyleNames[i++] = ("Plain"); + fontStyleNames[i++] = ("Bold"); + fontStyleNames[i++] = ("Italic"); + fontStyleNames[i++] = ("BoldItalic"); + } + return fontStyleNames; + } +} \ No newline at end of file diff --git a/src/com/classes/util/Menssage.java b/src/com/classes/util/Menssage.java new file mode 100644 index 0000000..db1ce75 --- /dev/null +++ b/src/com/classes/util/Menssage.java @@ -0,0 +1,48 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.classes.util; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JLabel; +import javax.swing.JPanel; + +/** + * + * @author Andrew + */ +public class Menssage extends JPanel { + + private JLabel label = null; + + private Thread thread = null; + + public Menssage(JLabel label) { + this.label = label; + this.label.setText(""); + } + + public void write(final String msg) { + thread = new Thread(new Runnable() { + @Override + public void run() { + label.setText(msg); + try { + Thread.sleep(10000); + } catch (InterruptedException ex) { + Logger.getLogger(Menssage.class.getName()).log(Level.SEVERE, null, ex); + } finally{ + label.setText(""); + } + } + }); + if(thread.isAlive()){ + thread.interrupt(); + } + thread.start(); + } + +} diff --git a/src/com/classes/util/MenuSetting.java b/src/com/classes/util/MenuSetting.java new file mode 100644 index 0000000..145f706 --- /dev/null +++ b/src/com/classes/util/MenuSetting.java @@ -0,0 +1,104 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.classes.util; + +import javax.swing.JMenuItem; +import javax.swing.JMenuBar; + +/** + * + * @author SIMONETO-2 + */ +public class MenuSetting { + + //MENU + JMenuBar MENU; + + //TAB ARQUIVOS + JMenuItem JMenuItem1; + JMenuItem JMenuItem2; + JMenuItem JMenuItem3; + JMenuItem JMenuItem4; + JMenuItem JMenuItem5; + JMenuItem JMenuItem6; + JMenuItem JMenuItem15; + + //TAB EDITAR + JMenuItem JMenuItem7; + JMenuItem JMenuItem8; + JMenuItem JMenuItem9; + JMenuItem JMenuItem10; + JMenuItem JMenuItem11; + JMenuItem JMenuItem12; + JMenuItem JMenuItem13; + JMenuItem JMenuItem14; + + //TAB EXIBIR + JMenuItem jMenuItem16; + + //TAB ALGORITMO + //JMenuItem jMenuItem17; + //JMenuItem jMenuItem18; + + + //TAB AJUDA + JMenuItem jMenuItem19; + + public MenuSetting(JMenuBar menu) { + this.MENU = menu; + + JMenuItem1 = MENU.getMenu(0).getItem(0); + JMenuItem2 = MENU.getMenu(0).getItem(1); + JMenuItem3 = MENU.getMenu(0).getItem(3); + JMenuItem4 = MENU.getMenu(0).getItem(4); + JMenuItem5 = MENU.getMenu(0).getItem(10); + JMenuItem6 = MENU.getMenu(0).getItem(8); + JMenuItem15 = MENU.getMenu(0).getItem(6); + + //TAB EDITAR + JMenuItem7 = MENU.getMenu(1).getItem(0); + JMenuItem8 = MENU.getMenu(1).getItem(1); + JMenuItem9 = MENU.getMenu(1).getItem(3); + JMenuItem10 = MENU.getMenu(1).getItem(4); + JMenuItem11 = MENU.getMenu(1).getItem(5); + JMenuItem12 = MENU.getMenu(1).getItem(7); + JMenuItem13 = MENU.getMenu(1).getItem(9); + JMenuItem14 = MENU.getMenu(1).getItem(10); + + //TAB EXIBIR + jMenuItem16 = MENU.getMenu(2).getItem(0); + + //TAB ALGORITMO + //jMenuItem17 = MENU.getMenu(3).getItem(0); + jMenuItem19 = MENU.getMenu(3).getItem(1); + } + + public void setDisabledTop(boolean p) { + JMenuItem3.setEnabled(p); + JMenuItem4.setEnabled(p); + JMenuItem6.setEnabled(p); + JMenuItem15.setEnabled(p); + + //MENU.getMenu(1).setEnabled(p); + //MENU.getMenu(2).setEnabled(p); + //MENU.getMenu(3).setEnabled(p); + + JMenuItem7.setEnabled(p); + JMenuItem8.setEnabled(p); + JMenuItem9.setEnabled(p); + JMenuItem10.setEnabled(p); + JMenuItem11.setEnabled(p); + JMenuItem12.setEnabled(p); + JMenuItem13.setEnabled(p); + JMenuItem14.setEnabled(p); + + jMenuItem16.setEnabled(p); + + //jMenuItem17.setEnabled(p); + jMenuItem19.setEnabled(p); + } + +} diff --git a/src/com/classes/util/NewTab.java b/src/com/classes/util/NewTab.java new file mode 100644 index 0000000..6f9e3bb --- /dev/null +++ b/src/com/classes/util/NewTab.java @@ -0,0 +1,178 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.classes.util; + +import static com.forms.Editor.enabled_menu; +import static com.forms.Editor.files_opens; +import static com.forms.Editor.line_number; +import static com.forms.Editor.linha_coluna_txt; +import de.sciss.syntaxpane.DefaultSyntaxKit; +import java.awt.Color; +import javax.swing.JEditorPane; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import de.sciss.syntaxpane.actions.CaretMonitor; +import de.sciss.syntaxpane.components.LineNumbersRuler; +import java.awt.AlphaComposite; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Toolkit; +import java.net.URL; + +/** + * + * @author SIMONETO-2 + */ +public class NewTab { + + private final JScrollPane[] scrollpane = new JScrollPane[500]; + private final JEditorPane[] jtextpane = new JEditorPane[500]; + + private JTabbedPane tab = null; + + public int tabs_criadas = 0; + + public NewTab(JTabbedPane jTab) { + //ADICIONANDO O JTAB + this.tab = jTab; + } + + public void addTab(String tabname, String diretory, String alg) { + //CRIANDO A SCROLBAR + scrollpane[tabs_criadas] = new javax.swing.JScrollPane(); + scrollpane[tabs_criadas].setBorder(null); + scrollpane[tabs_criadas].setBackground(Color.decode("#FFFFFF")); + scrollpane[tabs_criadas].setName("scrollpane_" + tabs_criadas); + + //CRIANDO JTEXTPANE + jtextpane[tabs_criadas] = new javax.swing.JEditorPane() { + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + + Graphics2D g2d = (Graphics2D) g; + + AlphaComposite alphaChannel = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); + URL urlicon = NewTab.class.getClassLoader().getResource("com/images/logo.png"); + Image icon = Toolkit.getDefaultToolkit().getImage(urlicon); + g2d.setComposite(alphaChannel); + g2d.drawImage(icon, this.getWidth() - 128, this.getHeight() - 128, this); + g2d.dispose(); + } + }; + jtextpane[tabs_criadas].setBackground(Color.decode("#FFFFFF")); + jtextpane[tabs_criadas].setBorder(null); + //jtextpane[tabs_criadas].setMargin(new java.awt.Insets(5, 5, 5, 5)); + jtextpane[tabs_criadas].setToolTipText(null); + jtextpane[tabs_criadas].setName("jtextpane_" + tabs_criadas); + jtextpane[tabs_criadas].setSelectionColor(Color.GRAY); + //SETANDO A SCROLL NO TEXTPANE + scrollpane[tabs_criadas].setViewportView(jtextpane[tabs_criadas]); + + //INICIANDO O EDITOR + jtextpane[tabs_criadas].setContentType("text/portugol"); + jtextpane[tabs_criadas].setText(alg); + ((de.sciss.syntaxpane.SyntaxDocument) jtextpane[tabs_criadas].getDocument()).clearUndos(); + + //ADICIOANDO A TAB + //""+tabname+"" + tab.addTab("" + tabname + "", scrollpane[tabs_criadas]); + jtextpane[tabs_criadas].setCaretPosition(0); + + //SETANDO CARET_MONITOR + CaretMonitor m = new CaretMonitor(jtextpane[tabs_criadas], linha_coluna_txt); + m.setNoSelectionFormat("Linha %d, Coluna %d (Total de caracteres ate o cursor %d)"); + m.setSelectionFormat("Linha %d, Coluna %d até Linha %d, Coluna %d (Total de caracteres selecionados %d)"); + + //VERIFICANDO SE E PARA REMOVER O LINE_NUMBER + if (!line_number) { + DefaultSyntaxKit kit = (DefaultSyntaxKit) jtextpane[tabs_criadas].getEditorKit(); + if (kit.isComponentInstalled(jtextpane[tabs_criadas], LineNumbersRuler.class.getName())) { + kit.deinstallComponent(jtextpane[tabs_criadas], LineNumbersRuler.class.getName()); + } + } + + //PEGANDO A POSICAO DA TAB + int tabIndex = tab.getTabCount() - 1; + + //ADICIONANDO NOME A TAB + tab.getComponentAt(tabIndex).setName("" + tabs_criadas); + + //CONFIGURANDO A ARRAY DE INFORMACOES DO ARQUIVO + files_opens.addFileOpen(tabs_criadas, "jtextpane_" + tabs_criadas, diretory); + + //SELECIONANDO A TAB ABERTA + tab.setSelectedIndex(tabIndex); + + //VERIFICANDO SE O MENU ESTA DESABILITADO + if (enabled_menu == false) { + enabled_menu = true; + } + //setting_menu.setDisabledTop(enabled_menu); + + //APLICANDO FOCUS NO TEXT + jtextpane[tabs_criadas].requestFocus(); + + System.out.println("Aba criada com sucesso. ID:" + tabs_criadas); + + //INCREMENTANDO CONTATADOR + tabs_criadas++; + } + + //RETORNAR TOTAL DE TABS + public int getTabCount() { + return tab.getTabCount(); + } + + //VAI PARA A TAB SELECIONADA + public void setSelectedIndex(int index) { + tab.setSelectedIndex(index); + } + + //FUNCAO PARA RENOMEAR A TAB + public void renameTab(int index, String txt) { + tab.setTitleAt(index, txt); + } + + public String getTitleTab(int index) { + return tab.getTitleAt(index); + } + + //PEGA A TAB QUE ESTA ABERTA + public int getIndexTab() { + return tab.getSelectedIndex(); + } + + //DELETAR TAB + public void unistallTab(int id) { + scrollpane[id] = null; + jtextpane[id] = null; + files_opens.unistall(id); + } + + //RETORNAR O JTEXTPANE DA TAB ABERTA + public JEditorPane getEditorPane() { + JScrollPane scroll_atual = (JScrollPane) tab.getSelectedComponent(); + return (JEditorPane) scroll_atual.getViewport().getComponent(0); + } + + //RETORNAR O JTEXTPANE DE QUALQUER TAB + public JEditorPane getJEditorPaneAt(int index) { + JScrollPane scroll_atual = (JScrollPane) tab.getComponentAt(index); + return (JEditorPane) scroll_atual.getViewport().getComponent(0); + } + + public int getIdTab() { + String[] Split = getEditorPane().getName().split("_"); + return Integer.parseInt(Split[1]); + } + + public int getIdTab(int index) { + String[] Split = getJEditorPaneAt(index).getName().split("_"); + return Integer.parseInt(Split[1]); + } +} diff --git a/src/com/classes/util/OpenFile.java b/src/com/classes/util/OpenFile.java new file mode 100644 index 0000000..6fc3bf6 --- /dev/null +++ b/src/com/classes/util/OpenFile.java @@ -0,0 +1,90 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.classes.util; + +import static com.forms.Editor.files_opens; +import static com.forms.Editor.tab; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JFileChooser; +import javax.swing.JMenuItem; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; + +/** + * + * @author SIMONETO-2 + */ +public class OpenFile { + + private JMenuItem menu = null; + + public OpenFile(JMenuItem botao) { + //ARMAZENANDO BOTAO + this.menu = botao; + //ADICIONANDO EVENTO + menu.addActionListener(actions); + } + + //RESPONSAVEL PELA LEITURA DO ARQUIVO + public String readFile(String path, Charset encoding) throws IOException { + /*byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding);*/ + String retorno = ""; + Listlines = Files.readAllLines(Paths.get(path), encoding); + for (int i = 0; i < lines.size(); i++) { + if (i == lines.size() - 1) { + retorno += lines.get(i); + } else { + retorno += lines.get(i) + "\n"; + } + } + return retorno; + } + + //ACAO DE ABERTURA DO ARQUIVO FILE CHOOSER + private final ActionListener actions = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == menu) { + JFileChooser fc = new JFileChooser(); + FileFilter filter = new FileNameExtensionFilter("Arquivo algoritmo *.alg", "alg"); + fc.addChoosableFileFilter(filter); + fc.setFileFilter(filter); + int returnVal = fc.showOpenDialog(menu); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + + //PARA EVITAR A ABERTURA DE ITENS DUPLICADOS + if (!files_opens.isExistingOpen(file.getAbsoluteFile().toString())) { + try { + InputStreamReader r = new InputStreamReader(new FileInputStream(file)); + /*Charset.defaultCharset()*/ + tab.addTab(file.getName(), file.getAbsoluteFile().toString(), readFile(file.toString(), Charset.forName(r.getEncoding()))); + tab.getEditorPane().setCaretPosition(0); + System.out.println("Arquivo " + file.getName() + " foi aberto com sucesso. Charset: " + r.getEncoding()); + } catch (IOException ex) { + Logger.getLogger(OpenFile.class.getName()).log(Level.SEVERE, null, ex); + } + } else { + tab.setSelectedIndex(files_opens.getPositionItem(file.getAbsoluteFile().toString())); + } + } + } + } + }; +} diff --git a/src/com/classes/util/SaveSaveAs.java b/src/com/classes/util/SaveSaveAs.java new file mode 100644 index 0000000..e17fd9a --- /dev/null +++ b/src/com/classes/util/SaveSaveAs.java @@ -0,0 +1,172 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.classes.util; + +import static com.forms.Editor.files_opens; +import static com.forms.Editor.msg; +import static com.forms.Editor.tab; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JFileChooser; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JTextPane; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; + +/** + * + * @author SIMONETO-2 + */ +public class SaveSaveAs { + + private JMenuItem botao_save = null; + private JMenuItem botao_save_as = null; + private JTextPane editor_txt = null; + + public SaveSaveAs(JMenuItem btn_save, JMenuItem btn_saveAs) { + //ARMAZENANDO VARIAVEIS (BOTOES) + this.botao_save = btn_save; + this.botao_save_as = btn_saveAs; + + //ADICIONANDO EVENTOS + botao_save_as.addActionListener(action_save_As); + botao_save.addActionListener(action_save); + } + + //EVENTO PARA SAVA(AS) + private final ActionListener action_save_As = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + if (e.getSource() == botao_save_as) { + SaveAs(); + } + } catch (IOException ex) { + Logger.getLogger(SaveSaveAs.class.getName()).log(Level.SEVERE, null, ex); + } + } + }; + + //EVENTO PARA SALVAMENTO PADRAO + private final ActionListener action_save = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + if (e.getSource() == botao_save) { + //VERIFICANDO SE EXISTE UM LOCAL SALVO + + if (!"".equals(files_opens.getInfo(tab.getEditorPane().getName())[2])) { + try { + //SALVA O ARQUIVO + Save(files_opens.getInfo(tab.getEditorPane().getName())[2]); + msg.write("Arquivo " + files_opens.getInfo(tab.getEditorPane().getName())[2] + " foi modificado com sucesso."); + System.out.println("Arquivo " + files_opens.getInfo(tab.getEditorPane().getName())[2] + " foi modificado com sucesso."); + } catch (IOException ex) { + JOptionPane.showConfirmDialog(null, "Erro ao salver o arquivo, tente novamente", "Alerta", JOptionPane.ERROR_MESSAGE); + //Logger.getLogger(SaveSaveAs.class.getName()).log(Level.SEVERE, null, ex); + } + } else { + try { + //ABRE JANELA DE SAVE(AS) + SaveAs(); + } catch (IOException ex) { + JOptionPane.showConfirmDialog(null, "Erro ao salver o arquivo, tente novamente", "Alerta", JOptionPane.ERROR_MESSAGE); + //Logger.getLogger(SaveSaveAs.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + } + }; + + public void Save(String diretory) throws IOException { + //ARMAZENA VARIAVEIS + String tmp = diretory; + File salvar_arquivo = new File(tmp); + + //APAGAR CONTEU DO ARQUIVO + PrintWriter clean = new PrintWriter(salvar_arquivo); + clean.print(""); + clean.close(); + + //PREPARA PARA SALVAR O ARQUIVO + PrintWriter writer = new PrintWriter(diretory); + String[] alg = tab.getEditorPane().getText().split("\n"); + for (int i = 0; i < alg.length; i++) { + if (i == alg.length - 1) { + writer.print(alg[i]); + } else { + writer.println(alg[i]); + } + } + writer.close(); + } + + public void SaveAs() throws FileNotFoundException, IOException { + //ABRINDO CHOOSE PARA SALVAR ARQUIVO + JFileChooser SavedFile = new JFileChooser(); + SavedFile.setAcceptAllFileFilterUsed(false); + FileFilter ft = new FileNameExtensionFilter("Salvar como arquivo algoritmo *.alg", "alg"); + SavedFile.addChoosableFileFilter(ft); + SavedFile.setDialogTitle("Aonde você deseja salvar o seu algoritmo ?"); + + //VARIAVEL DE RETORNO + int returnVal = SavedFile.showSaveDialog(botao_save_as); + + //ABRINDO DIALOGO PARA SALVAR ARQUIVO CRIPTOGRAFADO + if (returnVal == JFileChooser.APPROVE_OPTION) { + File salvar_arquivo = SavedFile.getSelectedFile(); + + //VERIFICANDO SE O ARQUIVO EXISTE PARA O REPLACE + if (salvar_arquivo.exists()) { + int result = JOptionPane.showConfirmDialog(null, "O arquivo que você está tentando salvar já existe. \nDeseja substituir esse arquivo?", "Alerta", JOptionPane.YES_NO_CANCEL_OPTION); + if (result == JOptionPane.NO_OPTION) { + SaveAs(); + return; + } + } + + //TRATANDO DO NOME + String nome = salvar_arquivo.toString(); + + //VERIFICA SE JA EXISTE O .ALG NO NOME + if (!nome.endsWith(".alg")) { + nome = nome + ".alg"; + } + + //MODIFICANDO NOME + salvar_arquivo = new File(nome); + + //SALVANDO O ARQUIVO + Save(salvar_arquivo.toString()); + + //VERIFICANDO SE O ARQUIVO JA ESTA SALVO + if (!"".equals(files_opens.getInfo(tab.getEditorPane().getName())[2])) { + //PARA O SAVAS_aS + tab.addTab(salvar_arquivo.getName(), nome, tab.getEditorPane().getText()); + } else { + //PARA O SAVE + files_opens.updateDir(tab.getEditorPane().getName(), nome); + tab.renameTab(tab.getIndexTab(), salvar_arquivo.getName()); + } + + + msg.write("Arquivo " + salvar_arquivo.toString() + " foi salvo com sucesso."); + System.out.println("Arquivo " + salvar_arquivo.toString() + " foi salvo com sucesso."); + + } + + } + +} diff --git a/src/com/compilador/portugol/.sublf61.tmp b/src/com/compilador/portugol/.sublf61.tmp new file mode 100644 index 0000000..784d04c --- /dev/null +++ b/src/com/compilador/portugol/.sublf61.tmp @@ -0,0 +1,239 @@ +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (GRAMATICA). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.analizador.portugol; + +/*import static com.analizador.portugol.parser.error;*/ +import java_cup.runtime.*; + + +parser code +{: + + static Compilador util = new Compilador(); + + public static void main(String args[]) throws Exception{ + new parser(new PortugolFlex(System.in)).parse(); + } + public void syntax_error(Symbol s){ + report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right)+". Trecho desconhecido: "+s.value,null); + util.setErro(); + } +:} + +action code {::} + +terminal ALGORITMO; +terminal VAR; +terminal String TIPO_VARIAVEL,TIPO_VARIAVEL_VETOR; + +terminal INICIO; + +terminal String OPERADOR,OPERADOR_SOMA,VALOR_LOGICO; +terminal ATRIBUIR; +terminal ABRIR_PARENTESE, FECHAR_PARENTESE,ABRIR_COLCHETE,FECHAR_COLCHETE,DOIS_PONTOS; + +terminal SE,ENTAO,SENAO,FIMSE; +terminal String CONDICIONAL_NUMERICA,CONDICIONAL_COMPARATIVA; + +terminal DE,E,OU; + +terminal FIMALGORITMO; + +terminal ADD_ATTR_VAR, SEPARADOR; +terminal String ID,STRING,NUMERO_INT,NUMERO_FLOAT; + + +non terminal algoritmo; + +/* ALGORITMO DECLARACAO */ +non terminal algoritmo_nome, algoritmo_instanciacao; + +/* VAR DECLARACAO */ +non terminal var_estrutura, variaveis, var_instanciacao; +non terminal String var_listagem; + + + +/* TERMINAL PROGRAMA */ +non terminal programa, corpo_programa; + +/* FUNCOES */ +non terminal instanciacao_variaveis,condicional; + +/* PARA OPERACOES EM GERAL*/ +non terminal String _operacoes,_condicional,_sub_condicional; + + +/* PRESEDENCIA DE OPERACOES */ +precedence left OPERADOR,OPERADOR_SOMA; + +precedence left ABRIR_PARENTESE, FECHAR_PARENTESE; + +/* PRESEDENCIA DE VARIAVEIS */ +precedence left SEPARADOR; + +/* PRECEDENCIAS CONDICIONAIS */ +precedence left E,OU; +precedence left CONDICIONAL_NUMERICA,CONDICIONAL_COMPARATIVA; + +start with algoritmo; + +/* ALGORITMO */ +algoritmo ::= algoritmo_nome + var_estrutura + INICIO {: util.setCode("\n\tpublic static void main(String[] args) {"); :} + programa + FIMALGORITMO {: util.setCode("\t}\n}"); if(util.isErros() == false) util.printCode(); :} + | error {::}; + + + + +/* PARA A DECLARACAO DO NO DO ALGORITMO */ +algoritmo_nome ::= algoritmo_instanciacao | error {: :}; +algoritmo_instanciacao ::= ALGORITMO ID:e {: util.setCode("class "+e+" {"); :} | ALGORITMO STRING:e {: util.setCode("class "+e.toString().substring(1, e.toString().length()-1)+" {"); :}; + + + + + +/* PARA A DECLARACAO DE VARIAVEIS */ +var_estrutura ::= VAR variaveis | error {: util.setCode("Detalhe: Erro de estruturacao. Exemplo de estruturacao.: var variavel1,variavel2 : tipo_de_variavel"); :}; +variaveis ::= variaveis var_instanciacao | var_instanciacao | error {: :}; +var_instanciacao ::= var_listagem:e ADD_ATTR_VAR TIPO_VARIAVEL:x {: + util.addVariavel(e,x); /* Ja estao com toLowerCase */ + util.setCode("\t" + util.getTipoVariavel(x) + " " +e+ ";"); + :} | + var_listagem:e ADD_ATTR_VAR TIPO_VARIAVEL_VETOR ABRIR_COLCHETE NUMERO_INT:n1 DOIS_PONTOS NUMERO_INT:n2 FECHAR_COLCHETE DE TIPO_VARIAVEL:x {: + util.setBiblioteca("import java.util.List;"); + util.addVariavelVetor(e,x,n1,n2); /* Ja estao com toLowerCase */ + util.setCode("\tList<"+util.getTipoVariavel(x)+"> "+e+" = new ArrayList<>();"); + :}; + +var_listagem ::= var_listagem:e1 SEPARADOR var_listagem:e2 {: RESULT = e1+","+e2; :} | + ID:value {: RESULT = value.toLowerCase(); :}; + + + + + +/*PROGRAMA*/ +programa ::= programa corpo_programa | corpo_programa | error {::}; + +corpo_programa ::= instanciacao_variaveis | condicional; + + +instanciacao_variaveis ::= ID:x ATRIBUIR _operacoes:e {: + String tmp = util.setVariavelOperador(x.toLowerCase(),e); + switch(tmp){ + case "error1" : this.parser.report_error("Erro de syntax: Variavel \""+x+"\" não foi declarada", null);util.setErro(); break; + case "error2" : this.parser.report_error("Erro de syntax: Variavel \""+x+"\" não suporta esse tipo de valor", null);util.setErro(); break; + default: util.setCode(tmp); break; + } + :} | + ID:x ABRIR_COLCHETE NUMERO_INT:n FECHAR_COLCHETE ATRIBUIR _operacoes:e {: + String tmp = util.setVariavelVetor(x.toLowerCase(),e,n); + switch(tmp){ + case "error1" : this.parser.report_error("Erro de syntax: Variavel \""+x+"\" não foi declarada", null);util.setErro(); break; + case "error2" : this.parser.report_error("Erro de syntax: Variavel \""+x+"\" não suporta esse tipo de valor", null);util.setErro(); break; + case "error3" : this.parser.report_error("Erro de syntax: Indice do vetor \""+x+"\" esta incorreto", null);util.setErro(); break; + default: util.setCode(tmp); break; + } + :} ; + + +condicional ::= SE _condicional:c ENTAO {: + String tmp = util.setCondicional(c.toLowerCase()); + switch(tmp){ + case "error1" : this.parser.report_error("Erro de syntax: Comparacao indevida em "+c, null);util.setErro(); break; + default: util.setCode(tmp); break; + } + :} programa FIMSE; + + + +/* CONDICINAL GRAMATICA */ +_condicional ::= _condicional:c1 E _condicional:c2 {: + RESULT = c1+" && "+c2; + util.setCondicinalETMP(true); + :} | + _condicional:c1 OU _condicional:c2 {: + RESULT = c1+" || "+c2; + util.setCondicionalOuTMP(true); + :} | + ABRIR_PARENTESE _condicional:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + _sub_condicional:e {: RESULT = e; :}; + + +_sub_condicional ::= _sub_condicional:s1 CONDICIONAL_NUMERICA:c _sub_condicional:s2 {: + RESULT = s1+" "+c+" "+s2; + util.setCondicinalNumericaTMP(true); + :} | + _sub_condicional:s1 CONDICIONAL_COMPARATIVA:c _sub_condicional:s2 {: + RESULT = s1+" "+util.getTipoCondiconal(c)+" "+s2; + util.setCondicionalComparativaTMP(true); + :} | + ABRIR_PARENTESE _sub_condicional:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + _operacoes:e {: + RESULT = e; + util.setTiposOperacaoeTMP(util.getTipoOperacao()); + :}; + + +/* OPERACOES */ +_operacoes ::= _operacoes:e1 OPERADOR:op _operacoes:e2 {: + RESULT = e1+" "+util.getOperador(op)+" "+e2; + util.setOperadorTMP(true); + :} | + _operacoes:e1 OPERADOR_SOMA _operacoes:e2 {: + RESULT = e1+" + "+e2; + util.setOperadorSomaTMP(true); + :} | + ABRIR_PARENTESE _operacoes:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + NUMERO_INT:n {: + RESULT = n; + util.setNumeroIntTMP(true); + :} | + NUMERO_FLOAT:n {: + RESULT = util.getValorRealFloat(n); + util.setNumeroFloatTMP(true); + :} | + ID:n {: + if(util.checkVariavelExiste(n.toLowerCase())) { + String[] tmp = util.getVariavel(n.toLowerCase()); + util.setTipoIdTMP(tmp[1]); + RESULT = n.toLowerCase(); + }else{ + this.parser.report_error("Erro de syntax: Variavel \""+n+"\" não foi declarada", null); + util.setErro(); + } + :} | + ID:n ABRIR_COLCHETE NUMERO_INT:i FECHAR_COLCHETE ATRIBUIR {: + String[] tmp = util.getVariavelVetor(n.toLowerCase()); + if(tmp[0] != null){ + if (i >= tmp[2] && i <= tmp[3]) { + util.setTipoIdTMP(tmp[1]); + RESULT = n.toLowerCase()+".get("+i+")"; + }else{ + this.parser.report_error("Erro de syntax: Indice do vetor \""+n+"\" esta incorreto", null); + util.setErro(); + } + }else{ + this.parser.report_error("Erro de syntax: Variavel \""+n+"\" não foi declarada", null); + util.setErro(); + } + :} | + STRING:s {: + util.setStringTMP(true); + RESULT = s; + :} | + VALOR_LOGICO:l {: + util.setBooleanTMP(true); + RESULT = util.getValorLogico(l); + :}; \ No newline at end of file diff --git a/src/com/compilador/portugol/Compilador.java b/src/com/compilador/portugol/Compilador.java new file mode 100644 index 0000000..1db9d44 --- /dev/null +++ b/src/com/compilador/portugol/Compilador.java @@ -0,0 +1,766 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.compilador.portugol; + +import com.forms.Console; +import com.forms.Editor; +import static com.forms.Editor.tela; +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +/** + * + * @author SIMONETO-2 + */ +public class Compilador { + + private final boolean printCode = false; + private final boolean execCode = true; + + + public ArrayList Variaveis = new ArrayList<>(); + /* + * MENU: + * 0-VARIAVEL NOME + * 1-VARIAVEL TIPO + */ + public ArrayList VariaveisVetor = new ArrayList<>(); + /* + * MENU: + * 0-VARIAVEL NOME + * 1-VARIAVEL TIPO + * 2-INDICE A + * 3-INDICE B + */ + + private String code_name; + + private String[] code = {"", "", "", ""}; // 0 - CABECALHO, 1 - VARIAVEIS , 2 - PROGRAMA , 3 - INCLUDES + public String[] code_exec = {"", "", ""}; + + private int erros = 0; + + private final String[] operacoes_portugol = {"+", "-", "*", "/", "^", "mod", "div"}; + private final String[] operacoes_java = {"+", "-", "*", "/", "^", "%", "/"}; + + private final String[] valores_logicos_portugol = {"verdadeiro", "falso"}; + private final String[] valores_logicos_java = {"true", "false"}; + + private final String[] tipos_variaveis_portugol = {"string", "caracter", "inteiro", "real", "logico"}; + private final String[] tipos_variaveis_java = {"String", "char", "int", "float", "boolean"}; + + private final String[] condicionais_portugol = {"=", "<>", "e", "ou"}; + private final String[] condicionais_java = {"==", "!=", "&&", "||"}; + + //para o comando de saida + private boolean scanner = false; + + public void setLeia(boolean n) { + if (this.scanner == false) { + this.scanner = true; + setBiblioteca("import java.util.Scanner;"); + setCodeVariables("\t\tScanner scanIn = new Scanner(System.in);"); + //setCodeVariablesExec("\t\tScanner scanIn = new Scanner(System.in);"); + } + } + + public void resetarSaidas() { + code_name = ""; + + code_exec[0] = ""; + code_exec[1] = ""; + code_exec[2] = ""; + + code[0] = ""; + code[1] = ""; + code[2] = ""; + code[3] = ""; + + scanner = false; + erros = 0; + + Variaveis.clear(); + VariaveisVetor.clear(); + } + + /* + * AUXILIAR NAS OPERACOES + */ + private boolean operador_tmp = false; + private boolean operador_soma = false; + private boolean numero_float_tmp = false; + private boolean numero_int_tmp = false; + private boolean string_tmp = false; + private boolean char_tmp = false; + private boolean boolean_tmp = false; + List TipoID_tmp = new ArrayList<>(); + + public void setOperadorTMP(boolean p) { + operador_tmp = p; + } + + public void setOperadorSomaTMP(boolean p) { + operador_soma = p; + } + + public void setNumeroIntTMP(boolean p) { + numero_int_tmp = p; + } + + public void setNumerofloatTMP(boolean p) { + numero_float_tmp = p; + } + + public void setStringTMP(boolean p) { + string_tmp = p; + } + + public void setCharTMP(boolean p) { + char_tmp = p; + } + + public void setBooleanTMP(boolean p) { + boolean_tmp = p; + } + + public void setTipoIdTMP(String e) { + TipoID_tmp.add(e); + } + + public void resetTMPSOperadores() { + operador_tmp = false; + operador_soma = false; + numero_float_tmp = false; + numero_int_tmp = false; + string_tmp = false; + boolean_tmp = false; + char_tmp = false; + TipoID_tmp.clear(); + + } + + /* + * AXULIAR NAS CONDICIONAIS + */ + //para as sub-condicionais + private boolean condicionais_numericas = false; + private boolean condicionais_comparativas = false; + private boolean condicinal_e = false; + private boolean condicinal_ou = false; + List TiposOperacoesTMP = new ArrayList<>(); + + //para as condicionais + private boolean condicionais_numericas_permanentes = false; + private boolean condicionais_comparativas_permanentes = false; + List TiposOperacoesTMP_permanentes = new ArrayList<>(); + + public void setCondicinalNumericaTMP(boolean p) { + condicionais_numericas = p; + condicionais_numericas_permanentes = p; //para as condicionais permanentes + } + + public void setCondicionalComparativaTMP(boolean p) { + condicionais_comparativas = p; + condicionais_comparativas_permanentes = p; //para as condicionais permanentes + } + + public void setCondicinalETMP(boolean p) { + condicinal_e = p; + } + + public void setCondicionalOuTMP(boolean p) { + condicinal_ou = p; + } + + public void setTiposOperacaoeTMP(String t) { + TiposOperacoesTMP.add(t); + TiposOperacoesTMP_permanentes.add(t); //para as condicionais permanentes + } + + public void resetTMPSSubCondicionais() { + condicionais_numericas = false; + condicionais_comparativas = false; + condicinal_e = false; + condicinal_ou = false; + TiposOperacoesTMP.clear(); + } + + public void resetTMPSCondicionais() { + condicionais_numericas_permanentes = false; + condicionais_comparativas_permanentes = false; + TiposOperacoesTMP_permanentes.clear(); + } + + + /* + * PARA LISTAGEM + */ + public void setCodeName(String name) { + this.code_name = name; + } + + public void setInitClass() { + this.code[0] = "\n\tpublic " + this.code_name + "(){"; + } + + public void setEndClass() { + setCode("\t}\n\n\tpublic static void main(String[] args){\n\t\t" + this.code_name + " programa = new " + this.code_name + "();\n\t}\n}"); + } + + public void setCode(String code) { + this.code[2] += code + "\n"; + } + + public void setCodeVariables(String code) { + this.code[1] += code + "\n"; + } + + public void setBiblioteca(String biblioteca) { + this.code[3] += biblioteca + "\n"; + } + + public void printCode() { + if (printCode) { + if ("".equals(this.code[3])) { + System.out.print(code[0] + '\n' + code[1] + '\n' + code[2]); + } else { + System.out.print(code[3] + '\n' + code[0] + '\n' + code[1] + '\n' + code[2]); + } + } + } + /* + * PARA EXECUTAR + */ + + public void setCodeExec(String code) { + this.code_exec[2] += code; + } + + public void setCodeExec(String code, int line) { + String _line = "\n"; + int cline = line + 1; + + + int total_line = (code_exec[0]+code_exec[1]+code_exec[2]).split("\n").length; + + for (int i = 0; i < (line-(total_line+1)); i++) { + _line += "\n"; + } + this.code_exec[2] += _line + code; + } + + public void setCodeVariablesExec(String code) { + this.code_exec[1] += code + "\n"; + } + + public void setCodeLibraryExec(String code) { + this.code_exec[0] += code + "\n"; + } + /* + public void execCode() { + if (execCode) { + + Threadcode = new Thread(new Runnable() { + + @Override + public void run() { + long startTime = 0; + long endTime = 0; + boolean error = false; + Interpreter i = new Interpreter(); + //System.out.println("#"+code_exec[0] + code_exec[1] + code_exec[2]); + try { + startTime = System.currentTimeMillis(); + i.set("ConsoleIO", ConsoleIO); + i.set("table_variaveis", table_variaveis); + i.eval(code_exec[0] + code_exec[1] + code_exec[2]); + } catch (EvalError ex) { + JOptionPane.showMessageDialog(null, "Erro de syntax:Há algum erro critico de syntax no seu código. Linha:" + (ex.getErrorLineNumber() - 1), "Erro de syntax", JOptionPane.WARNING_MESSAGE); + error = true; + } finally { + endTime = System.currentTimeMillis(); + ConsoleIO.println(""); + ConsoleIO.println(""); + if (!error) { + ConsoleIO.print("Programa finalizado. Tempo de duração: " + (endTime - startTime) / 1000 + " segundos", AttrColor("codigo_finalizado")); + } else { + ConsoleIO.print("Programa finalizado. Tempo de duração: " + (endTime - startTime) / 1000 + " segundos", AttrColor("codigo_finalizado_error")); + } + ConsoleIO.finalizacao(); + + } + } + + }); + Threadcode.start(); + } + } + */ + + public void setErro() { + erros++; + } + + public boolean isErros() { + boolean retorno = false; + if (erros > 0) { + retorno = true; + } + return retorno; + } + + public void codeComplete() { + if (isErros() == false) { + Console console = new Console(); + console.setLocation((tela.width - console.getSize().width) / 2, (tela.height - console.getSize().height) / 2); + console.setModal(true); + console.setVisible(true); + /* + //LISTAGEM DE VARIAVEIS + for (String[] Variavei : Variaveis) { + table_variaveis.add(Variavei[0], getTipoVariavelJavaToPt(Variavei[1]), null); + } + + //LISTAGEM DE VARIAVEIS DO TIPO VETOR + for (String[] Variavei : VariaveisVetor) { + for (int i = new Integer(Variavei[2]); i <= new Integer(Variavei[3]); i++) { + table_variaveis.add(Variavei[0] + "[" + i + "]", getTipoVariavelJavaToPt(Variavei[1]), null); + } + } + */ + printCode(); + //execCode(); + } + } + + /* + * PARA AS VARIAVEIS + */ + public String getTipoVariavel(String tipo) { //retornar o operador equivalente java + int i = 0; + while (i < tipos_variaveis_portugol.length && !tipos_variaveis_portugol[i].equals(tipo)) { + i++; + } + return tipos_variaveis_java[i]; + } + + public String getTipoVariavelJavaToPt(String tipo) { //retornar o operador equivalente java + int i = 0; + while (i < tipos_variaveis_java.length && !tipos_variaveis_java[i].equals(tipo)) { + i++; + } + return tipos_variaveis_portugol[i]; + } + + public String getOperador(String tipo) { // retornar o operador equivalente java + int i = 0; + while (i < operacoes_portugol.length && !operacoes_portugol[i].equals(tipo)) { + i++; + } + return operacoes_java[i]; + } + + public String getValorLogico(String value) { + int i = 0; + while (i < valores_logicos_portugol.length && !valores_logicos_portugol[i].equals(value)) { + i++; + } + return valores_logicos_java[i]; + } + /* + public String getValorRealfloat(String value) { + return value.replace(",", "."); + } + */ + + public String getValorFloatreal(String value) { + return value.replace(".", ","); + } + + public void addVariavel(String nome, String tipo) { //add a variavel na array para controle e seta o codigo + String[] variaveis = nome.split(","); + for (String var : variaveis) { + String[] tmp = {var, getTipoVariavel(tipo)}; + Variaveis.add(tmp); + } + } + + public void addVariavelVetor(String nome, String tipo, String indice1, String indice2) { + String[] variaveis = nome.split(","); + for (String var : variaveis) { + String[] tmp = {var, getTipoVariavel(tipo), indice1, indice2}; + VariaveisVetor.add(tmp); + setCodeVariables("\t" + getTipoVariavel(tipo) + "[] " + var + " = new " + getTipoVariavel(tipo) + "[" + (new Integer(indice2) - new Integer(indice1) + 1) + "];"); + setCodeVariablesExec("\t" + getTipoVariavel(tipo) + "[] " + var + " = new " + getTipoVariavel(tipo) + "[" + (new Integer(indice2) - new Integer(indice1) + 1) + "];"); + } + + } + + public String[] getVariavel(String variavel) { + String[] info = new String[2]; + + for (String[] var : Variaveis) { + if (var[0].equals(variavel)) { + String retorno[] = {var[0], var[1]}; + info = retorno; + break; + } + } + return info; + } + + public String[] getVariavelVetor(String variavel) { + String[] info = new String[4]; + + for (String[] var : VariaveisVetor) { + if (var[0].equals(variavel)) { + String retorno[] = {var[0], var[1], var[2], var[3]}; + info = retorno; + break; + } + } + return info; + } + + public boolean checkVariavelExiste(String variavel) { + boolean tmp = false; + String[] var = getVariavel(variavel); + if (var[1] == null) { + tmp = false; + } else { + tmp = true; + } + return tmp; + } + + public String setValorVariavelLogica(String variavel, String value) { + String[] var = getVariavel(variavel); + String retorno = null; + + if (var[1] == null) { + retorno = "error1"; //Variavel nao declarada + } else if ("boolean".equals(var[1])) { + retorno = "\t\t" + variavel + " = " + getValorLogico(value) + ";"; + } else { + retorno = "error2"; //Variavel nao suporta String + } + return retorno; + } + + public String getTipoOperacao() { + String tipo = null; + String[] tmp_tipo = {null, null}; + + int ids_string = 0; + int ids_char = 0; + int ids_int = 0; + int ids_float = 0; + int ids_boolean = 0; + + //caso tenha IDs + if (!TipoID_tmp.isEmpty()) { + for (String tmp : TipoID_tmp) { + if ("String".equals(tmp)) { + ids_string++; + } else if ("char".equals(tmp)) { + ids_char++; + } else if ("int".equals(tmp)) { + ids_int++; + } else if ("float".equals(tmp)) { + ids_float++; + } else if ("boolean".equals(tmp)) { + ids_boolean++; + } + } + } + /* + System.out.println("===================="); + System.out.println("string="+ids_string); + System.out.println("char="+ids_char); + System.out.println("int="+ids_int); + System.out.println("float="+ids_float); + System.out.println("===================="); + */ + /* + System.out.println("===================="); + System.out.println("string="+string_tmp); + System.out.println("char="+char_tmp); + System.out.println("int="+numero_int_tmp); + System.out.println("float="+numero_float_tmp); + System.out.println("===================="); + */ + + //caso int + if ((ids_int > 0 || numero_int_tmp == true) && string_tmp == false && ids_string == 0 && ids_float == 0 && numero_float_tmp == false && boolean_tmp == false && ids_boolean == 0 && ids_char == 0 && char_tmp == false) { + tipo = "int"; + + //caso float + } else if ((ids_float > 0 || ids_int > 0 || numero_float_tmp == true || numero_int_tmp == true) && string_tmp == false && ids_string == 0 && boolean_tmp == false && ids_boolean == 0 && ids_char == 0 && char_tmp == false) { + tipo = "float"; + + //caso String + } else if ((ids_string > 0 || string_tmp == true) && ids_int == 0 && ids_float == 0 && operador_tmp == false && numero_float_tmp == false && numero_int_tmp == false && boolean_tmp == false && ids_boolean == 0 && ids_char == 0 && char_tmp == false) { + tipo = "String"; + + //caso char + } else if ((ids_char > 0 || char_tmp == true) && operador_soma == false && ids_string == 0 && string_tmp == false && ids_int == 0 && ids_float == 0 && operador_tmp == false && numero_float_tmp == false && numero_int_tmp == false && ids_boolean == 0 && boolean_tmp == false) { + tipo = "char"; + } //caso logico + else if ((ids_boolean > 0 || boolean_tmp == true) && operador_soma == false && ids_string == 0 && string_tmp == false && ids_int == 0 && ids_float == 0 && operador_tmp == false && numero_float_tmp == false && numero_int_tmp == false && ids_char == 0 && char_tmp == false) { + tipo = "boolean"; + } + + resetTMPSOperadores(); + + return tipo; + } + + public String setVariavelOperador(String variavel, String value) { + String retorno = null; + String[] var = getVariavel(variavel); + + if (var[1] == null) { + retorno = "error1"; //Variavel nao declarada + } else { + + String tmp_tipo_operacao = getTipoOperacao(); + + if (var[1].equals(tmp_tipo_operacao)) { + retorno = "\t\t" + variavel + " = (" + var[1] + ") (" + value + "); /*Variavel do tipo: " + var[1] + ", operacao do tipo: " + tmp_tipo_operacao + "*/"; + } else if (("int".equals(tmp_tipo_operacao) || "float".equals(tmp_tipo_operacao)) && ("int".equals(var[1]) || "float".equals(var[1]))) { + retorno = "\t\t" + variavel + " = (" + var[1] + ") (" + value + "); /*Variavel do tipo: " + var[1] + ", operacao do tipo: " + tmp_tipo_operacao + "*/"; + } else { + retorno = "error2"; //Variavel nao suporta + } + } + return retorno; + } + + public String setVariavelVetor(String variavel, String value, String indice) { + String retorno = null; + String[] var = getVariavelVetor(variavel); + + if (var[1] == null) { + retorno = "error1"; //Variavel nao declarada + } else { + + String tmp_tipo_operacao = getTipoOperacao(); + + //int indice_a = new Integer(var[2]); + //int indice_xo = new Integer(indice); + if (var[1].equals(tmp_tipo_operacao)) { + retorno = "\t\t" + variavel + "[" + indice + " - (" + var[2] + ")] = (" + var[1] + ") (" + value + "); /*Variavel do tipo: " + var[1] + ", operacao do tipo: " + tmp_tipo_operacao + "*/"; + retorno += "t\ttable_variaveis.update(\"" + variavel + "[\"+" + indice + "+\"]\"," + variavel + "[" + indice + " - (" + var[2] + ")]);"; + } else if (("int".equals(tmp_tipo_operacao) || "float".equals(tmp_tipo_operacao)) && ("int".equals(var[1]) || "float".equals(var[1]))) { + retorno = "\t\t" + variavel + "[" + indice + " - (" + var[2] + ")] = (" + var[1] + ") (" + value + "); /*Variavel do tipo: " + var[1] + ", operacao do tipo: " + tmp_tipo_operacao + "*/"; + retorno += "t\ttable_variaveis.update(\"" + variavel + "[\"+" + indice + "+\"]\"," + variavel + "[" + indice + " - (" + var[2] + ")]);"; + } else { + retorno = "error2"; //Variavel nao suporta + } + } + return retorno; + } + + /* + * PARA VALORES LOGICOS + */ + public String getTipoCondiconal(String tipo) { //retornar o operador equivalente java + int i = 0; + while (!condicionais_portugol[i].equals(/*tipo.toLowerCase()*/tipo)) { + i++; + } + return condicionais_java[i]; + } + + /* + * CONDICINAIS + */ + public String setSubCondicional(String condicional) { + String retorno = null; + + int op_tipo_int = 0; + int op_tipo_char = 0; + int op_tipo_string = 0; + int op_tipo_float = 0; + int op_tipo_logico = 0; + + for (String tmp : TiposOperacoesTMP) { + if ("String".equals(tmp)) { + op_tipo_string++; + } else if ("char".equals(tmp)) { + op_tipo_char++; + } else if ("int".equals(tmp)) { + op_tipo_int++; + } else if ("float".equals(tmp)) { + op_tipo_float++; + } else if ("boolean".equals(tmp)) { + op_tipo_logico++; + } else { + retorno = "error1"; + } + } + /* + System.out.println("===================="); + System.out.println("op_tipo_int=" + op_tipo_int); + System.out.println("op_tipo_char=" + op_tipo_char); + System.out.println("op_tipo_string=" + op_tipo_string); + System.out.println("op_tipo_float=" + op_tipo_float); + System.out.println("op_tipo_logico=" + op_tipo_logico); + System.out.println("===================="); + */ + if (!"error1".equals(retorno)) { + //caso int e float (permitido qualquer tipo de comparacao) + if ((op_tipo_int > 0 | op_tipo_float > 0) && op_tipo_string == 0 && op_tipo_logico == 0 && op_tipo_char == 0) { + //caso String (permitido apenas compacao de == e !=) + } else if ((op_tipo_string > 0) && op_tipo_int == 0 && op_tipo_float == 0 && op_tipo_logico == 0 && op_tipo_char == 0 /*COMPARACOES*/ && condicionais_numericas == false) { + retorno = "String"; + //caso Logico + } else if ((op_tipo_logico > 0) && op_tipo_int == 0 && op_tipo_float == 0 && op_tipo_string == 0 && op_tipo_char == 0 /*COMPARACOES*/ && condicionais_numericas == false) { + //caso char + } else if ((op_tipo_char > 0) && op_tipo_int == 0 && op_tipo_float == 0 && op_tipo_string == 0 && op_tipo_logico == 0 /*COMPARACOES*/ && condicionais_numericas == false) { + //caso erro + } else { + retorno = condicional; + } + } + + resetTMPSSubCondicionais(); + + return retorno; + } + + public String setCondicional(String condicional) { + String retorno = null; + + int op_tipo_int = 0; + int op_tipo_char = 0; + int op_tipo_string = 0; + int op_tipo_float = 0; + int op_tipo_logico = 0; + + for (String tmp : TiposOperacoesTMP) { + if ("String".equals(tmp)) { + op_tipo_string++; + } else if ("char".equals(tmp)) { + op_tipo_char++; + } else if ("int".equals(tmp)) { + op_tipo_int++; + } else if ("float".equals(tmp)) { + op_tipo_float++; + } else if ("boolean".equals(tmp)) { + op_tipo_logico++; + } else { + retorno = "error1"; + } + } + + if (!"error1".equals(retorno)) { + // caso exista int ou float sem comparacao + if ((op_tipo_int > 0 || op_tipo_float > 0) && condicionais_numericas_permanentes == false && condicionais_comparativas_permanentes == false) { + retorno = condicional; + } else if (op_tipo_string > 0 && condicionais_comparativas_permanentes == false) { + retorno = condicional; + } else if (op_tipo_char > 0 && condicionais_comparativas_permanentes == false) { + retorno = condicional; + } + } + return retorno; + } + + public SimpleAttributeSet AttrColor(String tipe) { + SimpleAttributeSet retorno = new SimpleAttributeSet(); + + switch (tipe) { + case "error": + retorno.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.FALSE); + retorno.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.RED); + break; + + case "codigo_finalizado": + retorno.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE); + retorno.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.decode("#558737")); + break; + + case "codigo_finalizado_error": + retorno.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE); + retorno.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.decode("#960E0E")); + break; + } + + return retorno; + } + + public String Erros(String error, String complemento) { + String retorno = null; + switch (error) { + //////////////////////////// + //PARA AS VARIAVEIS NORMAIS + //////////////////////////// + case "VARIAVEL_ERRO1": + retorno = "Erro de syntax: Variável %s não foi declarada.".replace("%s", complemento); + break; + case "VARIAVEL_ERRO2": + retorno = "Erro de syntax: Variável %s não suporta esse tipo de valor.".replace("%s", complemento); + break; + ////////////////// + //PARA OS VETORES + ////////////////// + case "VARIAVEL_VETOR_ERRO1": + retorno = "Erro de syntax: Vetor %s não foi declarado.".replace("%s", complemento); + break; + case "VARIAVEL_VETOR_ERRO2": + retorno = "Erro de syntax: Vetor %s não suporta esse tipo de valor.".replace("%s", complemento); + break; + case "VARIAVEL_VETOR_ERRO3": + retorno = "Erro de syntax: Índice do vetor %s está incorreto.".replace("%s", complemento); + break; + case "VARIAVEL_VETOR_ERRO4": + retorno = "Erro de syntax: Índice do vetor %s deve ser um valor inteiro.".replace("%s", complemento); + break; + /////////////////////// + //PARA AS CONDICIONAIS + /////////////////////// + case "CONDICIONAL_ERRO1": + retorno = "Erro de syntax: Há uma operacão indevida na condicional."; + break; + case "CONDICIONAL_ERRO2": + retorno = "Erro de syntax: Comparação indevida em: %s.".replace("%s", complemento); + break; + + ///////////////////// + //ERRO DE OPERACAO/// + case "OPERACAO_ERRO1": + retorno = "Erro de syntax: Operação indevida."; + break; + + ///////////////////// + //ERRO FOR/////////// + ///////////////////// + case "INDICE_FOR": + retorno = "Erro de syntax: Índice do para não podem ser invertidos."; + break; + case "TIPO_VARIAVEL_FOR": + retorno = "Erro de syntax: Tipo de operação não permitida para o para."; + break; + + + /////// + //ALL// + /////// + case "SOMENTE_INT": + retorno = "Erro de syntax: Não é permitido outro tipo de operação: Somente tipo int."; + break; + + case "SOMENTE_NUMEROS": + retorno = "Erro de syntax: Não é permitido outro tipo de operação: Somente numeros."; + break; + } + return retorno; + } +} diff --git a/src/com/compilador/portugol/CompilarCUP.bat b/src/com/compilador/portugol/CompilarCUP.bat new file mode 100644 index 0000000..fe362fa --- /dev/null +++ b/src/com/compilador/portugol/CompilarCUP.bat @@ -0,0 +1,3 @@ +@echo off +java -jar java_cup.jar ./Portugol.cup +pause \ No newline at end of file diff --git a/src/com/compilador/portugol/ExecCompilador.java b/src/com/compilador/portugol/ExecCompilador.java new file mode 100644 index 0000000..818cc1c --- /dev/null +++ b/src/com/compilador/portugol/ExecCompilador.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.compilador.portugol; + +import static com.forms.Editor.tab; +import java.io.StringReader; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author SIMONETO-2 + */ +public class ExecCompilador extends Compilador { + + public ExecCompilador() { + PortugolFlex lexer = new PortugolFlex(new StringReader(tab.getEditorPane().getText())); + + + //Symbol sym; + //for (sym = lexer.next_token(); sym.sym != 0; sym = lexer.next_token()) { + //System.out.println("Token " + sym.sym + ", with value = " + sym.value + "; at line " + sym.left + ", column " + sym.right); + //} + + parser p = new parser(lexer); + try { + p.parse(); + } catch (Exception ex) { + Logger.getLogger(ExecCompilador.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/src/com/compilador/portugol/Exemplo.txt b/src/com/compilador/portugol/Exemplo.txt new file mode 100644 index 0000000..7cf7a74 --- /dev/null +++ b/src/com/compilador/portugol/Exemplo.txt @@ -0,0 +1,71 @@ +algoritmo "Algoritmo - Olá mundo" + +var s : string + c : caracter + +inicio + c <- 'c' +fimalgoritmo + + + + + +/* +algoritmo 'teste' + +var + numero,controle,tmp_espacos,i,n : inteiro + retorno : vetor[1..100] de caracter +inicio + escreva("Digite um numero: ") + leia(numero) + + controle <- numero + tmp_espacos <- numero + + para i de 0 ate (numero-1) faca + retorno[i] <- "" + para n de 0 ate (controle-1) faca + se(tmp_espacos > 1)entao + retorno[i] <- retorno[i] + " " + tmp_espacos <- tmp_espacos - 1 + senao + retorno[i] <- retorno[i] + "0" + fimse + fimpara + controle <- controle + 1 + tmp_espacos <- numero - (i+1) + escreval(retorno[i]) + fimpara + +fimalgoritmo + +algoritmo "teste" + +var nome : caracter + +inicio + escreva("Digite seu nomes: ") + leia(nome) + escreva("Seu nome e ",nome) +fimalgoritmo + + + + +algoritmo "Algoritmo - Olá mundo" + +var + nLoop : inteiro + nome : vetor[1..10] de caracter + +inicio + nLoop <- 1 + enquanto nLoop <= 10 faca + leia(nome[nLoop]) + nLoop <- nLoop + 1 + fimenquanto +fimalgoritmo + +*/ \ No newline at end of file diff --git a/src/com/compilador/portugol/Inicializador.java b/src/com/compilador/portugol/Inicializador.java new file mode 100644 index 0000000..dd6461d --- /dev/null +++ b/src/com/compilador/portugol/Inicializador.java @@ -0,0 +1,40 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.compilador.portugol; + +import static com.forms.Editor.tab; +import java.io.IOException; +import java.io.StringReader; +import java.util.Scanner; +import java.util.concurrent.locks.ReentrantLock; +import java_cup.runtime.Symbol; + +/** + * + * @author Andrew + */ +public class Inicializador { + + private final ReentrantLock lock = new ReentrantLock(); + + public static void main(String[] args) throws IOException, Exception { + //Yylex lexer = new Yylex(new StringReader("2+9")); + //PortugolFlex lexer = new PortugolFlex(Inicializador.class.getResourceAsStream("Exemplo.txt")); + + //Symbol sym; + //for (sym = lexer.next_token(); sym.sym != 0; sym = lexer.next_token()) { + //System.out.println("Token " + sym.sym + ", with value = " + sym.value + "; at line " + sym.left + ", column " + sym.right); + //} + //parser p = new parser(lexer); + //p.parse(); + //p.debug_parse(); + //System.out.print(Math.sin(90*Math.PI/180)); + if(System.getProperty("os.name").toLowerCase().contains("win")){ + System.out.print("windows"); + } + } + +} diff --git a/src/com/compilador/portugol/Portugol.cup b/src/com/compilador/portugol/Portugol.cup new file mode 100644 index 0000000..79d9111 --- /dev/null +++ b/src/com/compilador/portugol/Portugol.cup @@ -0,0 +1,648 @@ +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (GRAMATICA). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +/*import static com.analizador.portugol.parser.error;*/ +import java_cup.runtime.*; +import javax.swing.JOptionPane; + + +parser code +{: + + static Compilador util = new Compilador(); + + public void syntax_error(Symbol s){ + if(s.value != null){ + report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1)+". Trecho desconhecido: "+s.value,null); + JOptionPane.showMessageDialog(null,"Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1)+". Trecho desconhecido: "+s.value,"Erro de syntax",JOptionPane.WARNING_MESSAGE); + }else{ + report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1),null); + JOptionPane.showMessageDialog(null,"Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1),"Erro de syntax",JOptionPane.WARNING_MESSAGE); + } + util.setErro(); + this.done_parsing(); + } + public void syntax_error(int left,int right,String mensagem){ + report_error(mensagem + " " + "Linha "+(left+1)+" Coluna "+(right),null); + JOptionPane.showMessageDialog(null,mensagem + " " + "Linha "+(left+1)+" Coluna "+(right+1),"Erro de syntax",JOptionPane.WARNING_MESSAGE); + + util.setErro(); + this.done_parsing(); + } + public void report_fatal_error(String message, Object info){ + this.done_parsing(); + } +:} + + +init with {: + util = new Compilador(); +:}; + + +action code {::} + +terminal ALGORITMO; +terminal VAR; +terminal String TIPO_VARIAVEL,TIPO_VARIAVEL_VETOR; + +terminal INICIO; + +terminal String OPERADOR,OPERADOR_SOMA,VALOR_LOGICO; +terminal ATRIBUIR; +terminal ABRIR_PARENTESE, FECHAR_PARENTESE,ABRIR_COLCHETE,FECHAR_COLCHETE,DOIS_PONTOS; + +terminal SE,ENTAO,SENAO,FIMSE; +terminal ENQUANTO,PARA,FACA,FIMENQUANTO,FIMPARA; +terminal ESCOLHA,CASO,OUTROCASO,FIMESCOLHA; + +terminal INTERROMPA,ESPERAR,POTENCIA,MODULO,SENO,COSSENO,TANGENTE,RAIZ; +terminal PI; + +terminal FUNCAO,FIMFUNCAO,VOID; +terminal String CONDICIONAL_NUMERICA,CONDICIONAL_COMPARATIVA; + +terminal DE,E,ATE,PASSO,OU,NAO; + +terminal ESCREVA,ESCREVAL,LEIA; + +terminal FIMALGORITMO; + +terminal ADD_ATTR_VAR, SEPARADOR; +terminal String ID,STRING,NUMERO_INT,NUMERO_FLOAT,CHAR; + + +non terminal algoritmo; + +/* ALGORITMO DECLARACAO */ +non terminal algoritmo_nome, algoritmo_instanciacao; + +/* VAR DECLARACAO */ +non terminal var_estrutura, variaveis, var_instanciacao; +non terminal String var_listagem; + + + +/* TERMINAL PROGRAMA */ +non terminal programa, corpo_programa; + +/* FUNCOES */ +non terminal instanciacao_variaveis, + + condiciona_estrutura, + condicional_1, + condicional_2, + + escreva_funcao, + + leia_funcao, + + enquanto_funcao, + + para_funcao, + para_funcao_1, + + escolha_funcao, + escolha_loop, + escolha_casos, + escolha_outrocaso, + + funcoes_unitarias, + + funcao_estruturacao, + funcao_parametros_loop, + funcao_parametros; + +/* PARA OPERACOES EM GERAL*/ +non terminal String _operacoes,_operacoes_indice_vetor; +non terminal String _condicional,_sub_condicional; +non terminal String _loop_virgula,_loop_virgula_id; +non terminal String _para_complementar; + + +/* PRESEDENCIA DE OPERACOES */ +precedence left OPERADOR,OPERADOR_SOMA; + +precedence left ABRIR_PARENTESE, FECHAR_PARENTESE; + +/* PRESEDENCIA DE VARIAVEIS */ +precedence left SEPARADOR; + +/* PRECEDENCIAS CONDICIONAIS */ +precedence left E,OU; +precedence left CONDICIONAL_NUMERICA,CONDICIONAL_COMPARATIVA; + + +start with algoritmo; + + + +/**********************************************************************************************************************************/ +/**********************************************************************************************************************************/ +/**********************************************************************************************************************************/ + + + +/*************/ +/* ALGORITMO */ +/*************/ +algoritmo ::= algoritmo_nome + var_estrutura + INICIO + programa + FIMALGORITMO {: util.setEndClass(); util.codeComplete(); :} + |; + + + +/****************************************/ +/* PARA A DECLARACAO DO NO DO ALGORITMO */ +/****************************************/ +algoritmo_nome ::= algoritmo_instanciacao {: util.setInitClass(); :}; +algoritmo_instanciacao ::= ALGORITMO ID:e {: + util.setCode("public class "+e+" {"); + util.setCodeName(e); + :} | + ALGORITMO STRING:e {: + util.setCode("public class "+e.substring(1, e.length()-1)+" {"); + util.setCodeName(e.substring(1, e.length()-1)); + :}; + + + + +/**********************************/ +/* PARA A DECLARACAO DE VARIAVEIS */ +/**********************************/ +var_estrutura ::= VAR | VAR variaveis |; +variaveis ::= variaveis var_instanciacao | var_instanciacao; +var_instanciacao ::= var_listagem:e ADD_ATTR_VAR TIPO_VARIAVEL:x {: + util.addVariavel(e,x); + util.setCodeVariables("\t" + util.getTipoVariavel(x) + " " +e+ ";"); + util.setCodeVariablesExec("\t" + util.getTipoVariavel(x) + " " +e+ ";"); + :} | + var_listagem:e ADD_ATTR_VAR TIPO_VARIAVEL_VETOR ABRIR_COLCHETE NUMERO_INT:n1 DOIS_PONTOS NUMERO_INT:n2 FECHAR_COLCHETE DE TIPO_VARIAVEL:x {: + util.addVariavelVetor(e,x,n1,n2); + :}; + +var_listagem ::= var_listagem:e1 SEPARADOR var_listagem:e2 {: RESULT = e1+","+e2; :} | + ID:value {: RESULT = value; :}; + + + + +/************/ +/* PROGRAMA */ +/************/ +programa ::= programa corpo_programa | ; + +corpo_programa ::= funcoes_unitarias | instanciacao_variaveis | condiciona_estrutura | escreva_funcao | leia_funcao | enquanto_funcao | para_funcao | escolha_funcao; + + + +/**********************/ +/* CRIACAO DE FUNCOES */ +/**********************/ +/* +funcao_estruturacao ::= FUNCAO ID:id ABRIR_PARENTESE funcao_parametros_loop FECHAR_PARENTESE DOIS_PONTOS TIPO_VARIAVEL + + +funcao_parametros_loop ::= funcao_parametros_loop funcao_parametros | ; +funcao_parametros ::= ID:id DOIS_PONTOS TIPO_VARIAVEL:tipo; +*/ + + +/**********************/ +/* FUNCOES UNITARIAS */ +/**********************/ +funcoes_unitarias ::= INTERROMPA:i {: + util.setCode("\t\tbreak;"); + util.setCodeExec("\t\tbreak;",ileft); + :} | + ESPERAR:f ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(nleft,nright,util.Erros("SOMENTE_INT",null)); + }else{ + util.setCode("\t\tThread.sleep("+n+");"); + util.setCodeExec("\t\tThread.sleep("+n+");",fleft); + } + :}; + + + + +/*********************************/ +/* PARA INSTANCIACAO DE VARIAVEIS*/ +/*********************************/ +instanciacao_variaveis ::= ID:x ATRIBUIR _operacoes:e {: + String tmp = util.setVariavelOperador(x,e); + switch(tmp){ + case "error1" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_ERRO1",x)); break; + case "error2" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_ERRO2",x)); break; + default: + util.setCode(tmp); + util.setCodeExec(tmp + "\ttable_variaveis.update(\""+x+"\","+x+");",xleft); + break; + } + :} | + ID:x ABRIR_COLCHETE _operacoes_indice_vetor:n FECHAR_COLCHETE ATRIBUIR _operacoes:e {: + String tmp = util.setVariavelVetor(x,e,n); + switch(tmp){ + case "error1" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO1",x)); break; + case "error2" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO2",x)); break; + case "error3" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO3",x)); break; + default: + util.setCode(tmp); + util.setCodeExec(tmp,xleft); + break; + } + :}; + + + +/****************/ +/* CONDICIONAIS */ +/****************/ +condiciona_estrutura ::= condicional_1 programa FIMSE:p {: + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",pleft); + :}| + condicional_1 programa condicional_2 programa FIMSE:p3 {: + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",p3left); + :}; + + +condicional_1 ::= SE _condicional:c ENTAO {: + util.setCode("\t\tif("+c+"){"); + util.setCodeExec("\t\tif("+c+"){",cleft); + :}; + + +condicional_2 ::= SENAO:p {: + util.setCode("\t\t}else{"); + util.setCodeExec("\t\t}else{",pleft); + :}; + + +enquanto_funcao ::= ENQUANTO _condicional:c FACA {: + util.setCode("\t\twhile("+c+"){"); + util.setCodeExec("\t\twhile("+c+"){",cleft); + :} programa FIMENQUANTO:p {: util.setCode("\t\t}");util.setCodeExec("\t\t}",pleft); :}; + + + + + +/***************/ +/* FUNCAO PARA */ +/***************/ +para_funcao ::= para_funcao_1; + + +para_funcao_1 ::= PARA ID:n DE _operacoes:n1 {: + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n1left,n1right,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + :} ATE _operacoes:n2 {: + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n2left,n2right,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + :} _para_complementar:n3 FACA:p {: + String tmp[] = util.getVariavel(n); + + if(tmp[1] != null) { + if("int".equals(tmp[1])){ + if(n3 != null){ + util.setCode("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"+="+n3+"){"); + util.setCodeExec("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"+="+n3+"){",pleft); + }else{ + util.setCode("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"++){"); + util.setCodeExec("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"++){",pleft); + } + util.setCodeExec("\t\ttable_variaveis.update(\""+n+"\","+n+");"); + }else{ + parser.syntax_error(nleft,nright,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + :} programa FIMPARA:f {: util.setCode("\t\t}");util.setCodeExec("\t\t}",fleft); :}; + + +_para_complementar ::= PASSO _operacoes:n3 {: + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n3left,n3right,util.Erros("TIPO_VARIAVEL_FOR",null)); + }else{ + RESULT = n3; + } + :} |; + + + + + +/*****************************/ +/* FUNCAO ESCREVA E ESCREVAL */ +/*****************************/ +escreva_funcao ::= ESCREVA ABRIR_PARENTESE _loop_virgula:e FECHAR_PARENTESE {: + util.setCode("\t\tSystem.out.print("+e+");"); + util.setCodeExec("\t\tConsoleIO.print("+e+");",eleft); + :} | + ESCREVAL ABRIR_PARENTESE _loop_virgula:e FECHAR_PARENTESE {: + util.setCode("\t\tSystem.out.println("+e+");"); + util.setCodeExec("\t\tConsoleIO.println("+e+");",eleft); + :}; + + +/***************/ +/* FUNCAO LEIA */ +/***************/ +leia_funcao ::= LEIA ABRIR_PARENTESE _loop_virgula_id:e FECHAR_PARENTESE {: + util.setLeia(true); + + for (String ids : e.split(",")) { + String[] tmp; + + if(e.indexOf("[") > 0){ + tmp = util.getVariavelVetor(ids.replaceAll("\\[.*\\]","")); + String indice = ids.substring(ids.indexOf("[")+1,ids.indexOf("]")); + ids = ids.substring(0,ids.indexOf("]"))+"-("+tmp[2]+")]"; + switch(tmp[1]){ + case "int" : util.setCode("\t\t"+ids+" = ConsoleIO.nextInt();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeInt();",eleft);break; + case "float" : util.setCode("\t\t"+ids+" = scanIn.nextFloat();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeFloat();",eleft);break; + case "String" : util.setCode("\t\t"+ids+" = scanIn.next();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeString();",eleft);break; + case "char" : util.setCode("\t\t"+ids+" = scanIn.nextChar();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeChar();",eleft);break; + } + util.setCodeExec("\t\ttable_variaveis.update(\""+tmp[0]+"[\"+"+indice+"+\"]\","+ids+");"); + }else{ + tmp = util.getVariavel(ids); + switch(tmp[1]){ + case "int" : util.setCode("\t\t"+ids+" = ConsoleIO.nextInt();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeInt();",eleft);break; + case "float" : util.setCode("\t\t"+ids+" = scanIn.nextFloat();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeFloat();",eleft);break; + case "String" : util.setCode("\t\t"+ids+" = scanIn.next();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeString();",eleft);break; + case "char" : util.setCode("\t\t"+ids+" = scanIn.nextChar();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeChar();",eleft);break; + } + util.setCodeExec("\t\ttable_variaveis.update(\""+ids+"\","+ids+");"); + } + } + :}; + + + +/******************/ +/* FUNCAO ESCOLHA */ +/******************/ +escolha_funcao ::= ESCOLHA _operacoes:a {: + String tmp_tipo_operacao = util.getTipoOperacao(); + util.setCode("\t\tswitch("+a+"){"); + util.setCodeExec("\t\tswitch("+a+"){",aleft); + :} escolha_loop escolha_outrocaso FIMESCOLHA:f {: + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",fleft); + :}; + +escolha_loop ::= escolha_loop escolha_casos |; + +escolha_casos ::= CASO _operacoes:b {: + String tmp_tipo_operacao = util.getTipoOperacao(); + util.setCode("\t\tcase("+b+"):"); + util.setCodeExec("\t\tcase("+b+"):",bleft); + :} programa; + +escolha_outrocaso ::= OUTROCASO programa |; + + + + + + +/************************************************************************************************************/ +/************************************************************************************************************/ +/************************************************************************************************************/ + + +/************************/ +/* CONDICINAL GRAMATICA */ +/************************/ +_condicional ::= _condicional:c1 E _condicional:c2 {: + RESULT = c1+" && "+c2; + util.setCondicinalETMP(true); + :} | + _condicional:c1 OU _condicional:c2 {: + RESULT = c1+" || "+c2; + util.setCondicionalOuTMP(true); + :} | + ABRIR_PARENTESE _condicional:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + NAO ABRIR_PARENTESE _condicional:e FECHAR_PARENTESE {: RESULT = "!("+e+")"; :} | + _sub_condicional:e {: + RESULT = e; + String tmp = util.setCondicional(RESULT); + if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(eleft,eright,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(eleft,eright,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + :}; + +_sub_condicional ::= _sub_condicional:s1 CONDICIONAL_NUMERICA:c _sub_condicional:s2 {: + RESULT = s1+" "+c+" "+s2; + util.setCondicinalNumericaTMP(true); + + String tmp = util.setSubCondicional(RESULT); + if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + :} | + _sub_condicional:s1 CONDICIONAL_COMPARATIVA:c _sub_condicional:s2 {: + + util.setCondicionalComparativaTMP(true); + + RESULT = s1+" "+util.getTipoCondiconal(c)+" "+s2; + + String tmp = util.setSubCondicional(RESULT); + + if("String".equals(tmp)){ + if("<>".equals(c)){ + RESULT = "!"+s1+".equals("+s2+")"; + }else{ + RESULT = s1+".equals("+s2+")"; + } + } + else if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + :} | + ABRIR_PARENTESE _sub_condicional:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + NAO ABRIR_PARENTESE _sub_condicional:e FECHAR_PARENTESE {: RESULT = "!("+e+")"; :} | + _operacoes:e {: + RESULT = e; + util.setTiposOperacaoeTMP(util.getTipoOperacao()); + :}; + + + +/********************************************************************************************/ +/* LOOP COM VIRGULA PARA O ESCREVAL (PERMITIDO STRING IDS VETORES INTEIROS VALORES LOGICOS) */ +/********************************************************************************************/ +_loop_virgula ::= _loop_virgula:e1 SEPARADOR _loop_virgula:e2 {: RESULT = e1 + " + " + e2; :} | + _operacoes:e {: + RESULT = "("+e+")"; + String tmp = util.getTipoOperacao(); + if(tmp == null){ + parser.syntax_error(eleft,eright,util.Erros("OPERACAO_ERRO1",null)); + } + :}; + + +/********************************************************/ +/* LOOP COM VIRGULA PARA O LEIA (SOMENTE IDS E VETORES) */ +/********************************************************/ +_loop_virgula_id ::= _loop_virgula_id:e1 SEPARADOR _loop_virgula_id:e2 {: RESULT = e1 + "," + e2; :} | + ID:n {: + if(util.checkVariavelExiste(n)) { + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + :} | + ID:n ABRIR_COLCHETE _operacoes_indice_vetor:i FECHAR_COLCHETE {: + String[] tmp = util.getVariavelVetor(n); + if(tmp[0] != null){ + RESULT = n+"["+i+"]"; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO1",n)); + } + :}; + + +/*************/ +/* OPERACOES */ +/*************/ +_operacoes ::= _operacoes:e1 OPERADOR:op _operacoes:e2 {: + RESULT = e1+" "+util.getOperador(op)+" "+e2; + util.setOperadorTMP(true); + :} | + + _operacoes:e1 OPERADOR_SOMA _operacoes:e2 {: + RESULT = e1+" + "+e2; + util.setOperadorSomaTMP(true); + :} | + + POTENCIA ABRIR_PARENTESE _operacoes:n1 SEPARADOR _operacoes:n2 FECHAR_PARENTESE {: + RESULT = "Math.pow("+n1+","+n2+")"; + util.setOperadorTMP(true); + :} | + + MODULO ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + RESULT = "Math.abs("+n+")"; + util.setOperadorTMP(true); + :} | + + SENO ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + RESULT = "Math.sin("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + :} | + + COSSENO ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + RESULT = "Math.cos("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + :} | + + TANGENTE ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + RESULT = "Math.tan("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + :} | + + + RAIZ ABRIR_PARENTESE _operacoes:n FECHAR_PARENTESE {: + RESULT = "Math.sqrt("+n+")"; + util.setOperadorTMP(true); + :} | + + ABRIR_PARENTESE _operacoes:e FECHAR_PARENTESE {: RESULT = "("+e+")"; :} | + + ID:n ABRIR_COLCHETE _operacoes_indice_vetor:i FECHAR_COLCHETE {: + String[] tmp = util.getVariavelVetor(n); + if(tmp[0] != null){ + util.setTipoIdTMP(tmp[1]); + RESULT = n+"["+i+" - ("+tmp[2]+")]"; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO1",n)); + } + :} | + NUMERO_INT:n {: + RESULT = n; + util.setNumeroIntTMP(true); + :} | + NUMERO_FLOAT:n {: + RESULT = n; + util.setNumerofloatTMP(true); + :} | + PI {: + RESULT = ""+Math.PI; + util.setNumerofloatTMP(true); + :} | + ID:n {: + if(util.checkVariavelExiste(n)) { + String[] tmp = util.getVariavel(n); + util.setTipoIdTMP(tmp[1]); + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + :} | + STRING:s {: + util.setStringTMP(true); + RESULT = s; + :} | + CHAR:s {: + util.setCharTMP(true); + RESULT = s; + :} | + VALOR_LOGICO:l {: + util.setBooleanTMP(true); + RESULT = util.getValorLogico(l); + :}; + + +/********************************/ +/* OPERAÇÕES DE INCICE VETORIAL */ +/********************************/ +_operacoes_indice_vetor ::= _operacoes_indice_vetor:e1 OPERADOR:op _operacoes_indice_vetor:e2 {: RESULT = e1+" "+util.getOperador(op)+" "+e2; :} | + _operacoes_indice_vetor:e1 OPERADOR_SOMA _operacoes_indice_vetor:e2 {: RESULT = e1+" + "+e2; :} | + ABRIR_PARENTESE _operacoes_indice_vetor:e FECHAR_PARENTESE {: RESULT = e; :} | + NUMERO_INT:n {: RESULT = n; :} | + ID:n {: + String[] tmp = util.getVariavel(n); + if(tmp[1] != null) { + if("int".equals(tmp[1])){ + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO4",n)); + } + :}; \ No newline at end of file diff --git a/src/com/compilador/portugol/Portugol.flex b/src/com/compilador/portugol/Portugol.flex new file mode 100644 index 0000000..3fdd929 --- /dev/null +++ b/src/com/compilador/portugol/Portugol.flex @@ -0,0 +1,233 @@ +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (TOKENS). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +import java_cup.runtime.*; + + +%% +%class PortugolFlex +%cup +%line +%char +%column + +/*%caseless*/ +/*%ignorecase*/ + +%{ + + public PortugolFlex() { + super(); + } + + Symbol newSym(int tokenId) { + return new Symbol(tokenId , yyline, yycolumn); + } + + Symbol newSym(int tokenId, Object value) { + return new Symbol(tokenId , yyline, yycolumn, value); + } + +%} + + +letras = [A-Za-z] +numeros = [0-9] +alphanumeric = {letras}|{numeros} +underline = [_] +identifier = {letras}({alphanumeric}|{underline})* + +inteiro = {numeros}+|\-{numeros}+ +fracao = \.{numeros}* +exponent = (E|e)(\+|\-)?{numeros}* +float = ((({numeros}* {fracao} {exponent}?))|({numeros}+\.)|({numeros}+\.? {exponent})) | + \-((({numeros}* {fracao} {exponent}?))|({numeros}+\.)|({numeros}+\.? {exponent})) + + +whitespace = [\n\r\ \t] + +string_content = (\\\"|[^\n\r\"]|\\{whitespace}+\\)* +string_literal = {double_qoute}{string_content}{double_qoute} +double_qoute = \" + + +string_content_single = (\\\'|[^\n\r\']|\\{whitespace}+\\){0,1} +string_literal_single = {double_qoute_single}{string_content_single}{double_qoute_single} +double_qoute_single = \' + +/* +string = {string_literal} +char = {string_literal_single} +*/ + +string = (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) +char = (\' ( [^\'\n\\] | \\[^\n] ){0,1} (\n | \\\n | \')) + + +newline = \r|\n|\r\n +InputCharacter = [^\r\n] + +Comment = {TraditionalComment} | {EndOfLineComment} +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {newline}? + + +%% + +{Comment} {/* IGNORAR COMENTARIOS */} + +/* +* ALGORITMO NAME +*/ + +"algoritmo" {return newSym(sym.ALGORITMO,yytext()); } + + +/* +* VARIAVEIS +*/ + +"var" {return newSym(sym.VAR,yytext()); } +"inteiro" {return newSym(sym.TIPO_VARIAVEL,yytext()); } +"real" {return newSym(sym.TIPO_VARIAVEL,yytext()); } +"caracter" {return newSym(sym.TIPO_VARIAVEL,yytext()); } +"string" {return newSym(sym.TIPO_VARIAVEL,yytext()); } +"logico" {return newSym(sym.TIPO_VARIAVEL,yytext()); } +"vetor" {return newSym(sym.TIPO_VARIAVEL_VETOR,yytext()); } + + +/* +* ESTRUTURA +*/ + +"inicio" {return newSym(sym.INICIO,yytext()); } +"fimalgoritmo" {return newSym(sym.FIMALGORITMO,yytext()); } + + +/* +* CONDICIONAL +*/ +"se" {return newSym(sym.SE,yytext()); } +"entao" {return newSym(sym.ENTAO,yytext()); } +"senao" {return newSym(sym.SENAO,yytext()); } +"fimse" {return newSym(sym.FIMSE,yytext()); } + +/* +* FUNCAO REPETICAO +*/ +"enquanto" {return newSym(sym.ENQUANTO,yytext()); } +"faca" {return newSym(sym.FACA,yytext()); } +"fimenquanto" {return newSym(sym.FIMENQUANTO,yytext()); } + +"para" {return newSym(sym.PARA,yytext()); } +"fimpara" {return newSym(sym.FIMPARA,yytext()); } + + + +/* +* FUNCOES +*/ +"escreva" {return newSym(sym.ESCREVA,yytext()); } +"escreval" {return newSym(sym.ESCREVAL,yytext()); } +"leia" {return newSym(sym.LEIA,yytext()); } + +"escolha" {return newSym(sym.ESCOLHA,yytext()); } +"caso" {return newSym(sym.CASO,yytext()); } +"outrocaso" {return newSym(sym.OUTROCASO,yytext()); } +"fimescolha" {return newSym(sym.FIMESCOLHA,yytext()); } + +"interrompa" {return newSym(sym.INTERROMPA,yytext()); } +"espere" {return newSym(sym.ESPERAR,yytext()); } + +"funcao" {return newSym(sym.FUNCAO,yytext()); } +"fimfuncao" {return newSym(sym.FIMFUNCAO,yytext()); } +"vazio" {return newSym(sym.VOID,yytext()); } + +/* +* AUXILIARES +*/ + +"de" {return newSym(sym.DE,yytext()); } +"e" {return newSym(sym.E,yytext()); } +"ate" {return newSym(sym.ATE,yytext()); } +"passo" {return newSym(sym.PASSO,yytext()); } +"ou" {return newSym(sym.OU,yytext()); } +"nao" {return newSym(sym.NAO,yytext()); } + + +/* +* VARIAVEL LOGICA +*/ +"verdadeiro" {return newSym(sym.VALOR_LOGICO,yytext());} +"falso" {return newSym(sym.VALOR_LOGICO,yytext());} + + +/* +* OPERADORES +*/ + +"[" {return newSym(sym.ABRIR_COLCHETE,yytext());} +"]" {return newSym(sym.FECHAR_COLCHETE,yytext());} +"(" {return newSym(sym.ABRIR_PARENTESE,yytext());} +")" {return newSym(sym.FECHAR_PARENTESE,yytext());} + + +".." {return newSym(sym.DOIS_PONTOS,yytext());} +":" {return newSym(sym.ADD_ATTR_VAR,yytext());} +"," {return newSym(sym.SEPARADOR,yytext());} + + +"+" {return newSym(sym.OPERADOR_SOMA,yytext());} +"-" {return newSym(sym.OPERADOR,yytext());} +"*" {return newSym(sym.OPERADOR,yytext());} +"/" {return newSym(sym.OPERADOR,yytext());} +"mod" {return newSym(sym.OPERADOR,yytext());} +"div" {return newSym(sym.OPERADOR,yytext());} + + + +"pot" {return newSym(sym.POTENCIA,yytext());} +"modulo" {return newSym(sym.MODULO,yytext());} +"sen" {return newSym(sym.SENO,yytext());} +"cos" {return newSym(sym.COSSENO,yytext());} +"tan" {return newSym(sym.TANGENTE,yytext());} +"raiz" {return newSym(sym.RAIZ,yytext());} + +"PI" {return newSym(sym.PI,yytext());} + +"<" {return newSym(sym.CONDICIONAL_NUMERICA,yytext());} +"<=" {return newSym(sym.CONDICIONAL_NUMERICA,yytext());} +">" {return newSym(sym.CONDICIONAL_NUMERICA,yytext());} +">=" {return newSym(sym.CONDICIONAL_NUMERICA,yytext());} + +"<>" {return newSym(sym.CONDICIONAL_COMPARATIVA,yytext());} +"=" {return newSym(sym.CONDICIONAL_COMPARATIVA,yytext());} + + +"<-" {return newSym(sym.ATRIBUIR,yytext());} +":=" {return newSym(sym.ATRIBUIR,yytext());} + + + + +/* +* REGIDOS POR REGEXP +*/ +{inteiro} {return newSym(sym.NUMERO_INT, yytext()); } +{float} {return newSym(sym.NUMERO_FLOAT, yytext()); } +{identifier} {return newSym(sym.ID,yytext()); } +{string} {return newSym(sym.STRING, yytext()); } +{char} {return newSym(sym.CHAR, yytext()); } +{newline} {/* IGNORE */} +{whitespace} {/* IGNORE */} + + +< > {return newSym(sym.EOF);} +. {return newSym(sym.error,yytext()); } \ No newline at end of file diff --git a/src/com/compilador/portugol/PortugolFlex.java b/src/com/compilador/portugol/PortugolFlex.java new file mode 100644 index 0000000..0669019 --- /dev/null +++ b/src/com/compilador/portugol/PortugolFlex.java @@ -0,0 +1,1132 @@ +/* The following code was generated by JFlex 1.5.1 */ + +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (TOKENS). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +import java_cup.runtime.*; + + + +/** + * This class is a scanner generated by + * JFlex 1.5.1 + * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/src/com/compilador/portugol/Portugol.flex + */ +class PortugolFlex implements java_cup.runtime.Scanner { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\11\1\16\1\57\1\57\1\14\22\0\1\11\1\0\1\13"+ + "\4\0\1\15\1\46\1\47\1\20\1\10\1\51\1\4\1\5\1\17"+ + "\12\2\1\50\1\0\1\54\1\55\1\56\2\0\4\1\1\6\3\1"+ + "\1\53\6\1\1\52\12\1\1\44\1\12\1\45\1\0\1\3\1\0"+ + "\1\21\1\1\1\33\1\43\1\7\1\35\1\23\1\41\1\26\2\1"+ + "\1\22\1\30\1\32\1\24\1\40\1\36\1\25\1\34\1\27\1\37"+ + "\1\31\3\1\1\42\12\0\1\57\u1fa2\0\1\57\1\57\udfd6\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ + "\1\10\1\1\1\10\1\1\2\4\16\2\1\11\1\12"+ + "\1\13\1\14\1\15\1\16\1\2\1\17\1\20\1\17"+ + "\2\5\1\21\2\2\2\0\1\22\2\0\1\23\1\24"+ + "\1\0\4\2\1\25\12\2\1\26\6\2\1\27\1\2"+ + "\1\30\1\31\1\17\1\5\4\2\1\0\2\24\2\0"+ + "\1\2\1\32\7\2\1\33\1\4\2\2\1\34\1\2"+ + "\1\35\2\2\1\36\1\37\7\2\1\40\1\4\5\2"+ + "\1\0\1\2\1\41\2\2\1\42\1\43\7\2\1\44"+ + "\3\2\1\45\6\2\1\46\1\2\1\47\14\2\1\50"+ + "\1\51\1\2\1\52\1\2\1\53\3\2\1\54\3\2"+ + "\1\55\3\2\1\56\2\2\1\57\1\2\1\60\7\2"+ + "\1\61\1\2\1\62\1\63\11\2\1\64\1\65\1\66"+ + "\10\2\1\67\1\70\4\2\1\71\1\72\1\2\1\73"+ + "\1\2\1\74\1\2\1\75"; + + private static int [] zzUnpackAction() { + int [] result = new int[230]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\60"+ + "\0\60\0\u0150\0\u0180\0\u01b0\0\u01e0\0\60\0\u0210\0\u0240"+ + "\0\u0270\0\u02a0\0\u02d0\0\u0300\0\u0330\0\u0360\0\u0390\0\u03c0"+ + "\0\u03f0\0\u0420\0\u0450\0\u0480\0\60\0\60\0\60\0\60"+ + "\0\u04b0\0\60\0\u04e0\0\u0510\0\60\0\u0540\0\u0570\0\u05a0"+ + "\0\60\0\u05d0\0\u0600\0\u0150\0\u0630\0\60\0\u0660\0\u0690"+ + "\0\60\0\u06c0\0\u06f0\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0"+ + "\0\u0810\0\u0840\0\u0870\0\u08a0\0\u08d0\0\u0900\0\u0930\0\u0960"+ + "\0\u0990\0\u09c0\0\u09f0\0\u0a20\0\u0a50\0\u0a80\0\u0ab0\0\u0ae0"+ + "\0\u0b10\0\140\0\u0b40\0\60\0\140\0\60\0\u0b70\0\u0ba0"+ + "\0\u0bd0\0\u0c00\0\u0c30\0\u0c60\0\u0c90\0\60\0\u0cc0\0\u0cf0"+ + "\0\u0d20\0\140\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40"+ + "\0\u0e70\0\140\0\u0ea0\0\u0ed0\0\u0f00\0\140\0\u0f30\0\140"+ + "\0\u0f60\0\u0f90\0\140\0\u0fc0\0\u0ff0\0\u1020\0\u1050\0\u1080"+ + "\0\u10b0\0\u10e0\0\u1110\0\140\0\140\0\u1140\0\u1170\0\u11a0"+ + "\0\u11d0\0\u1200\0\u1230\0\u1260\0\140\0\u1290\0\u12c0\0\140"+ + "\0\140\0\u12f0\0\u1320\0\u1350\0\u1380\0\u13b0\0\u13e0\0\u1410"+ + "\0\140\0\u1440\0\u1470\0\u14a0\0\140\0\u14d0\0\u1500\0\u1530"+ + "\0\u1560\0\u1590\0\u15c0\0\140\0\u15f0\0\140\0\u1620\0\u1650"+ + "\0\u1680\0\u16b0\0\u16e0\0\u1710\0\u1740\0\u1770\0\u17a0\0\u17d0"+ + "\0\u1800\0\u1830\0\140\0\140\0\u1860\0\140\0\u1890\0\140"+ + "\0\u18c0\0\u18f0\0\u1920\0\140\0\u1950\0\u1980\0\u19b0\0\140"+ + "\0\u19e0\0\u1a10\0\u1a40\0\140\0\u1a70\0\u1aa0\0\140\0\u1ad0"+ + "\0\140\0\u1b00\0\u1b30\0\u1b60\0\u1b90\0\u1bc0\0\u1bf0\0\u1c20"+ + "\0\140\0\u1c50\0\140\0\u1c80\0\u1cb0\0\u1ce0\0\u1d10\0\u1d40"+ + "\0\u1d70\0\u1da0\0\u1dd0\0\u1e00\0\u1e30\0\140\0\140\0\140"+ + "\0\u1e60\0\u1e90\0\u1ec0\0\u1ef0\0\u1f20\0\u1f50\0\u1f80\0\u1fb0"+ + "\0\140\0\140\0\u1fe0\0\u2010\0\u2040\0\u2070\0\140\0\140"+ + "\0\u20a0\0\140\0\u20d0\0\140\0\u2100\0\140"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[230]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\1\3\1\4\1\2\1\5\1\6\1\3\1\7"+ + "\1\10\1\11\1\2\1\12\1\13\1\14\1\11\1\15"+ + "\1\16\1\17\1\20\1\3\1\21\1\22\1\23\1\24"+ + "\1\25\1\26\1\27\1\30\1\31\1\32\2\3\1\33"+ + "\2\3\1\34\1\35\1\36\1\37\1\40\1\41\1\42"+ + "\1\43\1\3\1\44\1\45\1\46\62\0\3\3\2\0"+ + "\2\3\11\0\23\3\6\0\2\3\6\0\1\4\2\0"+ + "\1\47\2\50\52\0\1\4\2\0\1\47\54\0\1\47"+ + "\2\0\1\51\2\50\51\0\3\3\2\0\2\3\11\0"+ + "\11\3\1\52\1\3\1\53\7\3\6\0\2\3\4\0"+ + "\12\54\1\55\1\56\2\54\1\56\41\54\16\0\1\11"+ + "\41\0\12\57\1\60\2\57\2\61\41\57\17\0\1\62"+ + "\1\63\40\0\3\3\2\0\2\3\11\0\1\3\1\64"+ + "\4\3\1\65\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\1\3\1\66\11\0\3\3\1\67\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\16\3\1\70\4\3"+ + "\6\0\2\3\5\0\3\3\2\0\1\3\1\71\11\0"+ + "\1\72\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\11\3\1\73\11\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\74\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\75\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\1\3\1\76\11\0\1\77"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\100\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\101\2\3\1\102\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\1\3\1\103\11\0\6\3\1\104\14\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\105"+ + "\4\3\1\106\10\3\1\107\4\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\110\2\3\1\111\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\1\3\1\112\11\0"+ + "\5\3\1\113\15\3\6\0\2\3\61\0\1\114\3\0"+ + "\3\3\2\0\2\3\11\0\23\3\6\0\1\3\1\115"+ + "\10\0\1\114\50\0\1\116\1\45\56\0\1\116\4\0"+ + "\1\47\3\0\2\50\52\0\1\117\1\0\1\117\3\0"+ + "\1\117\50\0\3\3\2\0\2\3\11\0\6\3\1\120"+ + "\6\3\1\121\5\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\12\3\1\122\4\3\1\123\3\3\6\0"+ + "\2\3\4\0\16\54\1\56\41\54\12\0\1\124\2\0"+ + "\2\61\41\0\16\57\1\61\41\57\14\62\1\125\1\62"+ + "\1\126\41\62\20\127\1\130\37\127\1\0\3\3\2\0"+ + "\2\3\11\0\2\3\1\131\20\3\6\0\2\3\5\0"+ + "\3\3\2\0\1\3\1\132\11\0\23\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\5\3\1\133\15\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\2\3"+ + "\1\134\20\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\6\3\1\135\14\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\136\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\5\3\1\137\15\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\5\3\1\140"+ + "\1\141\14\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\11\3\1\142\11\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\22\3\1\143\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\144\1\3\1\145"+ + "\14\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\146\14\3\1\147\1\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\150\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\4\3\1\151"+ + "\6\3\1\152\7\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\13\3\1\153\7\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\11\3\1\154\11\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\4\3\1\155"+ + "\16\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\3\1\156\10\3\1\157\10\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\7\3\1\160\13\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\11\3\1\161"+ + "\11\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\162\6\3\1\163\7\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\164\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\10\3\1\165"+ + "\12\3\6\0\2\3\6\0\1\117\56\0\3\3\2\0"+ + "\2\3\11\0\1\166\22\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\16\3\1\167\4\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\170\1\171"+ + "\16\3\6\0\2\3\5\0\3\3\2\0\1\3\1\172"+ + "\11\0\23\3\6\0\2\3\22\0\1\61\57\0\1\126"+ + "\41\0\20\127\1\173\37\127\17\0\1\126\1\130\40\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\174\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\175\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\5\3"+ + "\1\176\15\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\177\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\3\1\200\21\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\21\3\1\201\1\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\12\3"+ + "\1\202\10\3\6\0\2\3\5\0\3\3\2\0\1\3"+ + "\1\203\11\0\23\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\16\3\1\204\4\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\22\3\1\205\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\206\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\5\3"+ + "\1\207\15\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\210\22\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\211\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\212\22\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\5\3\1\213\15\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\13\3"+ + "\1\214\7\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\215\22\3\6\0\2\3\5\0\3\3\2\0"+ + "\1\3\1\216\11\0\1\217\12\3\1\220\1\221\2\3"+ + "\1\222\3\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\12\3\1\223\10\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\224\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\13\3\1\225\7\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\226"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\227\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\3\1\230\21\3\6\0\2\3\5\0\3\3"+ + "\2\0\1\3\1\231\11\0\23\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\232\16\3\6\0"+ + "\2\3\4\0\17\127\1\126\1\173\37\127\1\0\3\3"+ + "\2\0\2\3\11\0\4\3\1\233\16\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\12\3\1\234\10\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\235\17\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\5\3\1\236\15\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\4\3\1\237\1\240\15\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\3\1\241"+ + "\21\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\242\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\243\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\3\3\1\244\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\12\3\1\245\10\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\246\17\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\11\3\1\247\11\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\3\3\1\250\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\11\3\1\251\1\3"+ + "\1\252\7\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\3\1\253\21\3\6\0\2\3\5\0\3\3"+ + "\2\0\1\3\1\254\11\0\23\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\16\3\1\255\4\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\256\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\257"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\3\3\1\260\17\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\11\3\1\261\11\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\20\3\1\262\2\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\10\3\1\263"+ + "\12\3\6\0\2\3\5\0\3\3\2\0\1\3\1\264"+ + "\11\0\23\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\5\3\1\265\15\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\3\3\1\200\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\12\3\1\266\10\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\267\17\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\270\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\4\3\1\234\16\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\271\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\22\3"+ + "\1\272\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\6\3\1\273\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\2\3\1\200\20\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\15\3\1\274\5\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\12\3\1\275"+ + "\10\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\2\3\1\276\20\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\11\3\1\277\11\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\300\16\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\301"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\6\3\1\302\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\1\303\22\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\304\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\305\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\306\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\307\17\3\6\0\2\3\5\0\3\3\2\0\1\3"+ + "\1\310\11\0\23\3\6\0\2\3\5\0\3\3\2\0"+ + "\1\3\1\311\11\0\23\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\16\3\1\312\4\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\313\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\314\17\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\12\3\1\315\10\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\316\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\317\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\3\1\320"+ + "\21\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\7\3\1\321\13\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\13\3\1\322\7\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\7\3\1\323\13\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\5\3\1\324"+ + "\15\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\200\16\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\1\325\22\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\3\1\326\21\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\4\3\1\327\16\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\330"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\3\3\1\331\17\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\332\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\17\3\1\333\3\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\4\3\1\214"+ + "\16\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\11\3\1\334\11\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\20\3\1\335\2\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\5\3\1\336\15\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\337"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\340\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\6\3\1\341\14\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\342\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\343\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\344"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\7\3\1\345\13\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\346\17\3\6\0\2\3\4\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[8496]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\1\11\5\1\2\11\4\1\1\11\16\1\4\11"+ + "\1\1\1\11\2\1\1\11\3\1\1\11\2\1\2\0"+ + "\1\11\2\0\1\11\1\1\1\0\30\1\1\11\1\1"+ + "\1\11\5\1\1\0\1\1\1\11\2\0\42\1\1\0"+ + "\153\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[230]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + + public PortugolFlex() { + super(); + } + + Symbol newSym(int tokenId) { + return new Symbol(tokenId , yyline, yycolumn); + } + + Symbol newSym(int tokenId, Object value) { + return new Symbol(tokenId , yyline, yycolumn, value); + } + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + PortugolFlex(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + PortugolFlex(java.io.InputStream in) { + this(new java.io.InputStreamReader + (in, java.nio.charset.Charset.forName("UTF-8"))); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 138) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @returnfalse
, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead > 0) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * Internal scan buffer is resized down to its initial length, if it has grown. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + if (zzBuffer.length > ZZ_BUFFERSIZE) + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void zzDoEOF() throws java.io.IOException { + if (!zzEOFDone) { + zzEOFDone = true; + yyclose(); + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar+= zzMarkedPosL-zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) + zzR = false; + else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; + } + } + + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + else if (zzAtEOF) + zzPeek = false; + else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) + zzPeek = false; + else + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } + if (zzPeek) yyline--; + } + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return newSym(sym.error,yytext()); + } + case 62: break; + case 2: + { return newSym(sym.ID,yytext()); + } + case 63: break; + case 3: + { return newSym(sym.NUMERO_INT, yytext()); + } + case 64: break; + case 4: + { return newSym(sym.OPERADOR,yytext()); + } + case 65: break; + case 5: + { return newSym(sym.NUMERO_FLOAT, yytext()); + } + case 66: break; + case 6: + { return newSym(sym.E,yytext()); + } + case 67: break; + case 7: + { return newSym(sym.OPERADOR_SOMA,yytext()); + } + case 68: break; + case 8: + { /* IGNORE */ + } + case 69: break; + case 9: + { return newSym(sym.ABRIR_COLCHETE,yytext()); + } + case 70: break; + case 10: + { return newSym(sym.FECHAR_COLCHETE,yytext()); + } + case 71: break; + case 11: + { return newSym(sym.ABRIR_PARENTESE,yytext()); + } + case 72: break; + case 12: + { return newSym(sym.FECHAR_PARENTESE,yytext()); + } + case 73: break; + case 13: + { return newSym(sym.ADD_ATTR_VAR,yytext()); + } + case 74: break; + case 14: + { return newSym(sym.SEPARADOR,yytext()); + } + case 75: break; + case 15: + { return newSym(sym.CONDICIONAL_NUMERICA,yytext()); + } + case 76: break; + case 16: + { return newSym(sym.CONDICIONAL_COMPARATIVA,yytext()); + } + case 77: break; + case 17: + { return newSym(sym.DOIS_PONTOS,yytext()); + } + case 78: break; + case 18: + { return newSym(sym.STRING, yytext()); + } + case 79: break; + case 19: + { return newSym(sym.CHAR, yytext()); + } + case 80: break; + case 20: + { /* IGNORAR COMENTARIOS */ + } + case 81: break; + case 21: + { return newSym(sym.OU,yytext()); + } + case 82: break; + case 22: + { return newSym(sym.SE,yytext()); + } + case 83: break; + case 23: + { return newSym(sym.DE,yytext()); + } + case 84: break; + case 24: + { return newSym(sym.ATRIBUIR,yytext()); + } + case 85: break; + case 25: + { return newSym(sym.PI,yytext()); + } + case 86: break; + case 26: + { return newSym(sym.ATE,yytext()); + } + case 87: break; + case 27: + { return newSym(sym.TANGENTE,yytext()); + } + case 88: break; + case 28: + { return newSym(sym.VAR,yytext()); + } + case 89: break; + case 29: + { return newSym(sym.NAO,yytext()); + } + case 90: break; + case 30: + { return newSym(sym.COSSENO,yytext()); + } + case 91: break; + case 31: + { return newSym(sym.SENO,yytext()); + } + case 92: break; + case 32: + { return newSym(sym.POTENCIA,yytext()); + } + case 93: break; + case 33: + { return newSym(sym.LEIA,yytext()); + } + case 94: break; + case 34: + { return newSym(sym.TIPO_VARIAVEL,yytext()); + } + case 95: break; + case 35: + { return newSym(sym.RAIZ,yytext()); + } + case 96: break; + case 36: + { return newSym(sym.CASO,yytext()); + } + case 97: break; + case 37: + { return newSym(sym.FACA,yytext()); + } + case 98: break; + case 38: + { return newSym(sym.PARA,yytext()); + } + case 99: break; + case 39: + { return newSym(sym.ENTAO,yytext()); + } + case 100: break; + case 40: + { return newSym(sym.TIPO_VARIAVEL_VETOR,yytext()); + } + case 101: break; + case 41: + { return newSym(sym.VOID,yytext()); + } + case 102: break; + case 42: + { return newSym(sym.SENAO,yytext()); + } + case 103: break; + case 43: + { return newSym(sym.VALOR_LOGICO,yytext()); + } + case 104: break; + case 44: + { return newSym(sym.FIMSE,yytext()); + } + case 105: break; + case 45: + { return newSym(sym.PASSO,yytext()); + } + case 106: break; + case 46: + { return newSym(sym.ESPERAR,yytext()); + } + case 107: break; + case 47: + { return newSym(sym.INICIO,yytext()); + } + case 108: break; + case 48: + { return newSym(sym.MODULO,yytext()); + } + case 109: break; + case 49: + { return newSym(sym.FUNCAO,yytext()); + } + case 110: break; + case 50: + { return newSym(sym.ESCOLHA,yytext()); + } + case 111: break; + case 51: + { return newSym(sym.ESCREVA,yytext()); + } + case 112: break; + case 52: + { return newSym(sym.FIMPARA,yytext()); + } + case 113: break; + case 53: + { return newSym(sym.ENQUANTO,yytext()); + } + case 114: break; + case 54: + { return newSym(sym.ESCREVAL,yytext()); + } + case 115: break; + case 55: + { return newSym(sym.ALGORITMO,yytext()); + } + case 116: break; + case 56: + { return newSym(sym.OUTROCASO,yytext()); + } + case 117: break; + case 57: + { return newSym(sym.FIMFUNCAO,yytext()); + } + case 118: break; + case 58: + { return newSym(sym.INTERROMPA,yytext()); + } + case 119: break; + case 59: + { return newSym(sym.FIMESCOLHA,yytext()); + } + case 120: break; + case 60: + { return newSym(sym.FIMENQUANTO,yytext()); + } + case 121: break; + case 61: + { return newSym(sym.FIMALGORITMO,yytext()); + } + case 122: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + zzDoEOF(); + { + return newSym(sym.EOF); + } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/com/compilador/portugol/PortugolFlex.java~ b/src/com/compilador/portugol/PortugolFlex.java~ new file mode 100644 index 0000000..ec90ceb --- /dev/null +++ b/src/com/compilador/portugol/PortugolFlex.java~ @@ -0,0 +1,1130 @@ +/* The following code was generated by JFlex 1.5.1 */ + +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (TOKENS). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +import java_cup.runtime.*; + + + +/** + * This class is a scanner generated by + * JFlex 1.5.1 + * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/src/com/compilador/portugol/Portugol.flex + */ +class PortugolFlex implements java_cup.runtime.Scanner { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\11\1\16\1\57\1\57\1\14\22\0\1\11\1\0\1\13"+ + "\4\0\1\15\1\46\1\47\1\20\1\10\1\51\1\4\1\5\1\17"+ + "\12\2\1\50\1\0\1\54\1\55\1\56\2\0\4\1\1\6\3\1"+ + "\1\53\6\1\1\52\12\1\1\44\1\12\1\45\1\0\1\3\1\0"+ + "\1\21\1\1\1\33\1\43\1\7\1\35\1\23\1\41\1\26\2\1"+ + "\1\22\1\30\1\32\1\24\1\40\1\36\1\25\1\34\1\27\1\37"+ + "\1\31\3\1\1\42\12\0\1\57\u1fa2\0\1\57\1\57\udfd6\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ + "\1\10\1\1\1\10\1\1\2\4\16\2\1\11\1\12"+ + "\1\13\1\14\1\15\1\16\1\2\1\17\1\20\1\17"+ + "\2\5\1\21\2\2\2\0\1\22\2\0\1\23\1\24"+ + "\1\0\4\2\1\25\12\2\1\26\6\2\1\27\1\2"+ + "\1\30\1\31\1\17\1\5\4\2\1\0\2\24\2\0"+ + "\1\2\1\32\7\2\1\33\1\4\2\2\1\34\1\2"+ + "\1\35\2\2\1\36\1\37\7\2\1\40\1\4\5\2"+ + "\1\0\1\2\1\41\2\2\1\42\1\43\2\2\1\44"+ + "\4\2\1\45\3\2\1\46\6\2\1\47\1\2\1\50"+ + "\13\2\1\51\1\52\1\2\1\53\1\2\1\54\3\2"+ + "\1\55\3\2\1\56\3\2\1\57\2\2\1\60\10\2"+ + "\1\61\1\2\1\62\1\63\11\2\1\64\1\65\1\66"+ + "\10\2\1\67\1\70\4\2\1\71\1\72\1\2\1\73"+ + "\1\2\1\74\1\2\1\75"; + + private static int [] zzUnpackAction() { + int [] result = new int[228]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\60"+ + "\0\60\0\u0150\0\u0180\0\u01b0\0\u01e0\0\60\0\u0210\0\u0240"+ + "\0\u0270\0\u02a0\0\u02d0\0\u0300\0\u0330\0\u0360\0\u0390\0\u03c0"+ + "\0\u03f0\0\u0420\0\u0450\0\u0480\0\60\0\60\0\60\0\60"+ + "\0\u04b0\0\60\0\u04e0\0\u0510\0\60\0\u0540\0\u0570\0\u05a0"+ + "\0\60\0\u05d0\0\u0600\0\u0150\0\u0630\0\60\0\u0660\0\u0690"+ + "\0\60\0\u06c0\0\u06f0\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0"+ + "\0\u0810\0\u0840\0\u0870\0\u08a0\0\u08d0\0\u0900\0\u0930\0\u0960"+ + "\0\u0990\0\u09c0\0\u09f0\0\u0a20\0\u0a50\0\u0a80\0\u0ab0\0\u0ae0"+ + "\0\u0b10\0\140\0\u0b40\0\60\0\140\0\60\0\u0b70\0\u0ba0"+ + "\0\u0bd0\0\u0c00\0\u0c30\0\u0c60\0\u0c90\0\60\0\u0cc0\0\u0cf0"+ + "\0\u0d20\0\140\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40"+ + "\0\u0e70\0\140\0\u0ea0\0\u0ed0\0\u0f00\0\140\0\u0f30\0\140"+ + "\0\u0f60\0\u0f90\0\140\0\u0fc0\0\u0ff0\0\u1020\0\u1050\0\u1080"+ + "\0\u10b0\0\u10e0\0\u1110\0\140\0\140\0\u1140\0\u1170\0\u11a0"+ + "\0\u11d0\0\u1200\0\u1230\0\u1260\0\140\0\u1290\0\u12c0\0\140"+ + "\0\140\0\u12f0\0\u1320\0\140\0\u1350\0\u1380\0\u13b0\0\u13e0"+ + "\0\140\0\u1410\0\u1440\0\u1470\0\140\0\u14a0\0\u14d0\0\u1500"+ + "\0\u1530\0\u1560\0\u1590\0\140\0\u15c0\0\140\0\u15f0\0\u1620"+ + "\0\u1650\0\u1680\0\u16b0\0\u16e0\0\u1710\0\u1740\0\u1770\0\u17a0"+ + "\0\u17d0\0\140\0\140\0\u1800\0\140\0\u1830\0\140\0\u1860"+ + "\0\u1890\0\u18c0\0\140\0\u18f0\0\u1920\0\u1950\0\140\0\u1980"+ + "\0\u19b0\0\u19e0\0\140\0\u1a10\0\u1a40\0\140\0\u1a70\0\u1aa0"+ + "\0\u1ad0\0\u1b00\0\u1b30\0\u1b60\0\u1b90\0\u1bc0\0\140\0\u1bf0"+ + "\0\140\0\u1c20\0\u1c50\0\u1c80\0\u1cb0\0\u1ce0\0\u1d10\0\u1d40"+ + "\0\u1d70\0\u1da0\0\u1dd0\0\140\0\140\0\140\0\u1e00\0\u1e30"+ + "\0\u1e60\0\u1e90\0\u1ec0\0\u1ef0\0\u1f20\0\u1f50\0\140\0\140"+ + "\0\u1f80\0\u1fb0\0\u1fe0\0\u2010\0\140\0\140\0\u2040\0\140"+ + "\0\u2070\0\140\0\u20a0\0\140"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[228]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\1\3\1\4\1\2\1\5\1\6\1\3\1\7"+ + "\1\10\1\11\1\2\1\12\1\13\1\14\1\11\1\15"+ + "\1\16\1\17\1\20\1\3\1\21\1\22\1\23\1\24"+ + "\1\25\1\26\1\27\1\30\1\31\1\32\2\3\1\33"+ + "\2\3\1\34\1\35\1\36\1\37\1\40\1\41\1\42"+ + "\1\43\1\3\1\44\1\45\1\46\62\0\3\3\2\0"+ + "\2\3\11\0\23\3\6\0\2\3\6\0\1\4\2\0"+ + "\1\47\2\50\52\0\1\4\2\0\1\47\54\0\1\47"+ + "\2\0\1\51\2\50\51\0\3\3\2\0\2\3\11\0"+ + "\11\3\1\52\1\3\1\53\7\3\6\0\2\3\4\0"+ + "\12\54\1\55\1\56\2\54\1\56\41\54\16\0\1\11"+ + "\41\0\12\57\1\60\2\57\2\61\41\57\17\0\1\62"+ + "\1\63\40\0\3\3\2\0\2\3\11\0\1\3\1\64"+ + "\4\3\1\65\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\1\3\1\66\11\0\3\3\1\67\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\16\3\1\70\4\3"+ + "\6\0\2\3\5\0\3\3\2\0\1\3\1\71\11\0"+ + "\1\72\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\11\3\1\73\11\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\74\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\75\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\1\3\1\76\11\0\1\77"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\100\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\101\2\3\1\102\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\1\3\1\103\11\0\6\3\1\104\14\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\105"+ + "\4\3\1\106\10\3\1\107\4\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\110\2\3\1\111\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\1\3\1\112\11\0"+ + "\5\3\1\113\15\3\6\0\2\3\61\0\1\114\3\0"+ + "\3\3\2\0\2\3\11\0\23\3\6\0\1\3\1\115"+ + "\10\0\1\114\50\0\1\116\1\45\56\0\1\116\4\0"+ + "\1\47\3\0\2\50\52\0\1\117\1\0\1\117\3\0"+ + "\1\117\50\0\3\3\2\0\2\3\11\0\6\3\1\120"+ + "\6\3\1\121\5\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\12\3\1\122\4\3\1\123\3\3\6\0"+ + "\2\3\4\0\16\54\1\56\41\54\12\0\1\124\2\0"+ + "\2\61\41\0\16\57\1\61\41\57\14\62\1\125\1\62"+ + "\1\126\41\62\20\127\1\130\37\127\1\0\3\3\2\0"+ + "\2\3\11\0\2\3\1\131\20\3\6\0\2\3\5\0"+ + "\3\3\2\0\1\3\1\132\11\0\23\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\5\3\1\133\15\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\2\3"+ + "\1\134\20\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\6\3\1\135\14\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\136\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\5\3\1\137\15\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\5\3\1\140"+ + "\1\141\14\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\11\3\1\142\11\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\22\3\1\143\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\144\1\3\1\145"+ + "\14\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\146\14\3\1\147\1\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\150\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\4\3\1\151"+ + "\6\3\1\152\7\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\13\3\1\153\7\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\11\3\1\154\11\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\4\3\1\155"+ + "\16\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\3\1\156\10\3\1\157\10\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\7\3\1\160\13\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\11\3\1\161"+ + "\11\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\162\6\3\1\163\7\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\164\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\10\3\1\165"+ + "\12\3\6\0\2\3\6\0\1\117\56\0\3\3\2\0"+ + "\2\3\11\0\1\166\22\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\16\3\1\167\4\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\170\1\171"+ + "\16\3\6\0\2\3\5\0\3\3\2\0\1\3\1\172"+ + "\11\0\23\3\6\0\2\3\22\0\1\61\57\0\1\126"+ + "\41\0\20\127\1\173\37\127\17\0\1\126\1\130\40\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\174\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\175\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\5\3"+ + "\1\176\15\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\177\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\3\1\200\21\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\21\3\1\201\1\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\12\3"+ + "\1\202\10\3\6\0\2\3\5\0\3\3\2\0\1\3"+ + "\1\203\11\0\23\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\204\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\22\3\1\205\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\206\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\5\3"+ + "\1\207\15\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\210\22\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\211\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\212\22\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\5\3\1\213\15\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\13\3"+ + "\1\214\7\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\215\22\3\6\0\2\3\5\0\3\3\2\0"+ + "\1\3\1\216\11\0\1\217\12\3\1\220\1\221\2\3"+ + "\1\222\3\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\12\3\1\223\10\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\224\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\13\3\1\225\7\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\226"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\1\227\22\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\1\3\1\230\21\3\6\0\2\3\5\0\3\3"+ + "\2\0\1\3\1\231\11\0\23\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\232\16\3\6\0"+ + "\2\3\4\0\17\127\1\126\1\173\37\127\1\0\3\3"+ + "\2\0\2\3\11\0\4\3\1\233\16\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\12\3\1\234\10\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\3\3"+ + "\1\235\17\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\5\3\1\236\15\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\4\3\1\237\1\240\15\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\241\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\4\3"+ + "\1\242\16\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\3\3\1\243\17\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\12\3\1\244\10\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\245\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\11\3"+ + "\1\246\11\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\3\3\1\247\17\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\11\3\1\250\1\3\1\251\7\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\3"+ + "\1\252\21\3\6\0\2\3\5\0\3\3\2\0\1\3"+ + "\1\253\11\0\23\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\16\3\1\254\4\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\255\22\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\1\256\22\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\257"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\11\3\1\260\11\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\20\3\1\261\2\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\10\3\1\262\12\3\6\0"+ + "\2\3\5\0\3\3\2\0\1\3\1\263\11\0\23\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\5\3"+ + "\1\264\15\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\3\3\1\200\17\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\12\3\1\265\10\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\3\3\1\266\17\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\4\3"+ + "\1\267\16\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\234\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\22\3\1\270\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\271\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\2\3\1\200"+ + "\20\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\15\3\1\272\5\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\12\3\1\273\10\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\2\3\1\274\20\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\11\3\1\275"+ + "\11\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\4\3\1\276\16\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\277\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\6\3\1\300\14\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\301\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\302"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\6\3\1\303\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\1\304\22\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\3\3\1\305\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\1\3\1\306\11\0\23\3\6\0"+ + "\2\3\5\0\3\3\2\0\1\3\1\307\11\0\23\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\16\3"+ + "\1\310\4\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\3\3\1\311\17\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\3\3\1\312\17\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\12\3\1\313\10\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\314"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\3\3\1\315\17\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\1\3\1\316\21\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\7\3\1\317\13\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\13\3\1\320"+ + "\7\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\7\3\1\321\13\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\5\3\1\322\15\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\4\3\1\200\16\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\1\323\22\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\3"+ + "\1\324\21\3\6\0\2\3\5\0\3\3\2\0\2\3"+ + "\11\0\4\3\1\325\16\3\6\0\2\3\5\0\3\3"+ + "\2\0\2\3\11\0\1\326\22\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\3\3\1\327\17\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\330"+ + "\17\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\17\3\1\331\3\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\4\3\1\214\16\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\11\3\1\332\11\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\20\3\1\333"+ + "\2\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\5\3\1\334\15\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\335\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\1\336\22\3\6\0\2\3"+ + "\5\0\3\3\2\0\2\3\11\0\6\3\1\337\14\3"+ + "\6\0\2\3\5\0\3\3\2\0\2\3\11\0\1\340"+ + "\22\3\6\0\2\3\5\0\3\3\2\0\2\3\11\0"+ + "\6\3\1\341\14\3\6\0\2\3\5\0\3\3\2\0"+ + "\2\3\11\0\3\3\1\342\17\3\6\0\2\3\5\0"+ + "\3\3\2\0\2\3\11\0\7\3\1\343\13\3\6\0"+ + "\2\3\5\0\3\3\2\0\2\3\11\0\3\3\1\344"+ + "\17\3\6\0\2\3\4\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[8400]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of stateaState
+ */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\1\11\5\1\2\11\4\1\1\11\16\1\4\11"+ + "\1\1\1\11\2\1\1\11\3\1\1\11\2\1\2\0"+ + "\1\11\2\0\1\11\1\1\1\0\30\1\1\11\1\1"+ + "\1\11\5\1\1\0\1\1\1\11\2\0\42\1\1\0"+ + "\151\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[228]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + + public PortugolFlex() { + super(); + } + + Symbol newSym(int tokenId) { + return new Symbol(tokenId , yyline, yycolumn); + } + + Symbol newSym(int tokenId, Object value) { + return new Symbol(tokenId , yyline, yycolumn, value); + } + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + PortugolFlex(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + PortugolFlex(java.io.InputStream in) { + this(new java.io.InputStreamReader + (in, java.nio.charset.Charset.forName("UTF-8"))); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 138) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @returnfalse
, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead > 0) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * Internal scan buffer is resized down to its initial length, if it has grown. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + if (zzBuffer.length > ZZ_BUFFERSIZE) + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void zzDoEOF() throws java.io.IOException { + if (!zzEOFDone) { + zzEOFDone = true; + yyclose(); + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar+= zzMarkedPosL-zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) + zzR = false; + else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; + } + } + + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + else if (zzAtEOF) + zzPeek = false; + else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) + zzPeek = false; + else + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } + if (zzPeek) yyline--; + } + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return newSym(sym.error,yytext()); + } + case 62: break; + case 2: + { return newSym(sym.ID,yytext()); + } + case 63: break; + case 3: + { return newSym(sym.NUMERO_INT, yytext()); + } + case 64: break; + case 4: + { return newSym(sym.OPERADOR,yytext()); + } + case 65: break; + case 5: + { return newSym(sym.NUMERO_FLOAT, yytext()); + } + case 66: break; + case 6: + { return newSym(sym.E,yytext()); + } + case 67: break; + case 7: + { return newSym(sym.OPERADOR_SOMA,yytext()); + } + case 68: break; + case 8: + { /* IGNORE */ + } + case 69: break; + case 9: + { return newSym(sym.ABRIR_COLCHETE,yytext()); + } + case 70: break; + case 10: + { return newSym(sym.FECHAR_COLCHETE,yytext()); + } + case 71: break; + case 11: + { return newSym(sym.ABRIR_PARENTESE,yytext()); + } + case 72: break; + case 12: + { return newSym(sym.FECHAR_PARENTESE,yytext()); + } + case 73: break; + case 13: + { return newSym(sym.ADD_ATTR_VAR,yytext()); + } + case 74: break; + case 14: + { return newSym(sym.SEPARADOR,yytext()); + } + case 75: break; + case 15: + { return newSym(sym.CONDICIONAL_NUMERICA,yytext()); + } + case 76: break; + case 16: + { return newSym(sym.CONDICIONAL_COMPARATIVA,yytext()); + } + case 77: break; + case 17: + { return newSym(sym.DOIS_PONTOS,yytext()); + } + case 78: break; + case 18: + { return newSym(sym.STRING, yytext()); + } + case 79: break; + case 19: + { return newSym(sym.CHAR, yytext()); + } + case 80: break; + case 20: + { /* IGNORAR COMENTARIOS */ + } + case 81: break; + case 21: + { return newSym(sym.OU,yytext()); + } + case 82: break; + case 22: + { return newSym(sym.SE,yytext()); + } + case 83: break; + case 23: + { return newSym(sym.DE,yytext()); + } + case 84: break; + case 24: + { return newSym(sym.ATRIBUIR,yytext()); + } + case 85: break; + case 25: + { return newSym(sym.PI,yytext()); + } + case 86: break; + case 26: + { return newSym(sym.ATE,yytext()); + } + case 87: break; + case 27: + { return newSym(sym.TANGENTE,yytext()); + } + case 88: break; + case 28: + { return newSym(sym.VAR,yytext()); + } + case 89: break; + case 29: + { return newSym(sym.NAO,yytext()); + } + case 90: break; + case 30: + { return newSym(sym.COSSENO,yytext()); + } + case 91: break; + case 31: + { return newSym(sym.SENO,yytext()); + } + case 92: break; + case 32: + { return newSym(sym.POTENCIA,yytext()); + } + case 93: break; + case 33: + { return newSym(sym.LEIA,yytext()); + } + case 94: break; + case 34: + { return newSym(sym.TIPO_VARIAVEL,yytext()); + } + case 95: break; + case 35: + { return newSym(sym.RAIZ,yytext()); + } + case 96: break; + case 36: + { return newSym(sym.MODULO,yytext()); + } + case 97: break; + case 37: + { return newSym(sym.CASO,yytext()); + } + case 98: break; + case 38: + { return newSym(sym.FACA,yytext()); + } + case 99: break; + case 39: + { return newSym(sym.PARA,yytext()); + } + case 100: break; + case 40: + { return newSym(sym.ENTAO,yytext()); + } + case 101: break; + case 41: + { return newSym(sym.TIPO_VARIAVEL_VETOR,yytext()); + } + case 102: break; + case 42: + { return newSym(sym.VOID,yytext()); + } + case 103: break; + case 43: + { return newSym(sym.SENAO,yytext()); + } + case 104: break; + case 44: + { return newSym(sym.VALOR_LOGICO,yytext()); + } + case 105: break; + case 45: + { return newSym(sym.FIMSE,yytext()); + } + case 106: break; + case 46: + { return newSym(sym.PASSO,yytext()); + } + case 107: break; + case 47: + { return newSym(sym.ESPERAR,yytext()); + } + case 108: break; + case 48: + { return newSym(sym.INICIO,yytext()); + } + case 109: break; + case 49: + { return newSym(sym.FUNCAO,yytext()); + } + case 110: break; + case 50: + { return newSym(sym.ESCOLHA,yytext()); + } + case 111: break; + case 51: + { return newSym(sym.ESCREVA,yytext()); + } + case 112: break; + case 52: + { return newSym(sym.FIMPARA,yytext()); + } + case 113: break; + case 53: + { return newSym(sym.ENQUANTO,yytext()); + } + case 114: break; + case 54: + { return newSym(sym.ESCREVAL,yytext()); + } + case 115: break; + case 55: + { return newSym(sym.ALGORITMO,yytext()); + } + case 116: break; + case 56: + { return newSym(sym.OUTROCASO,yytext()); + } + case 117: break; + case 57: + { return newSym(sym.FIMFUNCAO,yytext()); + } + case 118: break; + case 58: + { return newSym(sym.INTERROMPA,yytext()); + } + case 119: break; + case 59: + { return newSym(sym.FIMESCOLHA,yytext()); + } + case 120: break; + case 60: + { return newSym(sym.FIMENQUANTO,yytext()); + } + case 121: break; + case 61: + { return newSym(sym.FIMALGORITMO,yytext()); + } + case 122: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + zzDoEOF(); + { + return newSym(sym.EOF); + } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/com/compilador/portugol/java_cup.jar b/src/com/compilador/portugol/java_cup.jar new file mode 100644 index 0000000..73ffa0b Binary files /dev/null and b/src/com/compilador/portugol/java_cup.jar differ diff --git a/src/com/compilador/portugol/parser.java b/src/com/compilador/portugol/parser.java new file mode 100644 index 0000000..d6e5c90 --- /dev/null +++ b/src/com/compilador/portugol/parser.java @@ -0,0 +1,2025 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Fri Sep 26 15:47:26 BRT 2014 +//---------------------------------------------------- + +package com.compilador.portugol; + +import static com.forms.Editor.util; +import java_cup.runtime.*; +import javax.swing.JOptionPane; + +/** CUP v0.11a beta 20060608 generated parser. + * @version Fri Sep 26 15:47:26 BRT 2014 + */ +public class parser extends java_cup.runtime.lr_parser { + + /** Default constructor. */ + public parser() {super();} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s) {super(s);} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);} + + /** Production table. */ + protected static final short _production_table[][] = + unpackFromStrings(new String[] { + "\000\132\000\002\002\004\000\002\002\007\000\002\002" + + "\002\000\002\003\003\000\002\004\004\000\002\004\004" + + "\000\002\005\003\000\002\005\004\000\002\005\002\000" + + "\002\006\004\000\002\006\003\000\002\007\005\000\002" + + "\007\014\000\002\010\005\000\002\010\003\000\002\011" + + "\004\000\002\011\002\000\002\012\003\000\002\012\003" + + "\000\002\012\003\000\002\012\003\000\002\012\003\000" + + "\002\012\003\000\002\012\003\000\002\012\003\000\002" + + "\030\003\000\002\030\006\000\002\013\005\000\002\013" + + "\010\000\002\014\005\000\002\014\007\000\002\015\005" + + "\000\002\016\003\000\002\043\002\000\002\021\010\000" + + "\002\022\003\000\002\044\002\000\002\045\002\000\002" + + "\046\002\000\002\023\017\000\002\042\004\000\002\042" + + "\002\000\002\017\006\000\002\017\006\000\002\020\006" + + "\000\002\047\002\000\002\024\010\000\002\025\004\000" + + "\002\025\002\000\002\050\002\000\002\026\006\000\002" + + "\027\004\000\002\027\002\000\002\036\005\000\002\036" + + "\005\000\002\036\005\000\002\036\006\000\002\036\003" + + "\000\002\037\005\000\002\037\005\000\002\037\005\000" + + "\002\037\006\000\002\037\003\000\002\040\005\000\002" + + "\040\003\000\002\041\005\000\002\041\003\000\002\041" + + "\006\000\002\034\005\000\002\034\005\000\002\034\010" + + "\000\002\034\006\000\002\034\006\000\002\034\006\000" + + "\002\034\006\000\002\034\006\000\002\034\005\000\002" + + "\034\006\000\002\034\003\000\002\034\003\000\002\034" + + "\003\000\002\034\003\000\002\034\003\000\002\034\003" + + "\000\002\034\003\000\002\035\005\000\002\035\005\000" + + "\002\035\005\000\002\035\003\000\002\035\003" }); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + unpackFromStrings(new String[] { + "\000\305\000\006\002\uffff\004\006\001\002\000\006\005" + + "\013\010\ufff9\001\002\000\006\005\ufffe\010\ufffe\001\002" + + "\000\006\071\011\072\012\001\002\000\004\002\010\001" + + "\002\000\004\002\001\001\002\000\006\005\ufffd\010\ufffd" + + "\001\002\000\006\005\ufffc\010\ufffc\001\002\000\006\010" + + "\ufffb\071\267\001\002\000\004\010\015\001\002\000\030" + + "\022\ufff1\026\ufff1\027\ufff1\033\ufff1\037\ufff1\040\ufff1\063" + + "\ufff1\064\ufff1\065\ufff1\066\ufff1\071\ufff1\001\002\000\030" + + "\022\034\026\040\027\024\033\037\037\031\040\044\063" + + "\021\064\030\065\042\066\020\071\026\001\002\000\046" + + "\022\uffef\024\uffef\025\uffef\026\uffef\027\uffef\031\uffef\032" + + "\uffef\033\uffef\034\uffef\035\uffef\036\uffef\037\uffef\040\uffef" + + "\063\uffef\064\uffef\065\uffef\066\uffef\071\uffef\001\002\000" + + "\004\002\000\001\002\000\004\015\264\001\002\000\046" + + "\022\uffec\024\uffec\025\uffec\026\uffec\027\uffec\031\uffec\032" + + "\uffec\033\uffec\034\uffec\035\uffec\036\uffec\037\uffec\040\uffec" + + "\063\uffec\064\uffec\065\uffec\066\uffec\071\uffec\001\002\000" + + "\046\022\ufff0\024\ufff0\025\ufff0\026\ufff0\027\ufff0\031\ufff0" + + "\032\ufff0\033\ufff0\034\ufff0\035\ufff0\036\ufff0\037\ufff0\040" + + "\ufff0\063\ufff0\064\ufff0\065\ufff0\066\ufff0\071\ufff0\001\002" + + "\000\004\071\246\001\002\000\046\022\ufff2\024\ufff2\025" + + "\ufff2\026\ufff2\027\ufff2\031\ufff2\032\ufff2\033\ufff2\034\ufff2" + + "\035\ufff2\036\ufff2\037\ufff2\040\ufff2\063\ufff2\064\ufff2\065" + + "\ufff2\066\ufff2\071\ufff2\001\002\000\006\014\240\017\237" + + "\001\002\000\046\022\uffde\024\uffde\025\uffde\026\uffde\027" + + "\uffde\031\uffde\032\uffde\033\uffde\034\uffde\035\uffde\036\uffde" + + "\037\uffde\040\uffde\063\uffde\064\uffde\065\uffde\066\uffde\071" + + "\uffde\001\002\000\004\015\231\001\002\000\046\022\uffe8" + + "\024\uffe8\025\uffe8\026\uffe8\027\uffe8\031\uffe8\032\uffe8\033" + + "\uffe8\034\uffe8\035\uffe8\036\uffe8\037\uffe8\040\uffe8\063\uffe8" + + "\064\uffe8\065\uffe8\066\uffe8\071\uffe8\001\002\000\032\022" + + "\ufff1\024\ufff1\025\ufff1\026\ufff1\027\ufff1\033\ufff1\037\ufff1" + + "\040\ufff1\063\ufff1\064\ufff1\065\ufff1\071\ufff1\001\002\000" + + "\046\022\uffea\024\uffea\025\uffea\026\uffea\027\uffea\031\uffea" + + "\032\uffea\033\uffea\034\uffea\035\uffea\036\uffea\037\uffea\040" + + "\uffea\063\uffea\064\uffea\065\uffea\066\uffea\071\uffea\001\002" + + "\000\040\013\051\015\146\041\047\042\057\043\061\044" + + "\046\045\060\046\053\047\064\062\150\071\056\072\054" + + "\073\063\074\052\075\062\001\002\000\046\022\uffee\024" + + "\uffee\025\uffee\026\uffee\027\uffee\031\uffee\032\uffee\033\uffee" + + "\034\uffee\035\uffee\036\uffee\037\uffee\040\uffee\063\uffee\064" + + "\uffee\065\uffee\066\uffee\071\uffee\001\002\000\046\022\uffed" + + "\024\uffed\025\uffed\026\uffed\027\uffed\031\uffed\032\uffed\033" + + "\uffed\034\uffed\035\uffed\036\uffed\037\uffed\040\uffed\063\uffed" + + "\064\uffed\065\uffed\066\uffed\071\uffed\001\002\000\036\013" + + "\051\015\050\041\047\042\057\043\061\044\046\045\060" + + "\046\053\047\064\071\056\072\054\073\063\074\052\075" + + "\062\001\002\000\040\013\051\015\146\041\047\042\057" + + "\043\061\044\046\045\060\046\053\047\064\062\150\071" + + "\056\072\054\073\063\074\052\075\062\001\002\000\046" + + "\022\uffe9\024\uffe9\025\uffe9\026\uffe9\027\uffe9\031\uffe9\032" + + "\uffe9\033\uffe9\034\uffe9\035\uffe9\036\uffe9\037\uffe9\040\uffe9" + + "\063\uffe9\064\uffe9\065\uffe9\066\uffe9\071\uffe9\001\002\000" + + "\004\015\134\001\002\000\046\022\uffeb\024\uffeb\025\uffeb" + + "\026\uffeb\027\uffeb\031\uffeb\032\uffeb\033\uffeb\034\uffeb\035" + + "\uffeb\036\uffeb\037\uffeb\040\uffeb\063\uffeb\064\uffeb\065\uffeb" + + "\066\uffeb\071\uffeb\001\002\000\004\015\045\001\002\000" + + "\036\013\051\015\050\041\047\042\057\043\061\044\046" + + "\045\060\046\053\047\064\071\056\072\054\073\063\074" + + "\052\075\062\001\002\000\004\015\131\001\002\000\004" + + "\015\124\001\002\000\036\013\051\015\050\041\047\042" + + "\057\043\061\044\046\045\060\046\053\047\064\071\056" + + "\072\054\073\063\074\052\075\062\001\002\000\076\011" + + "\uffad\012\uffad\016\uffad\022\uffad\023\uffad\024\uffad\025\uffad" + + "\026\uffad\027\uffad\030\uffad\031\uffad\032\uffad\033\uffad\034" + + "\uffad\035\uffad\036\uffad\037\uffad\040\uffad\053\uffad\054\uffad" + + "\056\uffad\057\uffad\060\uffad\061\uffad\063\uffad\064\uffad\065" + + "\uffad\066\uffad\070\uffad\071\uffad\001\002\000\076\011\uffb2" + + "\012\uffb2\016\uffb2\022\uffb2\023\uffb2\024\uffb2\025\uffb2\026" + + "\uffb2\027\uffb2\030\uffb2\031\uffb2\032\uffb2\033\uffb2\034\uffb2" + + "\035\uffb2\036\uffb2\037\uffb2\040\uffb2\053\uffb2\054\uffb2\056" + + "\uffb2\057\uffb2\060\uffb2\061\uffb2\063\uffb2\064\uffb2\065\uffb2" + + "\066\uffb2\070\uffb2\071\uffb2\001\002\000\004\015\117\001" + + "\002\000\076\011\uffaf\012\uffaf\016\uffaf\022\uffaf\023\uffaf" + + "\024\uffaf\025\uffaf\026\uffaf\027\uffaf\030\uffaf\031\uffaf\032" + + "\uffaf\033\uffaf\034\uffaf\035\uffaf\036\uffaf\037\uffaf\040\uffaf" + + "\053\uffaf\054\uffaf\056\uffaf\057\uffaf\060\uffaf\061\uffaf\063" + + "\uffaf\064\uffaf\065\uffaf\066\uffaf\070\uffaf\071\uffaf\001\002" + + "\000\010\011\071\012\067\016\116\001\002\000\100\011" + + "\uffb0\012\uffb0\016\uffb0\017\102\022\uffb0\023\uffb0\024\uffb0" + + "\025\uffb0\026\uffb0\027\uffb0\030\uffb0\031\uffb0\032\uffb0\033" + + "\uffb0\034\uffb0\035\uffb0\036\uffb0\037\uffb0\040\uffb0\053\uffb0" + + "\054\uffb0\056\uffb0\057\uffb0\060\uffb0\061\uffb0\063\uffb0\064" + + "\uffb0\065\uffb0\066\uffb0\070\uffb0\071\uffb0\001\002\000\004" + + "\015\077\001\002\000\004\015\074\001\002\000\004\015" + + "\065\001\002\000\076\011\uffae\012\uffae\016\uffae\022\uffae" + + "\023\uffae\024\uffae\025\uffae\026\uffae\027\uffae\030\uffae\031" + + "\uffae\032\uffae\033\uffae\034\uffae\035\uffae\036\uffae\037\uffae" + + "\040\uffae\053\uffae\054\uffae\056\uffae\057\uffae\060\uffae\061" + + "\uffae\063\uffae\064\uffae\065\uffae\066\uffae\070\uffae\071\uffae" + + "\001\002\000\076\011\uffb3\012\uffb3\016\uffb3\022\uffb3\023" + + "\uffb3\024\uffb3\025\uffb3\026\uffb3\027\uffb3\030\uffb3\031\uffb3" + + "\032\uffb3\033\uffb3\034\uffb3\035\uffb3\036\uffb3\037\uffb3\040" + + "\uffb3\053\uffb3\054\uffb3\056\uffb3\057\uffb3\060\uffb3\061\uffb3" + + "\063\uffb3\064\uffb3\065\uffb3\066\uffb3\070\uffb3\071\uffb3\001" + + "\002\000\076\011\uffb1\012\uffb1\016\uffb1\022\uffb1\023\uffb1" + + "\024\uffb1\025\uffb1\026\uffb1\027\uffb1\030\uffb1\031\uffb1\032" + + "\uffb1\033\uffb1\034\uffb1\035\uffb1\036\uffb1\037\uffb1\040\uffb1" + + "\053\uffb1\054\uffb1\056\uffb1\057\uffb1\060\uffb1\061\uffb1\063" + + "\uffb1\064\uffb1\065\uffb1\066\uffb1\070\uffb1\071\uffb1\001\002" + + "\000\036\013\051\015\050\041\047\042\057\043\061\044" + + "\046\045\060\046\053\047\064\071\056\072\054\073\063" + + "\074\052\075\062\001\002\000\010\011\071\012\067\016" + + "\070\001\002\000\036\013\051\015\050\041\047\042\057" + + "\043\061\044\046\045\060\046\053\047\064\071\056\072" + + "\054\073\063\074\052\075\062\001\002\000\076\011\uffb9" + + "\012\uffb9\016\uffb9\022\uffb9\023\uffb9\024\uffb9\025\uffb9\026" + + "\uffb9\027\uffb9\030\uffb9\031\uffb9\032\uffb9\033\uffb9\034\uffb9" + + "\035\uffb9\036\uffb9\037\uffb9\040\uffb9\053\uffb9\054\uffb9\056" + + "\uffb9\057\uffb9\060\uffb9\061\uffb9\063\uffb9\064\uffb9\065\uffb9" + + "\066\uffb9\070\uffb9\071\uffb9\001\002\000\036\013\051\015" + + "\050\041\047\042\057\043\061\044\046\045\060\046\053" + + "\047\064\071\056\072\054\073\063\074\052\075\062\001" + + "\002\000\076\011\uffbd\012\uffbd\016\uffbd\022\uffbd\023\uffbd" + + "\024\uffbd\025\uffbd\026\uffbd\027\uffbd\030\uffbd\031\uffbd\032" + + "\uffbd\033\uffbd\034\uffbd\035\uffbd\036\uffbd\037\uffbd\040\uffbd" + + "\053\uffbd\054\uffbd\056\uffbd\057\uffbd\060\uffbd\061\uffbd\063" + + "\uffbd\064\uffbd\065\uffbd\066\uffbd\070\uffbd\071\uffbd\001\002" + + "\000\076\011\uffbc\012\uffbc\016\uffbc\022\uffbc\023\uffbc\024" + + "\uffbc\025\uffbc\026\uffbc\027\uffbc\030\uffbc\031\uffbc\032\uffbc" + + "\033\uffbc\034\uffbc\035\uffbc\036\uffbc\037\uffbc\040\uffbc\053" + + "\uffbc\054\uffbc\056\uffbc\057\uffbc\060\uffbc\061\uffbc\063\uffbc" + + "\064\uffbc\065\uffbc\066\uffbc\070\uffbc\071\uffbc\001\002\000" + + "\036\013\051\015\050\041\047\042\057\043\061\044\046" + + "\045\060\046\053\047\064\071\056\072\054\073\063\074" + + "\052\075\062\001\002\000\010\011\071\012\067\016\076" + + "\001\002\000\076\011\uffb7\012\uffb7\016\uffb7\022\uffb7\023" + + "\uffb7\024\uffb7\025\uffb7\026\uffb7\027\uffb7\030\uffb7\031\uffb7" + + "\032\uffb7\033\uffb7\034\uffb7\035\uffb7\036\uffb7\037\uffb7\040" + + "\uffb7\053\uffb7\054\uffb7\056\uffb7\057\uffb7\060\uffb7\061\uffb7" + + "\063\uffb7\064\uffb7\065\uffb7\066\uffb7\070\uffb7\071\uffb7\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\010\011\071\012\067" + + "\016\101\001\002\000\076\011\uffba\012\uffba\016\uffba\022" + + "\uffba\023\uffba\024\uffba\025\uffba\026\uffba\027\uffba\030\uffba" + + "\031\uffba\032\uffba\033\uffba\034\uffba\035\uffba\036\uffba\037" + + "\uffba\040\uffba\053\uffba\054\uffba\056\uffba\057\uffba\060\uffba" + + "\061\uffba\063\uffba\064\uffba\065\uffba\066\uffba\070\uffba\071" + + "\uffba\001\002\000\010\015\105\071\103\073\106\001\002" + + "\000\012\011\uffa8\012\uffa8\016\uffa8\020\uffa8\001\002\000" + + "\010\011\112\012\110\020\115\001\002\000\010\015\105" + + "\071\103\073\106\001\002\000\012\011\uffa9\012\uffa9\016" + + "\uffa9\020\uffa9\001\002\000\010\011\112\012\110\016\111" + + "\001\002\000\010\015\105\071\103\073\106\001\002\000" + + "\012\011\uffaa\012\uffaa\016\uffaa\020\uffaa\001\002\000\010" + + "\015\105\071\103\073\106\001\002\000\012\011\uffac\012" + + "\uffac\016\uffac\020\uffac\001\002\000\012\011\uffab\012\uffab" + + "\016\uffab\020\uffab\001\002\000\076\011\uffb4\012\uffb4\016" + + "\uffb4\022\uffb4\023\uffb4\024\uffb4\025\uffb4\026\uffb4\027\uffb4" + + "\030\uffb4\031\uffb4\032\uffb4\033\uffb4\034\uffb4\035\uffb4\036" + + "\uffb4\037\uffb4\040\uffb4\053\uffb4\054\uffb4\056\uffb4\057\uffb4" + + "\060\uffb4\061\uffb4\063\uffb4\064\uffb4\065\uffb4\066\uffb4\070" + + "\uffb4\071\uffb4\001\002\000\046\022\uffe7\024\uffe7\025\uffe7" + + "\026\uffe7\027\uffe7\031\uffe7\032\uffe7\033\uffe7\034\uffe7\035" + + "\uffe7\036\uffe7\037\uffe7\040\uffe7\063\uffe7\064\uffe7\065\uffe7" + + "\066\uffe7\071\uffe7\001\002\000\036\013\051\015\050\041" + + "\047\042\057\043\061\044\046\045\060\046\053\047\064" + + "\071\056\072\054\073\063\074\052\075\062\001\002\000" + + "\010\011\071\012\067\016\121\001\002\000\076\011\uffb6" + + "\012\uffb6\016\uffb6\022\uffb6\023\uffb6\024\uffb6\025\uffb6\026" + + "\uffb6\027\uffb6\030\uffb6\031\uffb6\032\uffb6\033\uffb6\034\uffb6" + + "\035\uffb6\036\uffb6\037\uffb6\040\uffb6\053\uffb6\054\uffb6\056" + + "\uffb6\057\uffb6\060\uffb6\061\uffb6\063\uffb6\064\uffb6\065\uffb6" + + "\066\uffb6\070\uffb6\071\uffb6\001\002\000\010\011\071\012" + + "\067\016\123\001\002\000\076\011\uffb5\012\uffb5\016\uffb5" + + "\022\uffb5\023\uffb5\024\uffb5\025\uffb5\026\uffb5\027\uffb5\030" + + "\uffb5\031\uffb5\032\uffb5\033\uffb5\034\uffb5\035\uffb5\036\uffb5" + + "\037\uffb5\040\uffb5\053\uffb5\054\uffb5\056\uffb5\057\uffb5\060" + + "\uffb5\061\uffb5\063\uffb5\064\uffb5\065\uffb5\066\uffb5\070\uffb5" + + "\071\uffb5\001\002\000\036\013\051\015\050\041\047\042" + + "\057\043\061\044\046\045\060\046\053\047\064\071\056" + + "\072\054\073\063\074\052\075\062\001\002\000\010\011" + + "\071\012\067\070\126\001\002\000\036\013\051\015\050" + + "\041\047\042\057\043\061\044\046\045\060\046\053\047" + + "\064\071\056\072\054\073\063\074\052\075\062\001\002" + + "\000\010\011\071\012\067\016\130\001\002\000\076\011" + + "\uffbb\012\uffbb\016\uffbb\022\uffbb\023\uffbb\024\uffbb\025\uffbb" + + "\026\uffbb\027\uffbb\030\uffbb\031\uffbb\032\uffbb\033\uffbb\034" + + "\uffbb\035\uffbb\036\uffbb\037\uffbb\040\uffbb\053\uffbb\054\uffbb" + + "\056\uffbb\057\uffbb\060\uffbb\061\uffbb\063\uffbb\064\uffbb\065" + + "\uffbb\066\uffbb\070\uffbb\071\uffbb\001\002\000\036\013\051" + + "\015\050\041\047\042\057\043\061\044\046\045\060\046" + + "\053\047\064\071\056\072\054\073\063\074\052\075\062" + + "\001\002\000\010\011\071\012\067\016\133\001\002\000" + + "\076\011\uffb8\012\uffb8\016\uffb8\022\uffb8\023\uffb8\024\uffb8" + + "\025\uffb8\026\uffb8\027\uffb8\030\uffb8\031\uffb8\032\uffb8\033" + + "\uffb8\034\uffb8\035\uffb8\036\uffb8\037\uffb8\040\uffb8\053\uffb8" + + "\054\uffb8\056\uffb8\057\uffb8\060\uffb8\061\uffb8\063\uffb8\064" + + "\uffb8\065\uffb8\066\uffb8\070\uffb8\071\uffb8\001\002\000\004" + + "\071\135\001\002\000\010\016\uffbf\017\142\070\uffbf\001" + + "\002\000\006\016\140\070\137\001\002\000\004\071\135" + + "\001\002\000\046\022\uffd5\024\uffd5\025\uffd5\026\uffd5\027" + + "\uffd5\031\uffd5\032\uffd5\033\uffd5\034\uffd5\035\uffd5\036\uffd5" + + "\037\uffd5\040\uffd5\063\uffd5\064\uffd5\065\uffd5\066\uffd5\071" + + "\uffd5\001\002\000\006\016\uffc0\070\uffc0\001\002\000\010" + + "\015\105\071\103\073\106\001\002\000\010\011\112\012" + + "\110\020\144\001\002\000\006\016\uffbe\070\uffbe\001\002" + + "\000\010\030\201\056\173\061\172\001\002\000\040\013" + + "\051\015\146\041\047\042\057\043\061\044\046\045\060" + + "\046\053\047\064\062\150\071\056\072\054\073\063\074" + + "\052\075\062\001\002\000\024\011\071\012\067\016\uffc3" + + "\023\uffc3\030\uffc3\053\uffc3\054\uffc3\056\uffc3\061\uffc3\001" + + "\002\000\004\015\166\001\002\000\020\016\uffc8\023\uffc8" + + "\030\uffc8\053\152\054\153\056\uffc8\061\uffc8\001\002\000" + + "\040\013\051\015\154\041\047\042\057\043\061\044\046" + + "\045\060\046\053\047\064\062\156\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\040\013\051\015\154" + + "\041\047\042\057\043\061\044\046\045\060\046\053\047" + + "\064\062\156\071\056\072\054\073\063\074\052\075\062" + + "\001\002\000\040\013\051\015\154\041\047\042\057\043" + + "\061\044\046\045\060\046\053\047\064\062\156\071\056" + + "\072\054\073\063\074\052\075\062\001\002\000\020\016" + + "\uffc6\023\uffc6\030\uffc6\053\uffc6\054\uffc6\056\uffc6\061\uffc6" + + "\001\002\000\004\015\157\001\002\000\040\013\051\015" + + "\154\041\047\042\057\043\061\044\046\045\060\046\053" + + "\047\064\062\156\071\056\072\054\073\063\074\052\075" + + "\062\001\002\000\010\016\161\053\152\054\153\001\002" + + "\000\020\016\uffc4\023\uffc4\030\uffc4\053\uffc4\054\uffc4\056" + + "\uffc4\061\uffc4\001\002\000\010\016\164\053\152\054\153" + + "\001\002\000\020\011\071\012\067\016\123\053\uffc3\054" + + "\uffc3\056\uffc3\061\uffc3\001\002\000\020\016\uffc5\023\uffc5" + + "\030\uffc5\053\uffc5\054\uffc5\056\uffc5\061\uffc5\001\002\000" + + "\020\016\uffc7\023\uffc7\030\uffc7\053\uffc7\054\uffc7\056\uffc7" + + "\061\uffc7\001\002\000\040\013\051\015\146\041\047\042" + + "\057\043\061\044\046\045\060\046\053\047\064\062\150" + + "\071\056\072\054\073\063\074\052\075\062\001\002\000" + + "\010\016\171\056\173\061\172\001\002\000\014\016\161" + + "\053\152\054\153\056\uffc8\061\uffc8\001\002\000\014\016" + + "\uffc9\023\uffc9\030\uffc9\056\uffc9\061\uffc9\001\002\000\040" + + "\013\051\015\146\041\047\042\057\043\061\044\046\045" + + "\060\046\053\047\064\062\150\071\056\072\054\073\063" + + "\074\052\075\062\001\002\000\040\013\051\015\146\041" + + "\047\042\057\043\061\044\046\045\060\046\053\047\064" + + "\062\150\071\056\072\054\073\063\074\052\075\062\001" + + "\002\000\014\016\uffcc\023\uffcc\030\uffcc\056\uffcc\061\uffcc" + + "\001\002\000\014\016\uffcb\023\uffcb\030\uffcb\056\uffcb\061" + + "\uffcb\001\002\000\010\016\200\056\173\061\172\001\002" + + "\000\014\016\164\053\152\054\153\056\uffc8\061\uffc8\001" + + "\002\000\014\016\uffca\023\uffca\030\uffca\056\uffca\061\uffca" + + "\001\002\000\030\022\uffe0\026\uffe0\027\uffe0\031\uffe0\033" + + "\uffe0\037\uffe0\040\uffe0\063\uffe0\064\uffe0\065\uffe0\071\uffe0" + + "\001\002\000\030\022\ufff1\026\ufff1\027\ufff1\031\ufff1\033" + + "\ufff1\037\ufff1\040\ufff1\063\ufff1\064\ufff1\065\ufff1\071\ufff1" + + "\001\002\000\030\022\034\026\040\027\024\031\204\033" + + "\037\037\031\040\044\063\021\064\030\065\042\071\026" + + "\001\002\000\046\022\uffdf\024\uffdf\025\uffdf\026\uffdf\027" + + "\uffdf\031\uffdf\032\uffdf\033\uffdf\034\uffdf\035\uffdf\036\uffdf" + + "\037\uffdf\040\uffdf\063\uffdf\064\uffdf\065\uffdf\066\uffdf\071" + + "\uffdf\001\002\000\014\011\071\012\067\034\uffd4\035\uffd4" + + "\036\uffd4\001\002\000\010\034\uffd1\035\uffd1\036\uffd1\001" + + "\002\000\010\034\213\035\210\036\uffcd\001\002\000\030" + + "\022\ufff1\026\ufff1\027\ufff1\033\ufff1\036\ufff1\037\ufff1\040" + + "\ufff1\063\ufff1\064\ufff1\065\ufff1\071\ufff1\001\002\000\004" + + "\036\217\001\002\000\010\034\uffd2\035\uffd2\036\uffd2\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\040\011\071\012\067" + + "\022\uffd0\026\uffd0\027\uffd0\033\uffd0\034\uffd0\035\uffd0\036" + + "\uffd0\037\uffd0\040\uffd0\063\uffd0\064\uffd0\065\uffd0\071\uffd0" + + "\001\002\000\034\022\ufff1\026\ufff1\027\ufff1\033\ufff1\034" + + "\ufff1\035\ufff1\036\ufff1\037\ufff1\040\ufff1\063\ufff1\064\ufff1" + + "\065\ufff1\071\ufff1\001\002\000\034\022\034\026\040\027" + + "\024\033\037\034\uffcf\035\uffcf\036\uffcf\037\031\040\044" + + "\063\021\064\030\065\042\071\026\001\002\000\046\022" + + "\uffd3\024\uffd3\025\uffd3\026\uffd3\027\uffd3\031\uffd3\032\uffd3" + + "\033\uffd3\034\uffd3\035\uffd3\036\uffd3\037\uffd3\040\uffd3\063" + + "\uffd3\064\uffd3\065\uffd3\066\uffd3\071\uffd3\001\002\000\030" + + "\022\034\026\040\027\024\033\037\036\uffce\037\031\040" + + "\044\063\021\064\030\065\042\071\026\001\002\000\010" + + "\023\222\056\173\061\172\001\002\000\032\022\uffe2\024" + + "\uffe2\025\uffe2\026\uffe2\027\uffe2\033\uffe2\037\uffe2\040\uffe2" + + "\063\uffe2\064\uffe2\065\uffe2\071\uffe2\001\002\000\032\022" + + "\034\024\224\025\225\026\040\027\024\033\037\037\031" + + "\040\044\063\021\064\030\065\042\071\026\001\002\000" + + "\030\022\uffe1\025\uffe1\026\uffe1\027\uffe1\033\uffe1\037\uffe1" + + "\040\uffe1\063\uffe1\064\uffe1\065\uffe1\071\uffe1\001\002\000" + + "\046\022\uffe4\024\uffe4\025\uffe4\026\uffe4\027\uffe4\031\uffe4" + + "\032\uffe4\033\uffe4\034\uffe4\035\uffe4\036\uffe4\037\uffe4\040" + + "\uffe4\063\uffe4\064\uffe4\065\uffe4\066\uffe4\071\uffe4\001\002" + + "\000\030\022\ufff1\025\ufff1\026\ufff1\027\ufff1\033\ufff1\037" + + "\ufff1\040\ufff1\063\ufff1\064\ufff1\065\ufff1\071\ufff1\001\002" + + "\000\030\022\034\025\230\026\040\027\024\033\037\037" + + "\031\040\044\063\021\064\030\065\042\071\026\001\002" + + "\000\046\022\uffe3\024\uffe3\025\uffe3\026\uffe3\027\uffe3\031" + + "\uffe3\032\uffe3\033\uffe3\034\uffe3\035\uffe3\036\uffe3\037\uffe3" + + "\040\uffe3\063\uffe3\064\uffe3\065\uffe3\066\uffe3\071\uffe3\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\012\011\071\012\067" + + "\016\uffc1\070\uffc1\001\002\000\006\016\235\070\234\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\046\022\uffd6\024\uffd6" + + "\025\uffd6\026\uffd6\027\uffd6\031\uffd6\032\uffd6\033\uffd6\034" + + "\uffd6\035\uffd6\036\uffd6\037\uffd6\040\uffd6\063\uffd6\064\uffd6" + + "\065\uffd6\066\uffd6\071\uffd6\001\002\000\006\016\uffc2\070" + + "\uffc2\001\002\000\010\015\105\071\103\073\106\001\002" + + "\000\036\013\051\015\050\041\047\042\057\043\061\044" + + "\046\045\060\046\053\047\064\071\056\072\054\073\063" + + "\074\052\075\062\001\002\000\052\011\071\012\067\022" + + "\uffe6\024\uffe6\025\uffe6\026\uffe6\027\uffe6\031\uffe6\032\uffe6" + + "\033\uffe6\034\uffe6\035\uffe6\036\uffe6\037\uffe6\040\uffe6\063" + + "\uffe6\064\uffe6\065\uffe6\066\uffe6\071\uffe6\001\002\000\010" + + "\011\112\012\110\020\243\001\002\000\004\014\244\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\052\011\071\012\067" + + "\022\uffe5\024\uffe5\025\uffe5\026\uffe5\027\uffe5\031\uffe5\032" + + "\uffe5\033\uffe5\034\uffe5\035\uffe5\036\uffe5\037\uffe5\040\uffe5" + + "\063\uffe5\064\uffe5\065\uffe5\066\uffe5\071\uffe5\001\002\000" + + "\004\055\247\001\002\000\036\013\051\015\050\041\047" + + "\042\057\043\061\044\046\045\060\046\053\047\064\071" + + "\056\072\054\073\063\074\052\075\062\001\002\000\010" + + "\011\071\012\067\057\uffdd\001\002\000\004\057\252\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\012\011\071\012\067" + + "\030\uffdc\060\uffdc\001\002\000\006\030\uffd8\060\255\001" + + "\002\000\036\013\051\015\050\041\047\042\057\043\061" + + "\044\046\045\060\046\053\047\064\071\056\072\054\073" + + "\063\074\052\075\062\001\002\000\004\030\257\001\002" + + "\000\030\022\uffdb\026\uffdb\027\uffdb\032\uffdb\033\uffdb\037" + + "\uffdb\040\uffdb\063\uffdb\064\uffdb\065\uffdb\071\uffdb\001\002" + + "\000\030\022\ufff1\026\ufff1\027\ufff1\032\ufff1\033\ufff1\037" + + "\ufff1\040\ufff1\063\ufff1\064\ufff1\065\ufff1\071\ufff1\001\002" + + "\000\030\022\034\026\040\027\024\032\262\033\037\037" + + "\031\040\044\063\021\064\030\065\042\071\026\001\002" + + "\000\046\022\uffda\024\uffda\025\uffda\026\uffda\027\uffda\031" + + "\uffda\032\uffda\033\uffda\034\uffda\035\uffda\036\uffda\037\uffda" + + "\040\uffda\063\uffda\064\uffda\065\uffda\066\uffda\071\uffda\001" + + "\002\000\010\011\071\012\067\030\uffd9\001\002\000\036" + + "\013\051\015\050\041\047\042\057\043\061\044\046\045" + + "\060\046\053\047\064\071\056\072\054\073\063\074\052" + + "\075\062\001\002\000\006\016\266\070\234\001\002\000" + + "\046\022\uffd7\024\uffd7\025\uffd7\026\uffd7\027\uffd7\031\uffd7" + + "\032\uffd7\033\uffd7\034\uffd7\035\uffd7\036\uffd7\037\uffd7\040" + + "\uffd7\063\uffd7\064\uffd7\065\uffd7\066\uffd7\071\uffd7\001\002" + + "\000\006\067\ufff3\070\ufff3\001\002\000\006\010\ufffa\071" + + "\267\001\002\000\006\010\ufff7\071\ufff7\001\002\000\006" + + "\067\274\070\273\001\002\000\004\071\267\001\002\000" + + "\006\006\275\007\276\001\002\000\006\010\ufff6\071\ufff6" + + "\001\002\000\004\017\277\001\002\000\004\073\300\001" + + "\002\000\004\021\301\001\002\000\004\073\302\001\002" + + "\000\004\020\303\001\002\000\004\055\304\001\002\000" + + "\004\006\305\001\002\000\006\010\ufff5\071\ufff5\001\002" + + "\000\006\067\ufff4\070\ufff4\001\002\000\006\010\ufff8\071" + + "\ufff8\001\002" }); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /**reduce_goto
table. */ + protected static final short[][] _reduce_table = + unpackFromStrings(new String[] { + "\000\305\000\010\002\006\003\003\004\004\001\001\000" + + "\004\005\013\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\010\006\267\007\270\010\271\001\001" + + "\000\002\001\001\000\004\011\015\001\001\000\030\012" + + "\024\013\016\014\034\015\031\017\035\020\021\021\042" + + "\022\032\023\026\024\040\030\022\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\004\011\222\001\001\000\002\001\001\000" + + "\010\034\146\036\220\037\150\001\001\000\002\001\001" + + "\000\002\001\001\000\004\034\204\001\001\000\010\034" + + "\146\036\144\037\150\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\004\034" + + "\054\001\001\000\002\001\001\000\002\001\001\000\004" + + "\034\121\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\004\034\065\001\001\000\002\001\001\000\004\034" + + "\072\001\001\000\002\001\001\000\004\034\071\001\001" + + "\000\002\001\001\000\002\001\001\000\004\034\074\001" + + "\001\000\002\001\001\000\002\001\001\000\004\034\077" + + "\001\001\000\002\001\001\000\002\001\001\000\004\035" + + "\103\001\001\000\002\001\001\000\002\001\001\000\004" + + "\035\106\001\001\000\002\001\001\000\002\001\001\000" + + "\004\035\113\001\001\000\002\001\001\000\004\035\112" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\004\034\117\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\004\034\124\001\001\000\002\001\001\000\004" + + "\034\126\001\001\000\002\001\001\000\002\001\001\000" + + "\004\034\131\001\001\000\002\001\001\000\002\001\001" + + "\000\004\041\135\001\001\000\002\001\001\000\002\001" + + "\001\000\004\041\140\001\001\000\002\001\001\000\002" + + "\001\001\000\004\035\142\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\010\034\162\036\175" + + "\037\176\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\006\034\146\037\164\001\001\000\006" + + "\034\146\037\154\001\001\000\006\034\162\037\161\001" + + "\001\000\002\001\001\000\002\001\001\000\006\034\146" + + "\037\157\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\010\034\146\036\166\037\167\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\010" + + "\034\146\036\174\037\150\001\001\000\010\034\146\036" + + "\173\037\150\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\004\043\201\001\001\000\004\011\202\001\001\000\030" + + "\012\024\013\016\014\034\015\031\017\035\020\021\021" + + "\042\022\032\023\026\024\040\030\022\001\001\000\002" + + "\001\001\000\004\047\205\001\001\000\004\025\206\001" + + "\001\000\006\026\211\027\210\001\001\000\004\011\217" + + "\001\001\000\002\001\001\000\002\001\001\000\004\034" + + "\213\001\001\000\004\050\214\001\001\000\004\011\215" + + "\001\001\000\030\012\024\013\016\014\034\015\031\017" + + "\035\020\021\021\042\022\032\023\026\024\040\030\022" + + "\001\001\000\002\001\001\000\030\012\024\013\016\014" + + "\034\015\031\017\035\020\021\021\042\022\032\023\026" + + "\024\040\030\022\001\001\000\002\001\001\000\002\001" + + "\001\000\032\012\024\013\016\014\034\015\031\016\225" + + "\017\035\020\021\021\042\022\032\023\026\024\040\030" + + "\022\001\001\000\002\001\001\000\002\001\001\000\004" + + "\011\226\001\001\000\030\012\024\013\016\014\034\015" + + "\031\017\035\020\021\021\042\022\032\023\026\024\040" + + "\030\022\001\001\000\002\001\001\000\006\034\231\040" + + "\232\001\001\000\002\001\001\000\002\001\001\000\006" + + "\034\231\040\235\001\001\000\002\001\001\000\002\001" + + "\001\000\004\035\241\001\001\000\004\034\240\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\004\034\244\001\001\000\002\001\001\000\002\001\001" + + "\000\004\034\247\001\001\000\004\044\250\001\001\000" + + "\002\001\001\000\004\034\252\001\001\000\004\045\253" + + "\001\001\000\004\042\255\001\001\000\004\034\262\001" + + "\001\000\002\001\001\000\004\046\257\001\001\000\004" + + "\011\260\001\001\000\030\012\024\013\016\014\034\015" + + "\031\017\035\020\021\021\042\022\032\023\026\024\040" + + "\030\022\001\001\000\002\001\001\000\002\001\001\000" + + "\006\034\231\040\264\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\006\007\306\010\271\001" + + "\001\000\002\001\001\000\002\001\001\000\004\010\305" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001" }); + + /** Access toreduce_goto
table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$parser$actions action_obj; + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$parser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 0;} + + /**EOF
Symbol index. */ + public int EOF_sym() {return 0;} + + /**error
Symbol index. */ + public int error_sym() {return 1;} + + + /** User initialization code. */ + public void user_init() throws java.lang.Exception + { + + util = new Compilador(); + + } + + + public void syntax_error(Symbol s){ + if(s.value != null){ + report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1)+". Trecho desconhecido: "+s.value,null); + JOptionPane.showMessageDialog(null,"Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1)+". Trecho desconhecido: "+s.value,"Erro de syntax",JOptionPane.WARNING_MESSAGE); + }else{ + report_error("Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1),null); + JOptionPane.showMessageDialog(null,"Erro de syntax: Linha "+(s.left+1)+" Coluna "+(s.right+1),"Erro de syntax",JOptionPane.WARNING_MESSAGE); + } + util.setErro(); + this.done_parsing(); + } + public void syntax_error(int left,int right,String mensagem){ + report_error(mensagem + " " + "Linha "+(left+1)+" Coluna "+(right),null); + JOptionPane.showMessageDialog(null,mensagem + " " + "Linha "+(left+1)+" Coluna "+(right+1),"Erro de syntax",JOptionPane.WARNING_MESSAGE); + + util.setErro(); + this.done_parsing(); + } + public void report_fatal_error(String message, Object info){ + this.done_parsing(); + } + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +class CUP$parser$actions { + + + private final parser parser; + + /** Constructor */ + CUP$parser$actions(parser parser) { + this.parser = parser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + java.util.Stack CUP$parser$stack, + int CUP$parser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 89: // _operacoes_indice_vetor ::= ID + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String[] tmp = util.getVariavel(n); + if(tmp[1] != null) { + if("int".equals(tmp[1])){ + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO4",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes_indice_vetor",27, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 88: // _operacoes_indice_vetor ::= NUMERO_INT + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = n; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes_indice_vetor",27, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 87: // _operacoes_indice_vetor ::= ABRIR_PARENTESE _operacoes_indice_vetor FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = e; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes_indice_vetor",27, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 86: // _operacoes_indice_vetor ::= _operacoes_indice_vetor OPERADOR_SOMA _operacoes_indice_vetor + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = e1+" + "+e2; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes_indice_vetor",27, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 85: // _operacoes_indice_vetor ::= _operacoes_indice_vetor OPERADOR _operacoes_indice_vetor + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int opleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int opright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String op = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = e1+" "+util.getOperador(op)+" "+e2; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes_indice_vetor",27, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 84: // _operacoes ::= VALOR_LOGICO + { + String RESULT =null; + int lleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int lright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String l = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setBooleanTMP(true); + RESULT = util.getValorLogico(l); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 83: // _operacoes ::= CHAR + { + String RESULT =null; + int sleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int sright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String s = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCharTMP(true); + RESULT = s; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 82: // _operacoes ::= STRING + { + String RESULT =null; + int sleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int sright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String s = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setStringTMP(true); + RESULT = s; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 81: // _operacoes ::= ID + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + if(util.checkVariavelExiste(n)) { + String[] tmp = util.getVariavel(n); + util.setTipoIdTMP(tmp[1]); + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 80: // _operacoes ::= PI + { + String RESULT =null; + + RESULT = ""+Math.PI; + util.setNumerofloatTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 79: // _operacoes ::= NUMERO_FLOAT + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = n; + util.setNumerofloatTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 78: // _operacoes ::= NUMERO_INT + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = n; + util.setNumeroIntTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 77: // _operacoes ::= ID ABRIR_COLCHETE _operacoes_indice_vetor FECHAR_COLCHETE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + String[] tmp = util.getVariavelVetor(n); + if(tmp[0] != null){ + util.setTipoIdTMP(tmp[1]); + RESULT = n+"["+i+" - ("+tmp[2]+")]"; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO1",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 76: // _operacoes ::= ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = "("+e+")"; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 75: // _operacoes ::= RAIZ ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.sqrt("+n+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 74: // _operacoes ::= TANGENTE ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.tan("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 73: // _operacoes ::= COSSENO ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.cos("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 72: // _operacoes ::= SENO ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.sin("+n+"*"+(Math.PI)/180+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 71: // _operacoes ::= MODULO ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.abs("+n+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 70: // _operacoes ::= POTENCIA ABRIR_PARENTESE _operacoes SEPARADOR _operacoes FECHAR_PARENTESE + { + String RESULT =null; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int n2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int n2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + RESULT = "Math.pow("+n1+","+n2+")"; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 69: // _operacoes ::= _operacoes OPERADOR_SOMA _operacoes + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = e1+" + "+e2; + util.setOperadorSomaTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 68: // _operacoes ::= _operacoes OPERADOR _operacoes + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int opleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int opright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String op = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = e1+" "+util.getOperador(op)+" "+e2; + util.setOperadorTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_operacoes",26, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 67: // _loop_virgula_id ::= ID ABRIR_COLCHETE _operacoes_indice_vetor FECHAR_COLCHETE + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + String[] tmp = util.getVariavelVetor(n); + if(tmp[0] != null){ + RESULT = n+"["+i+"]"; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_VETOR_ERRO1",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_loop_virgula_id",31, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 66: // _loop_virgula_id ::= ID + { + String RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + if(util.checkVariavelExiste(n)) { + RESULT = n; + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_loop_virgula_id",31, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 65: // _loop_virgula_id ::= _loop_virgula_id SEPARADOR _loop_virgula_id + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = e1 + "," + e2; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_loop_virgula_id",31, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 64: // _loop_virgula ::= _operacoes + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = "("+e+")"; + String tmp = util.getTipoOperacao(); + if(tmp == null){ + parser.syntax_error(eleft,eright,util.Erros("OPERACAO_ERRO1",null)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_loop_virgula",30, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 63: // _loop_virgula ::= _loop_virgula SEPARADOR _loop_virgula + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = e1 + " + " + e2; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_loop_virgula",30, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 62: // _sub_condicional ::= _operacoes + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = e; + util.setTiposOperacaoeTMP(util.getTipoOperacao()); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_sub_condicional",29, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 61: // _sub_condicional ::= NAO ABRIR_PARENTESE _sub_condicional FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = "!("+e+")"; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_sub_condicional",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 60: // _sub_condicional ::= ABRIR_PARENTESE _sub_condicional FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = "("+e+")"; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_sub_condicional",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 59: // _sub_condicional ::= _sub_condicional CONDICIONAL_COMPARATIVA _sub_condicional + { + String RESULT =null; + int s1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int s1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String s1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + + util.setCondicionalComparativaTMP(true); + + RESULT = s1+" "+util.getTipoCondiconal(c)+" "+s2; + + String tmp = util.setSubCondicional(RESULT); + + if("String".equals(tmp)){ + if("<>".equals(c)){ + RESULT = "!"+s1+".equals("+s2+")"; + }else{ + RESULT = s1+".equals("+s2+")"; + } + } + else if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_sub_condicional",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 58: // _sub_condicional ::= _sub_condicional CONDICIONAL_NUMERICA _sub_condicional + { + String RESULT =null; + int s1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int s1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String s1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = s1+" "+c+" "+s2; + util.setCondicinalNumericaTMP(true); + + String tmp = util.setSubCondicional(RESULT); + if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(s1left,s1right,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_sub_condicional",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 57: // _condicional ::= _sub_condicional + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = e; + String tmp = util.setCondicional(RESULT); + if(tmp != null){ + switch(tmp){ + case "error1" : parser.syntax_error(eleft,eright,util.Erros("CONDICIONAL_ERRO1",null)); break; + default: parser.syntax_error(eleft,eright,util.Erros("CONDICIONAL_ERRO2",tmp)); break; + } + } + + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_condicional",28, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 56: // _condicional ::= NAO ABRIR_PARENTESE _condicional FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = "!("+e+")"; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_condicional",28, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 55: // _condicional ::= ABRIR_PARENTESE _condicional FECHAR_PARENTESE + { + String RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = "("+e+")"; + CUP$parser$result = parser.getSymbolFactory().newSymbol("_condicional",28, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 54: // _condicional ::= _condicional OU _condicional + { + String RESULT =null; + int c1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int c1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String c1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int c2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int c2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String c2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = c1+" || "+c2; + util.setCondicionalOuTMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_condicional",28, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 53: // _condicional ::= _condicional E _condicional + { + String RESULT =null; + int c1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int c1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String c1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int c2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int c2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String c2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + RESULT = c1+" && "+c2; + util.setCondicinalETMP(true); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_condicional",28, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 52: // escolha_outrocaso ::= + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_outrocaso",21, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 51: // escolha_outrocaso ::= OUTROCASO programa + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_outrocaso",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 50: // escolha_casos ::= CASO _operacoes NT$5 programa + { + Object RESULT =null; + // propagate RESULT from NT$5 + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int bleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int bright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String b = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_casos",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 49: // NT$5 ::= + { + Object RESULT =null; + int bleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int bright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String b = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + util.setCode("\t\tcase("+b+"):"); + util.setCodeExec("\t\tcase("+b+"):",bleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$5",38, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 48: // escolha_loop ::= + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_loop",19, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 47: // escolha_loop ::= escolha_loop escolha_casos + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_loop",19, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 46: // escolha_funcao ::= ESCOLHA _operacoes NT$4 escolha_loop escolha_outrocaso FIMESCOLHA + { + Object RESULT =null; + // propagate RESULT from NT$4 + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int aleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int aright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String a = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int fleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int fright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object f = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",fleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escolha_funcao",18, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 45: // NT$4 ::= + { + Object RESULT =null; + int aleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int aright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String a = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + util.setCode("\t\tswitch("+a+"){"); + util.setCodeExec("\t\tswitch("+a+"){",aleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$4",37, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 44: // leia_funcao ::= LEIA ABRIR_PARENTESE _loop_virgula_id FECHAR_PARENTESE + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + util.setLeia(true); + + for (String ids : e.split(",")) { + String[] tmp; + + if(e.indexOf("[") > 0){ + tmp = util.getVariavelVetor(ids.replaceAll("\\[.*\\]","")); + String indice = ids.substring(ids.indexOf("[")+1,ids.indexOf("]")); + ids = ids.substring(0,ids.indexOf("]"))+"-("+tmp[2]+")]"; + switch(tmp[1]){ + case "int" : util.setCode("\t\t"+ids+" = ConsoleIO.nextInt();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeInt();",eleft);break; + case "float" : util.setCode("\t\t"+ids+" = scanIn.nextFloat();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeFloat();",eleft);break; + case "String" : util.setCode("\t\t"+ids+" = scanIn.next();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeString();",eleft);break; + case "char" : util.setCode("\t\t"+ids+" = scanIn.nextChar();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeChar();",eleft);break; + } + util.setCodeExec("\t\ttable_variaveis.update(\""+tmp[0]+"[\"+"+indice+"+\"]\","+ids+");"); + }else{ + tmp = util.getVariavel(ids); + switch(tmp[1]){ + case "int" : util.setCode("\t\t"+ids+" = ConsoleIO.nextInt();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeInt();",eleft);break; + case "float" : util.setCode("\t\t"+ids+" = scanIn.nextFloat();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeFloat();",eleft);break; + case "String" : util.setCode("\t\t"+ids+" = scanIn.next();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeString();",eleft);break; + case "char" : util.setCode("\t\t"+ids+" = scanIn.nextChar();");util.setCodeExec("\t\t"+ids+" = ConsoleIO.writeChar();",eleft);break; + } + util.setCodeExec("\t\ttable_variaveis.update(\""+ids+"\","+ids+");"); + } + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("leia_funcao",14, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 43: // escreva_funcao ::= ESCREVAL ABRIR_PARENTESE _loop_virgula FECHAR_PARENTESE + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + util.setCode("\t\tSystem.out.println("+e+");"); + util.setCodeExec("\t\tConsoleIO.println("+e+");",eleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escreva_funcao",13, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 42: // escreva_funcao ::= ESCREVA ABRIR_PARENTESE _loop_virgula FECHAR_PARENTESE + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + util.setCode("\t\tSystem.out.print("+e+");"); + util.setCodeExec("\t\tConsoleIO.print("+e+");",eleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("escreva_funcao",13, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 41: // _para_complementar ::= + { + String RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_para_complementar",32, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 40: // _para_complementar ::= PASSO _operacoes + { + String RESULT =null; + int n3left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int n3right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n3left,n3right,util.Erros("TIPO_VARIAVEL_FOR",null)); + }else{ + RESULT = n3; + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("_para_complementar",32, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 39: // para_funcao_1 ::= PARA ID DE _operacoes NT$1 ATE _operacoes NT$2 _para_complementar FACA NT$3 programa FIMPARA + { + Object RESULT =null; + // propagate RESULT from NT$3 + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-11)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-11)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-11)).value; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-9)).value; + int n2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-6)).left; + int n2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-6)).right; + String n2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-6)).value; + int n3left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int n3right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String n3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int pright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int fleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int fright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object f = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + util.setCode("\t\t}");util.setCodeExec("\t\t}",fleft); + CUP$parser$result = parser.getSymbolFactory().newSymbol("para_funcao_1",17, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 38: // NT$3 ::= + { + Object RESULT =(Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-6)).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-6)).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-6)).value; + int n2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int n2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int n3left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int n3right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int pright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp[] = util.getVariavel(n); + + if(tmp[1] != null) { + if("int".equals(tmp[1])){ + if(n3 != null){ + util.setCode("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"+="+n3+"){"); + util.setCodeExec("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"+="+n3+"){",pleft); + }else{ + util.setCode("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"++){"); + util.setCodeExec("\t\tfor("+n+" = "+n1+";"+n+" <= "+n2+";"+n+"++){",pleft); + } + util.setCodeExec("\t\ttable_variaveis.update(\""+n+"\","+n+");"); + }else{ + parser.syntax_error(nleft,nright,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + }else{ + parser.syntax_error(nleft,nright,util.Erros("VARIAVEL_ERRO1",n)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$3",36, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 37: // NT$2 ::= + { + Object RESULT =(Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int n2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int n2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n2left,n2right,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$2",35, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 36: // NT$1 ::= + { + Object RESULT =null; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(n1left,n1right,util.Erros("TIPO_VARIAVEL_FOR",null)); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$1",34, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 35: // para_funcao ::= para_funcao_1 + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("para_funcao",16, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 34: // enquanto_funcao ::= ENQUANTO _condicional FACA NT$0 programa FIMENQUANTO + { + Object RESULT =null; + // propagate RESULT from NT$0 + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int pright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + util.setCode("\t\t}");util.setCodeExec("\t\t}",pleft); + CUP$parser$result = parser.getSymbolFactory().newSymbol("enquanto_funcao",15, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 33: // NT$0 ::= + { + Object RESULT =null; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + util.setCode("\t\twhile("+c+"){"); + util.setCodeExec("\t\twhile("+c+"){",cleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$0",33, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 32: // condicional_2 ::= SENAO + { + Object RESULT =null; + int pleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int pright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("\t\t}else{"); + util.setCodeExec("\t\t}else{",pleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("condicional_2",12, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 31: // condicional_1 ::= SE _condicional ENTAO + { + Object RESULT =null; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + util.setCode("\t\tif("+c+"){"); + util.setCodeExec("\t\tif("+c+"){",cleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("condicional_1",11, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 30: // condiciona_estrutura ::= condicional_1 programa condicional_2 programa FIMSE + { + Object RESULT =null; + int p3left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int p3right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object p3 = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",p3left); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("condiciona_estrutura",10, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 29: // condiciona_estrutura ::= condicional_1 programa FIMSE + { + Object RESULT =null; + int pleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int pright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("\t\t}"); + util.setCodeExec("\t\t}",pleft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("condiciona_estrutura",10, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 28: // instanciacao_variaveis ::= ID ABRIR_COLCHETE _operacoes_indice_vetor FECHAR_COLCHETE ATRIBUIR _operacoes + { + Object RESULT =null; + int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left; + int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).right; + String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp = util.setVariavelVetor(x,e,n); + switch(tmp){ + case "error1" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO1",x)); break; + case "error2" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO2",x)); break; + case "error3" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_VETOR_ERRO3",x)); break; + default: + util.setCode(tmp); + util.setCodeExec(tmp,xleft); + break; + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_variaveis",9, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 27: // instanciacao_variaveis ::= ID ATRIBUIR _operacoes + { + Object RESULT =null; + int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + String tmp = util.setVariavelOperador(x,e); + switch(tmp){ + case "error1" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_ERRO1",x)); break; + case "error2" : parser.syntax_error(xleft,xright,util.Erros("VARIAVEL_ERRO2",x)); break; + default: + util.setCode(tmp); + util.setCodeExec(tmp + "\ttable_variaveis.update(\""+x+"\","+x+");",xleft); + break; + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instanciacao_variaveis",9, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 26: // funcoes_unitarias ::= ESPERAR ABRIR_PARENTESE _operacoes FECHAR_PARENTESE + { + Object RESULT =null; + int fleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int fright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + Object f = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String n = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + String tmp_tipo_operacao = util.getTipoOperacao(); + if(tmp_tipo_operacao != "int"){ + parser.syntax_error(nleft,nright,util.Erros("SOMENTE_INT",null)); + }else{ + util.setCode("\t\tThread.sleep("+n+");"); + util.setCodeExec("\t\tThread.sleep("+n+");",fleft); + } + + CUP$parser$result = parser.getSymbolFactory().newSymbol("funcoes_unitarias",22, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 25: // funcoes_unitarias ::= INTERROMPA + { + Object RESULT =null; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("\t\tbreak;"); + util.setCodeExec("\t\tbreak;",ileft); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("funcoes_unitarias",22, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 24: // corpo_programa ::= escolha_funcao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 23: // corpo_programa ::= para_funcao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 22: // corpo_programa ::= enquanto_funcao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 21: // corpo_programa ::= leia_funcao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // corpo_programa ::= escreva_funcao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 19: // corpo_programa ::= condiciona_estrutura + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 18: // corpo_programa ::= instanciacao_variaveis + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 17: // corpo_programa ::= funcoes_unitarias + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("corpo_programa",8, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 16: // programa ::= + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("programa",7, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 15: // programa ::= programa corpo_programa + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("programa",7, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 14: // var_listagem ::= ID + { + String RESULT =null; + int valueleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int valueright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String value = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = value; + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_listagem",6, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // var_listagem ::= var_listagem SEPARADOR var_listagem + { + String RESULT =null; + int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = e1+","+e2; + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_listagem",6, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // var_instanciacao ::= var_listagem ADD_ATTR_VAR TIPO_VARIAVEL_VETOR ABRIR_COLCHETE NUMERO_INT DOIS_PONTOS NUMERO_INT FECHAR_COLCHETE DE TIPO_VARIAVEL + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-9)).value; + int n1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left; + int n1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).right; + String n1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; + int n2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int n2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + String n2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.addVariavelVetor(e,x,n1,n2); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_instanciacao",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // var_instanciacao ::= var_listagem ADD_ATTR_VAR TIPO_VARIAVEL + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int xleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int xright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String x = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.addVariavel(e,x); + util.setCodeVariables("\t" + util.getTipoVariavel(x) + " " +e+ ";"); + util.setCodeVariablesExec("\t" + util.getTipoVariavel(x) + " " +e+ ";"); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_instanciacao",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // variaveis ::= var_instanciacao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("variaveis",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // variaveis ::= variaveis var_instanciacao + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("variaveis",4, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // var_estrutura ::= + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_estrutura",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // var_estrutura ::= VAR variaveis + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_estrutura",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // var_estrutura ::= VAR + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("var_estrutura",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // algoritmo_instanciacao ::= ALGORITMO STRING + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("public class "+e.substring(1, e.length()-1)+" {"); + util.setCodeName(e.substring(1, e.length()-1)); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo_instanciacao",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // algoritmo_instanciacao ::= ALGORITMO ID + { + Object RESULT =null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + util.setCode("public class "+e+" {"); + util.setCodeName(e); + + CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo_instanciacao",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // algoritmo_nome ::= algoritmo_instanciacao + { + Object RESULT =null; + util.setInitClass(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo_nome",1, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // algoritmo ::= + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo",0, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // algoritmo ::= algoritmo_nome var_estrutura INICIO programa FIMALGORITMO + { + Object RESULT =null; + util.setEndClass(); util.codeComplete(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("algoritmo",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // $START ::= algoritmo EOF + { + Object RESULT =null; + int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = start_val; + CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + diff --git a/src/com/compilador/portugol/sym.java b/src/com/compilador/portugol/sym.java new file mode 100644 index 0000000..a6a7119 --- /dev/null +++ b/src/com/compilador/portugol/sym.java @@ -0,0 +1,73 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Fri Sep 26 15:47:26 BRT 2014 +//---------------------------------------------------- + +package com.compilador.portugol; + +/** CUP generated class containing symbol constants. */ +public class sym { + /* terminals */ + public static final int FIMALGORITMO = 52; + public static final int COSSENO = 34; + public static final int TIPO_VARIAVEL_VETOR = 5; + public static final int FUNCAO = 38; + public static final int CASO = 26; + public static final int DE = 43; + public static final int FIMSE = 19; + public static final int FIMENQUANTO = 23; + public static final int CHAR = 59; + public static final int ESCREVAL = 50; + public static final int ESCOLHA = 25; + public static final int PI = 37; + public static final int CONDICIONAL_NUMERICA = 41; + public static final int SE = 16; + public static final int ATRIBUIR = 10; + public static final int CONDICIONAL_COMPARATIVA = 42; + public static final int SEPARADOR = 54; + public static final int DOIS_PONTOS = 15; + public static final int PASSO = 46; + public static final int E = 44; + public static final int OUTROCASO = 27; + public static final int OPERADOR_SOMA = 8; + public static final int OU = 47; + public static final int ATE = 45; + public static final int RAIZ = 36; + public static final int ENTAO = 17; + public static final int VALOR_LOGICO = 9; + public static final int ALGORITMO = 2; + public static final int ID = 55; + public static final int ADD_ATTR_VAR = 53; + public static final int EOF = 0; + public static final int NUMERO_INT = 57; + public static final int error = 1; + public static final int SENAO = 18; + public static final int ENQUANTO = 20; + public static final int FECHAR_COLCHETE = 14; + public static final int ABRIR_PARENTESE = 11; + public static final int MODULO = 32; + public static final int ESCREVA = 49; + public static final int VOID = 40; + public static final int FIMPARA = 24; + public static final int FACA = 22; + public static final int TIPO_VARIAVEL = 4; + public static final int POTENCIA = 31; + public static final int FECHAR_PARENTESE = 12; + public static final int LEIA = 51; + public static final int TANGENTE = 35; + public static final int OPERADOR = 7; + public static final int INTERROMPA = 29; + public static final int FIMESCOLHA = 28; + public static final int SENO = 33; + public static final int FIMFUNCAO = 39; + public static final int STRING = 56; + public static final int ESPERAR = 30; + public static final int PARA = 21; + public static final int INICIO = 6; + public static final int NAO = 48; + public static final int NUMERO_FLOAT = 58; + public static final int VAR = 3; + public static final int ABRIR_COLCHETE = 13; +} + diff --git a/src/com/editor/flex/Portugol.flex b/src/com/editor/flex/Portugol.flex new file mode 100644 index 0000000..ace08c2 --- /dev/null +++ b/src/com/editor/flex/Portugol.flex @@ -0,0 +1,164 @@ +package com.editor.flex; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; +import jsyntaxpane.lexers.DefaultJFlexLexer; + +%% + +%public +%class PortugolFlex +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + +%caseless +%ignorecase + +%{ + + public PortugolFlex() { + super(); + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + + @Override + public int yychar() { + return yychar; + } +%} + + + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ + +ConstantIdentifier = {SimpleConstantIdentifier} +SimpleConstantIdentifier = [#A-Z0-9_]+ + +Identifier = [:jletter:][:jletterdigit:]* + +TypeIdentifier = {SimpleTypeIdentifier} +SimpleTypeIdentifier = [A-Z][:jletterdigit:]* + +/* int literals */ + +DecLiteral = 0 | [1-9][0-9]* {IntegerSuffix} + +HexLiteral = 0 [xX] 0* {HexDigit}* {IntegerSuffix} +HexDigit = [0-9a-fA-F] + +OctLiteral = 0+ {OctDigit}* {IntegerSuffix} +OctDigit = [0-7] + +IntegerSuffix = [uU]? [lL]? [uU]? + +/* float literals */ + +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? + +FLit1 = [0-9]+ \. [0-9]* {Exponent}? +FLit2 = \. [0-9]+ {Exponent}? +FLit3 = [0-9]+ {Exponent} +FLit4 = [0-9]+ {Exponent}? + +Exponent = [eE] [+\-]? [0-9]+ + +%% + +{ + + /* keywords */ + "algoritmo" | "var" { return token(TokenType.KEYWORD); } + + "escreva" |"escreval" | "leia" | "entao" | "faca" | "e" | "ou" { return token(TokenType.KEYWORD2); } + + /* Type */ + "inteiro" | "caracter" | "real" { return token(TokenType.TYPE); } + + + /* literals */ + (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) { return token(TokenType.STRING); } + + + + {DecLiteral} | {OctLiteral} | {HexLiteral} | {FloatLiteral} { return token(TokenType.NUMBER); } + + + + + + + /* separators */ + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + + "inicio" { return token(TokenType.KEYWORD, CURLY); } + "fimalgoritmo" { return token(TokenType.KEYWORD, -CURLY); } + + "se" | "enquanto" | "senao" { return token(TokenType.KEYWORD2, CURLY); } + "fimse" | "fimenquanto" { return token(TokenType.KEYWORD2, -CURLY); } + + + + + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + + + /* operators */ + "mod" | + "div" | + "=" | + "," | + ">" | + "<" | + ":" | + "+" | + "-" | + "*" | + "/" | + "^" | + "-" { return token(TokenType.OPERATOR); } + + + + {ConstantIdentifier} |{TypeIdentifier} | {Identifier} { return token(TokenType.IDENTIFIER); } + + +{WhiteSpace} {/* IGNORAR */} + +\n {/* IGNORAR */} + + + + {Comment} { return token(TokenType.COMMENT); } + +} + + + +/* error fallback */ +.|\n { } +< > { return null; } \ No newline at end of file diff --git a/src/com/editor/flex/PortugolFlex.java b/src/com/editor/flex/PortugolFlex.java new file mode 100644 index 0000000..d448355 --- /dev/null +++ b/src/com/editor/flex/PortugolFlex.java @@ -0,0 +1,1021 @@ +/* The following code was generated by JFlex 1.5.1 */ + +package com.editor.flex; + + +import de.sciss.syntaxpane.Token; +import de.sciss.syntaxpane.TokenType; +import de.sciss.syntaxpane.lexers.DefaultJFlexLexer; + + + +/** + * This class is a scanner generated by + * JFlex 1.5.1 + * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/src/com/editor/flex/Portugol_v2.flex + */ +public final class PortugolFlex extends DefaultJFlexLexer { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + public static final int STRING = 2; + public static final int ML_STRING = 4; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 1, 1 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\3\1\2\1\70\1\71\1\1\22\0\1\3\1\0\1\64"+ + "\4\0\1\67\1\47\1\50\1\5\1\53\1\62\1\22\1\20\1\4"+ + "\1\10\1\16\2\15\4\15\2\11\1\63\1\0\1\57\1\61\1\60"+ + "\1\66\1\0\4\14\1\21\1\17\2\6\1\56\1\65\1\6\1\12"+ + "\3\6\1\55\7\6\1\13\2\6\1\51\1\23\1\52\1\0\1\7"+ + "\1\0\1\24\1\14\1\36\1\42\1\40\1\37\1\26\1\46\1\31"+ + "\1\65\1\6\1\25\1\33\1\35\1\27\1\43\1\45\1\30\1\41"+ + "\1\32\1\44\1\34\1\6\1\13\1\6\1\54\12\0\1\70\u1fa2\0"+ + "\1\70\1\70\udfd6\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\2\0\1\1\3\2\2\3\1\4\2\5\1\1\13\4"+ + "\1\6\3\4\1\7\1\10\1\11\1\12\1\4\2\3"+ + "\1\13\2\1\1\14\1\0\1\15\3\5\1\0\4\5"+ + "\1\0\4\4\1\6\20\4\1\16\1\4\1\6\2\4"+ + "\1\3\1\0\1\17\1\0\1\17\2\0\2\14\2\0"+ + "\4\5\1\0\10\4\1\3\1\20\14\4\1\3\2\4"+ + "\1\21\2\0\2\5\3\4\1\22\21\4\1\16\2\5"+ + "\10\4\1\5\3\4\1\23\5\4\2\5\2\4\1\24"+ + "\11\4\2\5\10\4\1\6\2\5\6\4\2\5\2\4"+ + "\2\5\2\4\1\0\1\5\1\4\1\0\1\5\1\25"+ + "\1\0\1\5\1\0\1\5\1\0\1\5\1\0\1\5"+ + "\1\0\1\5\1\0\5\5"; + + private static int [] zzUnpackAction() { + int [] result = new int[226]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\72\0\164\0\256\0\164\0\350\0\u0122\0\164"+ + "\0\u015c\0\u0196\0\u01d0\0\u020a\0\u0244\0\u027e\0\u02b8\0\u02f2"+ + "\0\u032c\0\u0366\0\u03a0\0\u03da\0\u0414\0\u044e\0\u0488\0\u04c2"+ + "\0\u04fc\0\u0536\0\u0570\0\164\0\164\0\164\0\164\0\u05aa"+ + "\0\u05e4\0\u061e\0\u0658\0\u0692\0\u06cc\0\u0706\0\u0740\0\164"+ + "\0\u077a\0\u07b4\0\164\0\u07ee\0\u0828\0\u0862\0\u089c\0\u08d6"+ + "\0\u0910\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32\0\u0a6c\0\u0aa6"+ + "\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u0bc8\0\u0c02\0\u0c3c\0\u0c76"+ + "\0\u0cb0\0\u0cea\0\u0d24\0\u0d5e\0\u0d98\0\u0dd2\0\u0e0c\0\u0e46"+ + "\0\u015c\0\u0e80\0\u0eba\0\u015c\0\u06cc\0\164\0\u0ef4\0\u0f2e"+ + "\0\u0f68\0\u0fa2\0\u0fdc\0\164\0\u1016\0\u1050\0\u108a\0\u10c4"+ + "\0\u10fe\0\u1138\0\u1172\0\u11ac\0\u11e6\0\u1220\0\u125a\0\u1294"+ + "\0\u12ce\0\u1308\0\u1342\0\u137c\0\u015c\0\u13b6\0\u13f0\0\u142a"+ + "\0\u1464\0\u149e\0\u14d8\0\u1512\0\u154c\0\u1586\0\u15c0\0\u15fa"+ + "\0\u1634\0\u154c\0\u166e\0\u16a8\0\164\0\u16e2\0\u171c\0\u1756"+ + "\0\u1790\0\u17ca\0\u1804\0\u183e\0\u015c\0\u1878\0\u18b2\0\u18ec"+ + "\0\u1926\0\u1960\0\u199a\0\u19d4\0\u1a0e\0\u1a48\0\u1a82\0\u1abc"+ + "\0\u1af6\0\u1b30\0\u1b6a\0\u1ba4\0\u1bde\0\u1c18\0\u015c\0\u1c52"+ + "\0\u1c8c\0\u1cc6\0\u1d00\0\u1d3a\0\u1d74\0\u1dae\0\u1de8\0\u1e22"+ + "\0\u1e5c\0\u015c\0\u1e96\0\u1ed0\0\u1f0a\0\u015c\0\u1f44\0\u1f7e"+ + "\0\u1fb8\0\u1ff2\0\u202c\0\u2066\0\u20a0\0\u20da\0\u2114\0\u015c"+ + "\0\u214e\0\u2188\0\u21c2\0\u21fc\0\u2236\0\u2270\0\u22aa\0\u22e4"+ + "\0\u231e\0\u2358\0\u2392\0\u23cc\0\u2406\0\u2440\0\u247a\0\u24b4"+ + "\0\u24ee\0\u2528\0\u2562\0\u259c\0\u25d6\0\u2610\0\u264a\0\u2684"+ + "\0\u26be\0\u26f8\0\u2732\0\u276c\0\u27a6\0\u27e0\0\u281a\0\u2854"+ + "\0\u288e\0\u28c8\0\u2902\0\u293c\0\u2976\0\u29b0\0\u29ea\0\u2a24"+ + "\0\u2a5e\0\u015c\0\u2a98\0\u2ad2\0\u2b0c\0\u2b46\0\u2b80\0\u2bba"+ + "\0\u2bf4\0\u2c2e\0\u2c68\0\u2ca2\0\u2cdc\0\u2d16\0\u2d50\0\u2d8a"+ + "\0\u2dc4\0\u2dfe"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[226]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\3"+ + "\1\12\1\13\3\11\2\13\1\11\1\14\1\11\1\10"+ + "\1\3\1\15\1\16\1\11\1\17\1\20\1\21\1\22"+ + "\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+ + "\1\33\3\11\1\34\1\35\1\36\1\37\1\10\1\11"+ + "\1\40\1\11\1\41\2\42\1\10\1\42\1\43\1\11"+ + "\1\3\1\44\1\0\1\6\1\3\1\0\1\5\61\3"+ + "\1\45\2\3\1\44\76\0\1\5\72\0\1\6\65\0"+ + "\1\6\4\0\1\46\1\47\72\0\12\11\1\0\1\11"+ + "\2\0\23\11\5\0\3\11\6\0\1\11\1\50\13\0"+ + "\1\51\1\52\1\53\1\54\1\0\1\55\1\56\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\13\1\53\2\0\2\13\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\41\0\2\60\3\0\2\60"+ + "\61\0\12\11\1\0\1\11\2\0\1\11\1\62\4\11"+ + "\1\63\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\64\10\11\1\65"+ + "\6\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\20\11\1\66\2\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\1\67\13\11\1\70\6\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\11\11\1\71"+ + "\11\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\72\22\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\3\11"+ + "\1\73\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\74\13\11\1\75\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\76\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\77\2\11"+ + "\1\100\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\101\4\11\1\102\12\11"+ + "\1\103\2\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\11\11\1\104\3\11\1\105"+ + "\5\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\6\11\1\106\5\11\1\107\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\5\11\1\110\6\11\1\111\6\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\112\2\11\1\113\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\23\11"+ + "\5\0\2\11\1\114\6\0\1\11\1\50\25\0\1\10"+ + "\35\0\2\10\71\0\1\10\10\0\2\115\1\116\20\115"+ + "\1\117\40\115\1\120\5\115\2\121\1\116\20\121\1\122"+ + "\43\121\1\116\2\121\2\115\1\116\20\115\1\117\40\115"+ + "\1\116\5\115\1\46\1\123\1\124\67\46\5\125\1\126"+ + "\64\125\10\0\1\51\1\52\1\53\2\0\1\55\1\56"+ + "\1\57\1\60\1\61\3\0\1\53\11\0\1\57\1\61"+ + "\41\0\2\52\3\0\2\52\1\57\1\60\1\61\15\0"+ + "\1\57\1\61\41\0\1\127\1\130\2\0\4\130\1\0"+ + "\1\130\2\0\1\130\11\0\3\130\1\0\1\130\37\0"+ + "\1\131\1\52\1\53\2\0\2\131\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\1\55\1\52"+ + "\1\53\2\0\2\55\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\116\0\1\53\14\0\2\60\3\0"+ + "\2\60\1\57\1\0\1\61\15\0\1\57\1\61\41\0"+ + "\2\132\3\0\2\132\3\0\1\133\30\0\1\133\24\0"+ + "\12\11\1\0\1\11\2\0\2\11\1\134\20\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\14\11\1\111\6\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\2\11\1\135"+ + "\20\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\5\11\1\136\15\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\6\11\1\137\14\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\5\11\1\140\15\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\141\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\5\11\1\142"+ + "\1\143\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\11\11\1\114\11\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\16\11\1\144\4\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\4\11\1\145"+ + "\16\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\4\11\1\146\1\11\1\147\14\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\3\11\1\114\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\4\11"+ + "\1\150\10\11\1\151\5\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\15\11\1\114"+ + "\5\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\152\10\11\1\136\10\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\7\11\1\153\13\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\154\11\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\6\11\1\155\12\11\1\156"+ + "\1\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\157\4\11\1\160\3\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\161\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\162\11\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\10\11\1\114\12\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\4\11\1\163\10\11\1\164\5\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\6\11\1\114\14\11\5\0\3\11\6\0\1\11\1\50"+ + "\3\0\2\115\1\116\67\115\64\0\1\165\7\0\1\116"+ + "\20\0\1\166\43\0\1\116\2\0\2\121\1\116\67\121"+ + "\2\0\1\124\67\0\5\125\1\167\64\125\4\0\1\124"+ + "\1\126\74\0\1\127\1\130\1\53\1\0\4\130\1\0"+ + "\1\130\2\0\1\130\1\53\10\0\3\130\1\0\1\130"+ + "\37\0\2\170\1\53\1\0\4\170\1\0\1\170\2\0"+ + "\1\170\1\53\10\0\3\170\1\0\1\170\37\0\1\171"+ + "\1\52\1\53\2\0\2\171\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\41\0\2\132\3\0\2\132"+ + "\1\57\17\0\1\57\42\0\2\132\3\0\2\132\61\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\172\17\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\5\11\1\173\15\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\111\22\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\174\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\23\11"+ + "\5\0\1\114\2\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\175\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\12\11\1\176\10\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\14\11\1\177\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\20\11\1\200\2\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\16\11"+ + "\1\201\4\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\202\17\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\203\22\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\3\11\1\111\17\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\15\11\1\204\5\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\1\205"+ + "\12\11\1\206\1\207\1\210\1\11\1\211\3\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\12\11\1\155\10\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\151\22\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\20\11\1\212\2\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\3\11"+ + "\1\213\1\214\16\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\14\11\1\215\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\5\11\1\216\15\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\1\217"+ + "\22\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\15\11\1\151\5\11\5\0\3\11"+ + "\6\0\1\11\1\50\5\0\1\116\67\0\4\125\1\124"+ + "\1\167\64\125\10\0\2\220\1\53\1\0\4\220\1\0"+ + "\1\220\2\0\1\220\1\53\10\0\3\220\1\0\1\220"+ + "\37\0\1\221\1\52\1\53\2\0\2\221\1\57\1\60"+ + "\1\61\3\0\1\53\11\0\1\57\1\61\37\0\12\11"+ + "\1\0\1\11\2\0\4\11\1\222\16\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\12\11\1\223\10\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\3\11\1\224\17\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\5\11\1\225\15\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\4\11"+ + "\1\226\1\227\15\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\11\1\76\21\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\230\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\4\11\1\111"+ + "\16\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\231\10\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\232\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\11\1\233\21\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\20\11\1\103\2\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\234\3\11\1\235\5\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\14\11\1\236"+ + "\6\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\237\22\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\1\240"+ + "\22\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\241\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\14\11\1\242\6\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\4\11\1\63\16\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\11\11\1\243\11\11\5\0\3\11\6\0"+ + "\1\11\1\50\13\0\2\244\1\53\1\0\4\244\1\0"+ + "\1\244\2\0\1\244\1\53\10\0\3\244\1\0\1\244"+ + "\37\0\1\245\1\52\1\53\2\0\2\245\1\57\1\60"+ + "\1\61\3\0\1\53\11\0\1\57\1\61\37\0\12\11"+ + "\1\0\1\11\2\0\5\11\1\246\15\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\175\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\12\11\1\247\10\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\3\11\1\250\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\4\11"+ + "\1\251\16\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\4\11\1\223\16\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\16\11\1\252\4\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\6\11\1\253"+ + "\14\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\2\11\1\254\20\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\21\11\1\255\1\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\12\11\1\256\10\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\257\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\260\11\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\22\11\1\163\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\10\11\1\261\12\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\2\11\1\175\20\11"+ + "\5\0\3\11\6\0\1\11\1\50\13\0\2\262\1\53"+ + "\1\0\4\262\1\0\1\262\2\0\1\262\1\53\10\0"+ + "\3\262\1\0\1\262\37\0\1\263\1\52\1\53\2\0"+ + "\2\263\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\37\0\12\11\1\0\1\11\2\0\6\11\1\264"+ + "\14\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\164\22\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\3\11"+ + "\1\265\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\14\11\1\266\6\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\14\11\1\267\6\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\3\11\1\270"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\20\11\1\271\2\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\272\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\236\22\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\6\11\1\273\14\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\274\22\11"+ + "\5\0\3\11\6\0\1\11\1\50\13\0\2\275\1\53"+ + "\1\0\4\275\1\0\1\275\2\0\1\275\1\53\10\0"+ + "\3\275\1\0\1\275\37\0\1\276\1\52\1\53\2\0"+ + "\2\276\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\37\0\12\11\1\0\1\11\2\0\7\11\1\277"+ + "\13\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\7\11\1\300\13\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\5\11\1\301\15\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\4\11\1\175\16\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\302\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\1\303"+ + "\22\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\304\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\217\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\11\1\111\21\11"+ + "\5\0\3\11\6\0\1\11\1\50\13\0\2\305\1\53"+ + "\1\0\4\305\1\0\1\305\2\0\1\305\1\53\10\0"+ + "\3\305\1\0\1\305\37\0\1\306\1\52\1\53\2\0"+ + "\2\306\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\37\0\12\11\1\0\1\11\2\0\3\11\1\145"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\17\11\1\136\3\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\4\11\1\204\16\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\5\11\1\307\15\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\11\11\1\310\11\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\22\11"+ + "\1\257\5\0\3\11\6\0\1\11\1\50\13\0\2\311"+ + "\1\53\1\0\4\311\1\0\1\311\2\0\1\311\1\53"+ + "\10\0\3\311\1\0\1\311\37\0\1\312\1\52\1\53"+ + "\2\0\2\312\1\57\1\60\1\61\3\0\1\53\11\0"+ + "\1\57\1\61\37\0\12\11\1\0\1\11\2\0\6\11"+ + "\1\313\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\6\11\1\314\14\11\5\0"+ + "\3\11\6\0\1\11\1\50\13\0\2\315\1\53\1\0"+ + "\4\315\1\0\1\315\2\0\1\315\1\53\10\0\3\315"+ + "\1\0\1\315\37\0\1\316\1\52\1\53\2\0\2\316"+ + "\1\57\1\60\1\61\3\0\1\53\11\0\1\57\1\61"+ + "\37\0\12\11\1\0\1\11\2\0\7\11\1\317\13\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\3\11\1\236\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\13\0\2\320\1\53\1\0\4\320\1\0"+ + "\1\320\2\0\1\320\1\53\10\0\3\320\1\0\1\320"+ + "\37\0\1\321\1\52\1\53\2\0\2\321\1\57\1\60"+ + "\1\61\3\0\1\53\11\0\1\57\1\61\37\0\12\11"+ + "\1\0\1\11\2\0\3\11\1\322\17\11\5\0\3\11"+ + "\6\0\1\11\1\50\13\0\2\323\1\53\1\0\4\323"+ + "\1\0\1\323\2\0\1\323\1\53\10\0\3\323\1\0"+ + "\1\323\37\0\1\324\1\52\1\53\2\0\2\324\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\325\1\53\1\0\4\325\1\0\1\325\2\0\1\325"+ + "\1\53\10\0\3\325\1\0\1\325\37\0\1\326\1\52"+ + "\1\53\2\0\2\326\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\41\0\2\327\1\53\1\0\4\327"+ + "\1\0\1\327\2\0\1\327\1\53\10\0\3\327\1\0"+ + "\1\327\37\0\1\330\1\52\1\53\2\0\2\330\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\331\1\53\1\0\4\331\1\0\1\331\2\0\1\331"+ + "\1\53\10\0\3\331\1\0\1\331\37\0\1\332\1\52"+ + "\1\53\2\0\2\332\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\41\0\2\333\1\53\1\0\4\333"+ + "\1\0\1\333\2\0\1\333\1\53\10\0\3\333\1\0"+ + "\1\333\37\0\1\334\1\52\1\53\2\0\2\334\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\335\1\53\1\0\4\335\1\0\1\335\2\0\1\335"+ + "\1\53\10\0\3\335\1\0\1\335\37\0\1\336\1\52"+ + "\1\53\2\0\2\336\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\43\0\1\53\12\0\1\53\54\0"+ + "\1\337\1\52\1\53\2\0\2\337\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\1\340\1\52"+ + "\1\53\2\0\2\340\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\41\0\1\341\1\52\1\53\2\0"+ + "\2\341\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\41\0\1\342\1\52\1\53\2\0\2\342\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\52\1\53\2\0\2\52\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\31\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[11832]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
+ */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\2\0\1\11\1\1\1\11\2\1\1\11\23\1\4\11"+ + "\7\1\1\0\1\11\2\1\1\11\1\0\4\1\1\0"+ + "\33\1\1\0\1\11\1\0\1\1\2\0\1\1\1\11"+ + "\2\0\4\1\1\0\31\1\1\11\2\0\125\1\1\0"+ + "\2\1\1\0\2\1\1\0\1\1\1\0\1\1\1\0"+ + "\1\1\1\0\1\1\1\0\1\1\1\0\5\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[226]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public PortugolFlex() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte WORD = 4; + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public PortugolFlex(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public PortugolFlex(java.io.InputStream in) { + this(new java.io.InputStreamReader + (in, java.nio.charset.Charset.forName("UTF-8"))); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 166) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @returnfalse
, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead > 0) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * Internal scan buffer is resized down to its initial length, if it has grown. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + if (zzBuffer.length > ZZ_BUFFERSIZE) + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public Token yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar+= zzMarkedPosL-zzStartRead; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return token(TokenType.ERROR); + } + case 22: break; + case 2: + { + } + case 23: break; + case 3: + { return token(TokenType.OPERATOR); + } + case 24: break; + case 4: + { return token(TokenType.IDENTIFIER); + } + case 25: break; + case 5: + { return token(TokenType.NUMBER); + } + case 26: break; + case 6: + { return token(TokenType.KEYWORD2); + } + case 27: break; + case 7: + { return token(TokenType.OPERATOR, PARAN); + } + case 28: break; + case 8: + { return token(TokenType.OPERATOR, -PARAN); + } + case 29: break; + case 9: + { return token(TokenType.OPERATOR, BRACKET); + } + case 30: break; + case 10: + { return token(TokenType.OPERATOR, -BRACKET); + } + case 31: break; + case 11: + { yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + case 32: break; + case 12: + { return token(TokenType.COMMENT); + } + case 33: break; + case 13: + { return token(TokenType.TYPE2); + } + case 34: break; + case 14: + { return token(TokenType.KEYWORD2, WORD); + } + case 35: break; + case 15: + { return token(TokenType.STRING); + } + case 36: break; + case 16: + { return token(TokenType.KEYWORD); + } + case 37: break; + case 17: + { yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + case 38: break; + case 18: + { return token(TokenType.TYPE); + } + case 39: break; + case 19: + { return token(TokenType.KEYWORD2, -WORD); + } + case 40: break; + case 20: + { return token(TokenType.KEYWORD, WORD); + } + case 41: break; + case 21: + { return token(TokenType.KEYWORD, -WORD); + } + case 42: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return null; + } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/com/editor/flex/PortugolFlex.java~ b/src/com/editor/flex/PortugolFlex.java~ new file mode 100644 index 0000000..3a1e1b3 --- /dev/null +++ b/src/com/editor/flex/PortugolFlex.java~ @@ -0,0 +1,1018 @@ +/* The following code was generated by JFlex 1.5.1 */ + +package com.editor.flex; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; +import jsyntaxpane.lexers.DefaultJFlexLexer; + + + +/** + * This class is a scanner generated by + * JFlex 1.5.1 + * from the specification file C:/Users/SIMONETO-2/Documents/NetBeansProjects/portugol-projeto/src/com/editor/flex/Portugol_v2.flex + */ +public final class PortugolFlex extends DefaultJFlexLexer { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + public static final int STRING = 2; + public static final int ML_STRING = 4; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 1, 1 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\3\1\2\1\70\1\71\1\1\22\0\1\3\1\0\1\64"+ + "\4\0\1\67\1\47\1\50\1\5\1\53\1\62\1\22\1\20\1\4"+ + "\1\10\1\16\2\15\4\15\2\11\1\63\1\0\1\57\1\61\1\60"+ + "\1\66\1\0\4\14\1\21\1\17\2\6\1\56\1\65\1\6\1\12"+ + "\3\6\1\55\7\6\1\13\2\6\1\51\1\23\1\52\1\0\1\7"+ + "\1\0\1\24\1\14\1\36\1\42\1\40\1\37\1\26\1\46\1\31"+ + "\1\65\1\6\1\25\1\33\1\35\1\27\1\43\1\45\1\30\1\41"+ + "\1\32\1\44\1\34\1\6\1\13\1\6\1\54\12\0\1\70\u1fa2\0"+ + "\1\70\1\70\udfd6\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\2\0\1\1\3\2\2\3\1\4\2\5\1\1\13\4"+ + "\1\6\3\4\1\7\1\10\1\11\1\12\1\4\2\3"+ + "\1\13\2\1\1\14\1\0\1\15\3\5\1\0\4\5"+ + "\1\0\4\4\1\6\20\4\1\16\1\4\1\6\2\4"+ + "\1\3\1\0\1\17\1\0\1\17\2\0\2\14\2\0"+ + "\4\5\1\0\10\4\1\3\1\20\14\4\1\3\2\4"+ + "\1\21\2\0\2\5\3\4\1\22\20\4\1\16\2\5"+ + "\10\4\1\5\3\4\1\23\5\4\2\5\2\4\1\24"+ + "\11\4\2\5\10\4\1\6\2\5\6\4\2\5\2\4"+ + "\2\5\2\4\1\0\1\5\1\4\1\0\1\5\1\25"+ + "\1\0\1\5\1\0\1\5\1\0\1\5\1\0\1\5"+ + "\1\0\1\5\1\0\5\5"; + + private static int [] zzUnpackAction() { + int [] result = new int[225]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\72\0\164\0\256\0\164\0\350\0\u0122\0\164"+ + "\0\u015c\0\u0196\0\u01d0\0\u020a\0\u0244\0\u027e\0\u02b8\0\u02f2"+ + "\0\u032c\0\u0366\0\u03a0\0\u03da\0\u0414\0\u044e\0\u0488\0\u04c2"+ + "\0\u04fc\0\u0536\0\u0570\0\164\0\164\0\164\0\164\0\u05aa"+ + "\0\u05e4\0\u061e\0\u0658\0\u0692\0\u06cc\0\u0706\0\u0740\0\164"+ + "\0\u077a\0\u07b4\0\164\0\u07ee\0\u0828\0\u0862\0\u089c\0\u08d6"+ + "\0\u0910\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32\0\u0a6c\0\u0aa6"+ + "\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u0bc8\0\u0c02\0\u0c3c\0\u0c76"+ + "\0\u0cb0\0\u0cea\0\u0d24\0\u0d5e\0\u0d98\0\u0dd2\0\u0e0c\0\u0e46"+ + "\0\u015c\0\u0e80\0\u0eba\0\u015c\0\u06cc\0\164\0\u0ef4\0\u0f2e"+ + "\0\u0f68\0\u0fa2\0\u0fdc\0\164\0\u1016\0\u1050\0\u108a\0\u10c4"+ + "\0\u10fe\0\u1138\0\u1172\0\u11ac\0\u11e6\0\u1220\0\u125a\0\u1294"+ + "\0\u12ce\0\u1308\0\u1342\0\u0c02\0\u015c\0\u137c\0\u13b6\0\u13f0"+ + "\0\u142a\0\u1464\0\u149e\0\u14d8\0\u1512\0\u154c\0\u1586\0\u15c0"+ + "\0\u15fa\0\u1512\0\u1634\0\u166e\0\164\0\u16a8\0\u16e2\0\u171c"+ + "\0\u1756\0\u1790\0\u17ca\0\u1804\0\u015c\0\u183e\0\u1878\0\u18b2"+ + "\0\u18ec\0\u1926\0\u1960\0\u199a\0\u19d4\0\u1a0e\0\u1a48\0\u1a82"+ + "\0\u1abc\0\u1af6\0\u1b30\0\u1b6a\0\u1ba4\0\u015c\0\u1bde\0\u1c18"+ + "\0\u1c52\0\u1c8c\0\u1cc6\0\u1d00\0\u1d3a\0\u1d74\0\u1dae\0\u1de8"+ + "\0\u015c\0\u1e22\0\u1e5c\0\u1e96\0\u015c\0\u1ed0\0\u1f0a\0\u1f44"+ + "\0\u1f7e\0\u1fb8\0\u1ff2\0\u202c\0\u2066\0\u20a0\0\u015c\0\u20da"+ + "\0\u2114\0\u214e\0\u2188\0\u21c2\0\u21fc\0\u2236\0\u2270\0\u22aa"+ + "\0\u22e4\0\u231e\0\u2358\0\u2392\0\u23cc\0\u2406\0\u2440\0\u247a"+ + "\0\u24b4\0\u24ee\0\u2528\0\u2562\0\u259c\0\u25d6\0\u2610\0\u264a"+ + "\0\u2684\0\u26be\0\u26f8\0\u2732\0\u276c\0\u27a6\0\u27e0\0\u281a"+ + "\0\u2854\0\u288e\0\u28c8\0\u2902\0\u293c\0\u2976\0\u29b0\0\u29ea"+ + "\0\u015c\0\u2a24\0\u2a5e\0\u2a98\0\u2ad2\0\u2b0c\0\u2b46\0\u2b80"+ + "\0\u2bba\0\u2bf4\0\u2c2e\0\u2c68\0\u2ca2\0\u2cdc\0\u2d16\0\u2d50"+ + "\0\u2d8a"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[225]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\3"+ + "\1\12\1\13\3\11\2\13\1\11\1\14\1\11\1\10"+ + "\1\3\1\15\1\16\1\11\1\17\1\20\1\21\1\22"+ + "\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+ + "\1\33\3\11\1\34\1\35\1\36\1\37\1\10\1\11"+ + "\1\40\1\11\1\41\2\42\1\10\1\42\1\43\1\11"+ + "\1\3\1\44\1\0\1\6\1\3\1\0\1\5\61\3"+ + "\1\45\2\3\1\44\76\0\1\5\72\0\1\6\65\0"+ + "\1\6\4\0\1\46\1\47\72\0\12\11\1\0\1\11"+ + "\2\0\23\11\5\0\3\11\6\0\1\11\1\50\13\0"+ + "\1\51\1\52\1\53\1\54\1\0\1\55\1\56\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\2\13\1\53\2\0\2\13\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\41\0\2\60\3\0\2\60"+ + "\61\0\12\11\1\0\1\11\2\0\1\11\1\62\4\11"+ + "\1\63\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\64\10\11\1\65"+ + "\6\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\20\11\1\66\2\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\1\67\13\11\1\70\6\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\11\11\1\71"+ + "\11\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\72\22\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\3\11"+ + "\1\73\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\74\13\11\1\75\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\76\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\77\2\11"+ + "\1\100\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\101\4\11\1\102\12\11"+ + "\1\103\2\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\11\11\1\104\3\11\1\105"+ + "\5\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\6\11\1\106\5\11\1\107\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\5\11\1\110\6\11\1\111\6\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\112\2\11\1\113\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\23\11"+ + "\5\0\2\11\1\114\6\0\1\11\1\50\25\0\1\10"+ + "\35\0\2\10\71\0\1\10\10\0\2\115\1\116\20\115"+ + "\1\117\40\115\1\120\5\115\2\121\1\116\20\121\1\122"+ + "\43\121\1\116\2\121\2\115\1\116\20\115\1\117\40\115"+ + "\1\116\5\115\1\46\1\123\1\124\67\46\5\125\1\126"+ + "\64\125\10\0\1\51\1\52\1\53\2\0\1\55\1\56"+ + "\1\57\1\60\1\61\3\0\1\53\11\0\1\57\1\61"+ + "\41\0\2\52\3\0\2\52\1\57\1\60\1\61\15\0"+ + "\1\57\1\61\41\0\1\127\1\130\2\0\4\130\1\0"+ + "\1\130\2\0\1\130\11\0\3\130\1\0\1\130\37\0"+ + "\1\131\1\52\1\53\2\0\2\131\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\1\55\1\52"+ + "\1\53\2\0\2\55\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\116\0\1\53\14\0\2\60\3\0"+ + "\2\60\1\57\1\0\1\61\15\0\1\57\1\61\41\0"+ + "\2\132\3\0\2\132\3\0\1\133\30\0\1\133\24\0"+ + "\12\11\1\0\1\11\2\0\2\11\1\134\20\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\14\11\1\111\6\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\2\11\1\135"+ + "\20\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\5\11\1\136\15\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\6\11\1\137\14\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\5\11\1\140\15\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\141\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\5\11\1\142"+ + "\1\143\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\11\11\1\114\11\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\16\11\1\144\4\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\4\11\1\145"+ + "\16\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\4\11\1\146\1\11\1\147\14\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\3\11\1\114\17\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\4\11"+ + "\1\150\10\11\1\151\5\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\15\11\1\114"+ + "\5\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\152\10\11\1\136\10\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\7\11\1\153\13\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\154\11\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\6\11\1\155\12\11\1\156"+ + "\1\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\157\4\11\1\160\3\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\161\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\11\11"+ + "\1\162\11\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\10\11\1\114\12\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\4\11\1\163\10\11\1\164\5\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\6\11\1\114\14\11\5\0\3\11\6\0\1\11\1\50"+ + "\3\0\2\115\1\116\67\115\64\0\1\165\7\0\1\116"+ + "\20\0\1\166\43\0\1\116\2\0\2\121\1\116\67\121"+ + "\2\0\1\124\67\0\5\125\1\167\64\125\4\0\1\124"+ + "\1\126\74\0\1\127\1\130\1\53\1\0\4\130\1\0"+ + "\1\130\2\0\1\130\1\53\10\0\3\130\1\0\1\130"+ + "\37\0\2\170\1\53\1\0\4\170\1\0\1\170\2\0"+ + "\1\170\1\53\10\0\3\170\1\0\1\170\37\0\1\171"+ + "\1\52\1\53\2\0\2\171\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\41\0\2\132\3\0\2\132"+ + "\1\57\17\0\1\57\42\0\2\132\3\0\2\132\61\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\172\17\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\5\11\1\173\15\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\1\111\22\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\174\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\23\11"+ + "\5\0\1\114\2\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\175\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\12\11\1\176\10\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\14\11\1\177\6\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\16\11\1\200\4\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\3\11"+ + "\1\201\17\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\202\22\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\111\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\15\11\1\203\5\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\204\12\11\1\205\1\206\1\207\1\11"+ + "\1\210\3\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\12\11\1\155\10\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\151\22\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\20\11\1\211\2\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\3\11\1\212\1\213\16\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\14\11\1\214\6\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\5\11\1\215\15\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\1\216\22\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\15\11\1\151"+ + "\5\11\5\0\3\11\6\0\1\11\1\50\5\0\1\116"+ + "\67\0\4\125\1\124\1\167\64\125\10\0\2\217\1\53"+ + "\1\0\4\217\1\0\1\217\2\0\1\217\1\53\10\0"+ + "\3\217\1\0\1\217\37\0\1\220\1\52\1\53\2\0"+ + "\2\220\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\37\0\12\11\1\0\1\11\2\0\4\11\1\221"+ + "\16\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\222\10\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\223\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\5\11\1\224\15\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\225\1\226\15\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\1\227\22\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\4\11\1\111\16\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\12\11\1\230\10\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\3\11\1\231"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\232\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\20\11\1\103\2\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\11\11\1\233\3\11"+ + "\1\234\5\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\14\11\1\235\6\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\236\22\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\237\22\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\11\1\240\21\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\14\11\1\241"+ + "\6\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\4\11\1\63\16\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\11\11\1\242\11\11\5\0\3\11\6\0\1\11\1\50"+ + "\13\0\2\243\1\53\1\0\4\243\1\0\1\243\2\0"+ + "\1\243\1\53\10\0\3\243\1\0\1\243\37\0\1\244"+ + "\1\52\1\53\2\0\2\244\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\37\0\12\11\1\0\1\11"+ + "\2\0\5\11\1\245\15\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\3\11\1\175"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\246\10\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\247\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\4\11\1\250\16\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\4\11\1\222\16\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\16\11"+ + "\1\251\4\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\6\11\1\252\14\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\2\11\1\253\20\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\21\11\1\254"+ + "\1\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\12\11\1\255\10\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\4\11\1\256\16\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\11\11\1\257\11\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\22\11\1\163\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\10\11\1\260"+ + "\12\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\2\11\1\175\20\11\5\0\3\11"+ + "\6\0\1\11\1\50\13\0\2\261\1\53\1\0\4\261"+ + "\1\0\1\261\2\0\1\261\1\53\10\0\3\261\1\0"+ + "\1\261\37\0\1\262\1\52\1\53\2\0\2\262\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\37\0"+ + "\12\11\1\0\1\11\2\0\6\11\1\263\14\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\164\22\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\3\11\1\264\17\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\14\11\1\265\6\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\14\11"+ + "\1\266\6\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\267\17\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\20\11\1\270\2\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\3\11\1\271"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\235\22\11\5\0\3\11\6\0"+ + "\1\11\1\50\11\0\12\11\1\0\1\11\2\0\6\11"+ + "\1\272\14\11\5\0\3\11\6\0\1\11\1\50\11\0"+ + "\12\11\1\0\1\11\2\0\1\273\22\11\5\0\3\11"+ + "\6\0\1\11\1\50\13\0\2\274\1\53\1\0\4\274"+ + "\1\0\1\274\2\0\1\274\1\53\10\0\3\274\1\0"+ + "\1\274\37\0\1\275\1\52\1\53\2\0\2\275\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\37\0"+ + "\12\11\1\0\1\11\2\0\7\11\1\276\13\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\7\11\1\277\13\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\5\11\1\300"+ + "\15\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\4\11\1\175\16\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\4\11\1\301\16\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\1\302\22\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\1\11\1\303\21\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\3\11\1\216"+ + "\17\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\1\11\1\111\21\11\5\0\3\11"+ + "\6\0\1\11\1\50\13\0\2\304\1\53\1\0\4\304"+ + "\1\0\1\304\2\0\1\304\1\53\10\0\3\304\1\0"+ + "\1\304\37\0\1\305\1\52\1\53\2\0\2\305\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\37\0"+ + "\12\11\1\0\1\11\2\0\3\11\1\145\17\11\5\0"+ + "\3\11\6\0\1\11\1\50\11\0\12\11\1\0\1\11"+ + "\2\0\17\11\1\136\3\11\5\0\3\11\6\0\1\11"+ + "\1\50\11\0\12\11\1\0\1\11\2\0\4\11\1\203"+ + "\16\11\5\0\3\11\6\0\1\11\1\50\11\0\12\11"+ + "\1\0\1\11\2\0\5\11\1\306\15\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\11\11\1\307\11\11\5\0\3\11\6\0\1\11\1\50"+ + "\11\0\12\11\1\0\1\11\2\0\22\11\1\256\5\0"+ + "\3\11\6\0\1\11\1\50\13\0\2\310\1\53\1\0"+ + "\4\310\1\0\1\310\2\0\1\310\1\53\10\0\3\310"+ + "\1\0\1\310\37\0\1\311\1\52\1\53\2\0\2\311"+ + "\1\57\1\60\1\61\3\0\1\53\11\0\1\57\1\61"+ + "\37\0\12\11\1\0\1\11\2\0\6\11\1\312\14\11"+ + "\5\0\3\11\6\0\1\11\1\50\11\0\12\11\1\0"+ + "\1\11\2\0\6\11\1\313\14\11\5\0\3\11\6\0"+ + "\1\11\1\50\13\0\2\314\1\53\1\0\4\314\1\0"+ + "\1\314\2\0\1\314\1\53\10\0\3\314\1\0\1\314"+ + "\37\0\1\315\1\52\1\53\2\0\2\315\1\57\1\60"+ + "\1\61\3\0\1\53\11\0\1\57\1\61\37\0\12\11"+ + "\1\0\1\11\2\0\7\11\1\316\13\11\5\0\3\11"+ + "\6\0\1\11\1\50\11\0\12\11\1\0\1\11\2\0"+ + "\3\11\1\235\17\11\5\0\3\11\6\0\1\11\1\50"+ + "\13\0\2\317\1\53\1\0\4\317\1\0\1\317\2\0"+ + "\1\317\1\53\10\0\3\317\1\0\1\317\37\0\1\320"+ + "\1\52\1\53\2\0\2\320\1\57\1\60\1\61\3\0"+ + "\1\53\11\0\1\57\1\61\37\0\12\11\1\0\1\11"+ + "\2\0\3\11\1\321\17\11\5\0\3\11\6\0\1\11"+ + "\1\50\13\0\2\322\1\53\1\0\4\322\1\0\1\322"+ + "\2\0\1\322\1\53\10\0\3\322\1\0\1\322\37\0"+ + "\1\323\1\52\1\53\2\0\2\323\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\2\324\1\53"+ + "\1\0\4\324\1\0\1\324\2\0\1\324\1\53\10\0"+ + "\3\324\1\0\1\324\37\0\1\325\1\52\1\53\2\0"+ + "\2\325\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\41\0\2\326\1\53\1\0\4\326\1\0\1\326"+ + "\2\0\1\326\1\53\10\0\3\326\1\0\1\326\37\0"+ + "\1\327\1\52\1\53\2\0\2\327\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\2\330\1\53"+ + "\1\0\4\330\1\0\1\330\2\0\1\330\1\53\10\0"+ + "\3\330\1\0\1\330\37\0\1\331\1\52\1\53\2\0"+ + "\2\331\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\41\0\2\332\1\53\1\0\4\332\1\0\1\332"+ + "\2\0\1\332\1\53\10\0\3\332\1\0\1\332\37\0"+ + "\1\333\1\52\1\53\2\0\2\333\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\2\334\1\53"+ + "\1\0\4\334\1\0\1\334\2\0\1\334\1\53\10\0"+ + "\3\334\1\0\1\334\37\0\1\335\1\52\1\53\2\0"+ + "\2\335\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\43\0\1\53\12\0\1\53\54\0\1\336\1\52"+ + "\1\53\2\0\2\336\1\57\1\60\1\61\3\0\1\53"+ + "\11\0\1\57\1\61\41\0\1\337\1\52\1\53\2\0"+ + "\2\337\1\57\1\60\1\61\3\0\1\53\11\0\1\57"+ + "\1\61\41\0\1\340\1\52\1\53\2\0\2\340\1\57"+ + "\1\60\1\61\3\0\1\53\11\0\1\57\1\61\41\0"+ + "\1\341\1\52\1\53\2\0\2\341\1\57\1\60\1\61"+ + "\3\0\1\53\11\0\1\57\1\61\41\0\2\52\1\53"+ + "\2\0\2\52\1\57\1\60\1\61\3\0\1\53\11\0"+ + "\1\57\1\61\31\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[11716]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of stateaState
+ */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\2\0\1\11\1\1\1\11\2\1\1\11\23\1\4\11"+ + "\7\1\1\0\1\11\2\1\1\11\1\0\4\1\1\0"+ + "\33\1\1\0\1\11\1\0\1\1\2\0\1\1\1\11"+ + "\2\0\4\1\1\0\31\1\1\11\2\0\124\1\1\0"+ + "\2\1\1\0\2\1\1\0\1\1\1\0\1\1\1\0"+ + "\1\1\1\0\1\1\1\0\1\1\1\0\5\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[225]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public PortugolFlex() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte WORD = 4; + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public PortugolFlex(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public PortugolFlex(java.io.InputStream in) { + this(new java.io.InputStreamReader + (in, java.nio.charset.Charset.forName("UTF-8"))); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 166) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @returnfalse
, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead > 0) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * Internal scan buffer is resized down to its initial length, if it has grown. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + if (zzBuffer.length > ZZ_BUFFERSIZE) + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public Token yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar+= zzMarkedPosL-zzStartRead; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return token(TokenType.ERROR); + } + case 22: break; + case 2: + { + } + case 23: break; + case 3: + { return token(TokenType.OPERATOR); + } + case 24: break; + case 4: + { return token(TokenType.IDENTIFIER); + } + case 25: break; + case 5: + { return token(TokenType.NUMBER); + } + case 26: break; + case 6: + { return token(TokenType.KEYWORD2); + } + case 27: break; + case 7: + { return token(TokenType.OPERATOR, PARAN); + } + case 28: break; + case 8: + { return token(TokenType.OPERATOR, -PARAN); + } + case 29: break; + case 9: + { return token(TokenType.OPERATOR, BRACKET); + } + case 30: break; + case 10: + { return token(TokenType.OPERATOR, -BRACKET); + } + case 31: break; + case 11: + { yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + case 32: break; + case 12: + { return token(TokenType.COMMENT); + } + case 33: break; + case 13: + { return token(TokenType.TYPE2); + } + case 34: break; + case 14: + { return token(TokenType.KEYWORD2, WORD); + } + case 35: break; + case 15: + { return token(TokenType.STRING); + } + case 36: break; + case 16: + { return token(TokenType.KEYWORD); + } + case 37: break; + case 17: + { yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + case 38: break; + case 18: + { return token(TokenType.TYPE); + } + case 39: break; + case 19: + { return token(TokenType.KEYWORD2, -WORD); + } + case 40: break; + case 20: + { return token(TokenType.KEYWORD, WORD); + } + case 41: break; + case 21: + { return token(TokenType.KEYWORD, -WORD); + } + case 42: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return null; + } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/com/editor/flex/Portugol_v2.flex b/src/com/editor/flex/Portugol_v2.flex new file mode 100644 index 0000000..d824ca5 --- /dev/null +++ b/src/com/editor/flex/Portugol_v2.flex @@ -0,0 +1,230 @@ +package com.editor.flex; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; +import jsyntaxpane.lexers.DefaultJFlexLexer; + + +%% + +%public +%class PortugolFlex +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + +/*%caseless*/ +/*%ignorecase*/ + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public PortugolFlex() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte WORD = 4; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [a-zA-Z][a-zA-Z0-9_]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] + +%state STRING, ML_STRING + +%% + +{ + + /* key principais */ + "algoritmo" | + "var" { return token(TokenType.KEYWORD); } + + + "inicio" { return token(TokenType.KEYWORD, WORD); } + "fimalgoritmo" { return token(TokenType.KEYWORD, -WORD); } + + + + + /* keys secundarias */ + "leia" | + "escreva" | + "escreval" | + "entao" | + "vetor" | + "de" | + "ate" | + "passo" | + "e" | + "ou" | + "senao" | + "caso" | + "outrocaso" | + "interrompa" | + "funcao" | + "fimfuncao" | + "espere" | + "faca" { return token(TokenType.KEYWORD2); } + + + /* key secundarias com abertura de identacao */ + "enquanto" | + "escolha" | + "para" | + "se" { return token(TokenType.KEYWORD2, WORD); } + + "fimenquanto" | + "fimescolha" | + "fimpara" | + "fimse" { return token(TokenType.KEYWORD2, -WORD); } + + + "string" | + "inteiro" | + "caracter" | + "logico" | + "real" { return token(TokenType.TYPE); } + + + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + /* "{" { return token(TokenType.OPERATOR, CURLY); } */ + /* "}" { return token(TokenType.OPERATOR, -CURLY); } */ + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + + + "+" | + "-" | + "*" | + "/" | + "mod" | + "div" | + "nao" | + "pot" | + "modulo" | + "sen" | + "cos" | + "tan" | + "raiz" | + "PI" | + "<" | + ">" | + "<=" | + ">=" | + "==" | + "<>" | + "," | + ":" | + ":=" | + "<-" | + "=" { return token(TokenType.OPERATOR); } + + + "verdadeiro"| + "falso" { return token(TokenType.NUMBER); } + + + /* string literal */ + \"{3} { + yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + + /* identifiers */ + {Identifier}"?" { return token(TokenType.TYPE2); } + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) { return token(TokenType.STRING); } + + (\' ( [^\'\n\\] | \\[^\n] ){0,1} (\n | \\\n | \')) { return token(TokenType.STRING); } + +/* error fallback */ +\n { } +. {return token(TokenType.ERROR); } +< > { return null; } diff --git a/src/com/editor/identacao/Portugol.cup b/src/com/editor/identacao/Portugol.cup new file mode 100644 index 0000000..ca8b541 --- /dev/null +++ b/src/com/editor/identacao/Portugol.cup @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (IDENTACAO). //// +* BY: ANDREW NETO //// +* 29/09/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +import java_cup.runtime.*; + + +terminal VAR; + +terminal INICIO,FIMALGORITMO; + + +terminal SE,SENAO,FIMSE; +terminal ENQUANTO,FIMENQUANTO,PARA,FIMPARA; +terminal ESCOLHA,CASO,OUTROCASO,FIMESCOLHA; + +terminal ALL; + + + + +non terminal identacao; + + +start with identacao; + + +identacao ::= VAR \ No newline at end of file diff --git a/src/com/editor/identacao/Portugol.flex b/src/com/editor/identacao/Portugol.flex new file mode 100644 index 0000000..1814ad4 --- /dev/null +++ b/src/com/editor/identacao/Portugol.flex @@ -0,0 +1,72 @@ +//////////////////////////////////////////////////////////////////////// +/* //// +* ANALIZADOR DE PORTUGOL (TOKENS). //// +* BY: ANDREW NETO //// +* 05/07/2014 //// +*/ //// +//////////////////////////////////////////////////////////////////////// + +package com.compilador.portugol; + +import java_cup.runtime.*; + + +%% +%class PortugolFlex +%cup +%line +%char +%column + + +%{ + + public PortugolFlex() { + super(); + } + + Symbol newSym(int tokenId) { + return new Symbol(tokenId , yyline, yycolumn); + } + + Symbol newSym(int tokenId, Object value) { + return new Symbol(tokenId , yyline, yycolumn, value); + } + +%} + + +newline = \r|\n|\r\n +full = .* + + + +%% + + +"var" {return newSym(sym.VAR,yytext()); } + +"inicio" {return newSym(sym.INICIO,yytext()); } +"fimalgoritmo" {return newSym(sym.FIMALGORITMO,yytext()); } + +"se" {return newSym(sym.SE,yytext()); } +"senao" {return newSym(sym.SENAO,yytext()); } +"fimse" {return newSym(sym.FIMSE,yytext()); } + +"enquanto" {return newSym(sym.ENQUANTO,yytext()); } +"fimenquanto" {return newSym(sym.FIMENQUANTO,yytext()); } + +"para" {return newSym(sym.PARA,yytext()); } +"fimpara" {return newSym(sym.FIMPARA,yytext()); } + +"escolha" {return newSym(sym.ESCOLHA,yytext()); } +"caso" {return newSym(sym.CASO,yytext()); } +"outrocaso" {return newSym(sym.OUTROCASO,yytext()); } +"fimescolha" {return newSym(sym.FIMESCOLHA,yytext()); } + +{newline} {/* IGNORE */} +{whitespace} {/* IGNORE */} +{full} {return newSym(sym.ALL,yytext()); } + +< > {return newSym(sym.EOF);} +. {return newSym(sym.error,yytext()); } \ No newline at end of file diff --git a/src/com/editor/syntax/PortugolSyntaxKit.java b/src/com/editor/syntax/PortugolSyntaxKit.java new file mode 100644 index 0000000..ba1e77a --- /dev/null +++ b/src/com/editor/syntax/PortugolSyntaxKit.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.editor.syntax; + +import com.editor.flex.PortugolFlex; +import de.sciss.syntaxpane.DefaultSyntaxKit; + +/** + * + * @author Andrew + */ +public class PortugolSyntaxKit extends DefaultSyntaxKit { + public PortugolSyntaxKit(){ + super(new PortugolFlex()); + } +} diff --git a/src/com/editor/syntax/propriedades/combocompletions.txt b/src/com/editor/syntax/propriedades/combocompletions.txt new file mode 100644 index 0000000..e1ea522 --- /dev/null +++ b/src/com/editor/syntax/propriedades/combocompletions.txt @@ -0,0 +1,14 @@ +algoritmo +var +caracter +inteiro +real +vetor +logico +inicio +escreva +escreval +enquanto(condicional) faca\n\t// \nfimenquanto +se(condicional) entao\n\t// \nfimse +para variavel de indice1 ate indice2 faca\n\t// \nfimpara +fimalgoritmo \ No newline at end of file diff --git a/src/com/editor/syntax/propriedades/config.properties b/src/com/editor/syntax/propriedades/config.properties new file mode 100644 index 0000000..d6a71bd --- /dev/null +++ b/src/com/editor/syntax/propriedades/config.properties @@ -0,0 +1,119 @@ +Components = de.sciss.syntaxpane.components.PairsMarker, \de.sciss.syntaxpane.components.LineNumbersRuler, \de.sciss.syntaxpane.components.TokenMarker +TokenMarker.TokenTypes = IDENTIFIER, TYPE + + +#SingleColorSelect = true +#RightMarginColumn = 80 +#RightMarginColor = 0xdddddd + +DefaultFont = Monospaced 14 +CaretColor = 0x000000 + +#TokenMarker.Color = 0x646464 +#PairMarker.Color = 0x0B0909 + + +#LineNumbers.RightMargin = 7 +#LineNumbers.Foreground = 0x999999 +#LineNumbers.Background 0x272822 +#LineNumbers.CurrentBack = 0x272822 +LineNumbers.RightMargin = 10 +LineNumbers.Foreground = 0x000000 +LineNumbers.Background 0xf0f0f0 +LineNumbers.CurrentBack = 0xFFFFFF +LineNumbers.YOFFset = -5 +#Style.KEYWORD = 0x66d9ef, 0 +#Style.KEYWORD2 = 0xf92672, 0 +#Style.STRING = 0xe6db74, 0 +#Style.COMMENT = 0x8f908a, 2 +#Style.TYPE = 0xf92672, 0 +#Style.NUMBER = 0xae81ff, 1 + +#Style.DEFAULT = 0xFFFFFF, 0 +#Style.IDENTIFIER = 0xFFFFFF, 0 +#Style.OPERATOR = 0xFFFFFF, 0 + +Style.OPERATOR = 0x000000, 1 +Style.DELIMITER = 0x000000, 1 +Style.KEYWORD = 0x000cff, 0 +Style.KEYWORD2 = 0x000cff, 0 +Style.TYPE = 0x399028, 1 +Style.TYPE2 = 0x000000, 1 +Style.TYPE3 = 0x000000, 3 +Style.STRING = 0xb75c01, 0 +Style.STRING2 = 0xb75c01, 1 +Style.NUMBER = 0x7701b4, 1 +Style.REGEX = 0xcc6600, 0 +Style.IDENTIFIER = 0x000000, 0 +Style.COMMENT = 0x339933, 2 +Style.COMMENT2 = 0x339933, 3 +Style.DEFAULT = 0x000000, 0 +Style.WARNING = 0xCC0000, 0 +Style.ERROR = 0xCC0000, 3 + + + + +Action.indent.WordRegex=\\w+|\\/(\\*)+ + +############# COMPLETE +Action.parenthesis = de.sciss.syntaxpane.actions.PairAction, typed ( +Action.brackets = de.sciss.syntaxpane.actions.PairAction, typed [ +Action.quotes = de.sciss.syntaxpane.actions.PairAction, typed ' +Action.double-quotes = de.sciss.syntaxpane.actions.PairAction, typed " + +############# COMPLETE +Action.combo-completion = de.sciss.syntaxpane.actions.ComboCompletionAction, control SPACE +Action.combo-completion.MenuText = Completar +Action.combo-completion.ItemsURL=${class_path}/combocompletions.txt + +############# LISTAGEM DE SAIDA +Action.surround-debug = de.sciss.syntaxpane.actions.TemplateAction, control Q +Action.surround-debug.MenuText = Comando de saida +Action.surround-debug.ToolTip = Comando de saida escreval +Action.surround-debug.Template = escreval("O valor de #{selection} = " + (#{selection})) + +############# LISTAGEM DE CONDICIONAL +Action.surround-if = de.sciss.syntaxpane.actions.TemplateAction, control E +Action.surround-if.MenuText = Condicional +Action.surround-if.ToolTip = Express\u00f5es Conditional +Action.surround-if.Template = se(#{p:condition}) entao\n #{selection}\nfimse + +############# LISTAGEM DE SE +Action.surround-while = de.sciss.syntaxpane.actions.TemplateAction, control R +Action.surround-while.MenuText = Enquanto loop +Action.surround-while.ToolTip = Selecao de loop enquanto +Action.surround-while.Template = enquanto(#{p:condition}) faca\n #{selection}\nfimenquanto + + +#Action.undo = de.sciss.syntaxpane.actions.UndoAction, menu Z +#Action.undo.MenuText = Voltar + +#Action.redo = de.sciss.syntaxpane.actions.RedoAction, menu Y +#Action.redo.MenuText = Refazer +#JavaSyntaxKit.Action.TOGGLE_LINES = jsyntaxpane.actions.ToggleComponentAction, control F2 +Action.find = de.sciss.syntaxpane.actions.FindReplaceAction, control F + +Action.indent.MenuText = Identar + +DefaultAction.select-all.MenuText = Selecionar tudo +DefaultAction.copy-to-clipboard.MenuText = Copiar +DefaultAction.cut-to-clipboard.MenuText = Recortar +DefaultAction.paste-from-clipboard.MenuText = Colar +DefaultAction.goto-line.MenuText = Ir para linha +DefaultAction.goto-line.ToolTip = Ir para linha + +TextAA = ON + +DEFAULT_EDIT_MENU= \ + cut-to-clipboard , \ + copy-to-clipboard , \ + paste-from-clipboard , \ + - , \ + select-all +PopupMenu = \ + ${DEFAULT_EDIT_MENU} + + +#GotoLineDialog.title=Ir para linha +#GotoLineDialog.jBtnOk.text=Ir \ No newline at end of file diff --git a/src/com/forms/Console.form b/src/com/forms/Console.form new file mode 100644 index 0000000..68c8d0b --- /dev/null +++ b/src/com/forms/Console.form @@ -0,0 +1,104 @@ + + + diff --git a/src/com/forms/Console.java b/src/com/forms/Console.java new file mode 100644 index 0000000..96fa947 --- /dev/null +++ b/src/com/forms/Console.java @@ -0,0 +1,179 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.forms; + +import bsh.EvalError; +import bsh.Interpreter; +import static com.forms.Editor.Threadcode; +import static com.forms.Editor.table_variaveis; +import static com.forms.Editor.util; +import static com.forms.Editor.ConsoleIO; +import com.system.ConsoleIO; +import com.system.TableVariables; +import java.awt.Image; +import java.awt.Toolkit; +import java.net.URL; +import javax.swing.JOptionPane; + +/** + * + * @author Andrew + */ +public class Console extends javax.swing.JDialog { + + + public Console() { + + URL urlicon = Editor.class.getClassLoader().getResource("com/images/pgeditor.png"); + Image icon = Toolkit.getDefaultToolkit().getImage(urlicon); + setIconImage(icon); + + initComponents(); + ConsoleIO = new ConsoleIO(console_txt); + table_variaveis = new TableVariables(jTableVariavel); + + execCode(); + } + + private void execCode() { + + //LISTAGEM DE VARIAVEIS + for (String[] Variavei : util.Variaveis) { + table_variaveis.add(Variavei[0], util.getTipoVariavelJavaToPt(Variavei[1]), null); + } + + //LISTAGEM DE VARIAVEIS DO TIPO VETOR + for (String[] Variavei : util.VariaveisVetor) { + for (int i = new Integer(Variavei[2]); i <= new Integer(Variavei[3]); i++) { + table_variaveis.add(Variavei[0] + "[" + i + "]", util.getTipoVariavelJavaToPt(Variavei[1]), null); + } + } + + Threadcode = new Thread(new Runnable() { + + @Override + public void run() { + + Thread.currentThread().setName("Thread - Interpretador"); + + long startTime = 0; + long endTime = 0; + boolean error = false; + Interpreter i = new Interpreter(); + System.out.println(util.code_exec[0] + util.code_exec[1] + util.code_exec[2]); + try { + startTime = System.currentTimeMillis(); + i.set("ConsoleIO", ConsoleIO); + i.set("table_variaveis", table_variaveis); + i.eval(util.code_exec[0] + util.code_exec[1] + util.code_exec[2]); + } catch (EvalError ex) { + JOptionPane.showMessageDialog(null, "Erro de syntax: Há algum erro critico de syntax no seu código. Linha:" + (ex.getErrorLineNumber() - 1), "Erro de syntax", JOptionPane.WARNING_MESSAGE); + error = true; + } finally { + endTime = System.currentTimeMillis(); + ConsoleIO.println(""); + ConsoleIO.println(""); + if (!error) { + ConsoleIO.print("Programa finalizado. Tempo de duração: " + (endTime - startTime) / 1000 + " segundos", util.AttrColor("codigo_finalizado")); + } else { + ConsoleIO.print("Programa finalizado. Tempo de duração: " + (endTime - startTime) / 1000 + " segundos", util.AttrColor("codigo_finalizado_error")); + } + ConsoleIO.finalizacao(); + + } + } + + }); + Threadcode.start(); + } + + public void close() { + ConsoleIO.interrupt(); + dispose(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jSplitPane1 = new javax.swing.JSplitPane(); + jScrollPane1 = new javax.swing.JScrollPane(); + console_txt = new javax.swing.JTextPane(); + jScrollPane3 = new javax.swing.JScrollPane(); + jTableVariavel = new javax.swing.JTable(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setTitle("Console I/O"); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeWindow(evt); + } + }); + + jSplitPane1.setDividerLocation(600); + jSplitPane1.setResizeWeight(0.5); + + console_txt.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N + console_txt.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); + console_txt.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jScrollPane1.setViewportView(console_txt); + + jSplitPane1.setLeftComponent(jScrollPane1); + + jTableVariavel.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Variável", "Tipo", "Valor" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTableVariavel.setCellSelectionEnabled(true); + jScrollPane3.setViewportView(jTableVariavel); + + jSplitPane1.setRightComponent(jScrollPane3); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 877, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow + // TODO add your handling code here: + close(); + }//GEN-LAST:event_closeWindow + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextPane console_txt; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JTable jTableVariavel; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/forms/Editor.form b/src/com/forms/Editor.form new file mode 100644 index 0000000..73f711a --- /dev/null +++ b/src/com/forms/Editor.form @@ -0,0 +1,407 @@ + + + diff --git a/src/com/forms/Editor.java b/src/com/forms/Editor.java new file mode 100644 index 0000000..519d496 --- /dev/null +++ b/src/com/forms/Editor.java @@ -0,0 +1,929 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.forms; + +import com.classes.util.ExportPDF; +import com.classes.util.FilesOpens; +import com.classes.util.Menssage; +import com.classes.util.MenuSetting; +import com.classes.util.NewTab; +import com.classes.util.OpenFile; +import com.classes.util.SaveSaveAs; +import com.compilador.portugol.Compilador; +import com.compilador.portugol.ExecCompilador; +import com.editor.syntax.PortugolSyntaxKit; +import com.jidesoft.swing.JideTabbedPane; +import com.system.ConsoleIO; +import com.system.TableVariables; +import de.sciss.syntaxpane.DefaultSyntaxKit; +import de.sciss.syntaxpane.actions.DocumentSearchData; +import de.sciss.syntaxpane.components.LineNumbersRuler; +import de.sciss.syntaxpane.util.Configuration; +import de.sciss.syntaxpane.util.JarServiceProvider; +import java.awt.AWTKeyStroke; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.DisplayMode; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.KeyboardFocusManager; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.print.PrinterException; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.Action; +import javax.swing.Box; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; +import javax.swing.KeyStroke; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import net.iharder.dnd.FileDrop; + +/** + * + * @author SIMONETO-2 + */ +public final class Editor extends javax.swing.JFrame { + + //PEGANDO AS DIMENSOES DA TELA + public static Dimension tela = Toolkit.getDefaultToolkit().getScreenSize(); + + //CLASS PARA ABRIR TABS + public static NewTab tab = null; + + //ORGANIZANDO DE ARQUIVOS + public static FilesOpens files_opens = null; + + //IMPORTE DE CONTROLE DOS MENUS + public static MenuSetting setting_menu = null; + + //ACOES PARA ABRIR ARQUIVOS + private static OpenFile _abrir = null; + + //VARIAVEL PARA CONTROLE DE MENUS ENABLEDS + public static boolean enabled_menu = false; + + //VARIAVEL RESPONSAVEL PELO HIDE/SHOW LINE NUMBER + public static boolean line_number = true; + + //VARIAVEL RESPONSAVEL PELA GRAVACAO DO DISPLAY + private DisplayMode dispModeOld = null; + + //VARIAVEL ESTATICA RESPONSAVEL PELA MESANGEM + public static Menssage msg = null; + + //########################################################################### + //# VARIAVEIS ESTATICAS RESPONSAVEIS PELO FUNCIONAMENTO DO INTERPRETADOR # + //########################################################################### + //VARIAVEL RESPONSAVEL POR CRIAR A CHAMADA DA CLASS COMPILADOR + public static Compilador util; + + //VARIAVEL TO THEREAD DE EXECUCAO DO INTERPRETADOR BSH + public static Thread Threadcode; + + //CRIA O STATIC DO CONSOLE_IO + public static ConsoleIO ConsoleIO; + + //CRIA O STATIC DO TABLE_VARIAVEIS + public static TableVariables table_variaveis; + + //########################################################################### + //########################################################################### + //########################################################################### + //ARQUIVO EXTERNO DE CONFIGURAÇÕES + public static File file_setting = new File(System.getProperty("user.dir") + "\\config.properties"); + + //PRIVATE VARIAVEL DE TABS + private JideTabbedPane jTab; + + //VARIAVEL DE OLA MUNDO + private final String algoritmo_dafault = "algoritmo \"Algoritmo - Olá mundo\"\n" + + "\n" + + "inicio\n" + + " escreval(\"Olá mundo\")\n" + + "fimalgoritmo"; + + public Editor() { + initComponents(); + + URL urlicon = Editor.class.getClassLoader().getResource("com/images/logo_icon.png"); + Image icon = Toolkit.getDefaultToolkit().getImage(urlicon); + setIconImage(icon); + + files_opens = new FilesOpens(); + + jTab = new JideTabbedPane(); + jTab.setShowCloseButton(true); + jTab.setShowCloseButtonOnTab(true); + jTab.setTabShape(JideTabbedPane.SHAPE_DEFAULT); + jTab.setColorTheme(JideTabbedPane.COLOR_THEME_WINXP); + + //AÇÃO DE FECHAMENTO DAS TABS + jTab.setCloseAction(new Action() { + + @Override + public Object getValue(String key) { + return null; + } + + @Override + public void putValue(String key, Object value) { + } + + @Override + public void setEnabled(boolean b) { + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void actionPerformed(ActionEvent e) { + Component b = (Component) e.getSource(); + int id = new Integer(b.getName()); + int index = files_opens.getPositionItem(id); + tab.unistallTab(id); + jTab.remove(index); + } + }); + + /*jTab.setTabHistoryEnabled(true); + jTab.setCloseButtonStrategy(CloseButtonStrategy.ALL_TABS); + jTab.setTabOverviewEnabled(false); + jTab.setPaintSelectedTabBold(true); + jTab.setTabReorderByDraggingEnabled(false); + + jTab.setTabStyle(JYTabbedPane.TabStyle.SELECTED_TAB_ONLY); + + jTab.getActionMap().put("closeTab", new Tab.CloseTabAction() { + @Override + public void actionPerformed(ActionEvent evt) { + AbstractButton closeButton = (AbstractButton) evt.getSource(); + Tab _tab = (Tab) closeButton.getParent().getParent(); + int tabIndex = _tab.getTabIndex(); + + String id = jTab.getComponentAt(tabIndex).getName(); + tab.unistallTab(new Integer(id)); + + System.out.println("Tab fechada com sucesso. ID:" + id); + super.actionPerformed(evt); + } + }); + */ + jTab.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (jTab.getTabCount() > 1) { + DefaultSyntaxKit kit = (DefaultSyntaxKit) tab.getEditorPane().getEditorKit(); + if (line_number) { + if (!kit.isComponentInstalled(tab.getEditorPane(), LineNumbersRuler.class.getName())) { + kit.installComponent(tab.getEditorPane(), LineNumbersRuler.class.getName()); + } + } else { + if (kit.isComponentInstalled(tab.getEditorPane(), LineNumbersRuler.class.getName())) { + kit.deinstallComponent(tab.getEditorPane(), LineNumbersRuler.class.getName()); + } + } + } + } + }); + + painelTab.setLayout(new BorderLayout()); + painelTab.add(jTab); + + DefaultSyntaxKit.registerContentType("text/portugol", PortugolSyntaxKit.class.getCanonicalName()); + + Configuration conf = DefaultSyntaxKit.getConfig(PortugolSyntaxKit.class); + + String url = "com/editor/syntax/propriedades/config"; + Properties p = JarServiceProvider.readProperties(url); + conf.putAll(p); + + if (file_setting.exists()) { + InputStream leitura = null; + try { + leitura = new FileInputStream(file_setting); + Properties prop = new Properties(); + prop.load(leitura); + conf.putAll(prop); + } catch (FileNotFoundException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IOException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } finally { + try { + leitura.close(); + } catch (IOException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + tab = new NewTab(jTab); + setupTabTraversalKeys(jTab); + //setting_menu = new MenuSetting(jMenuBar); + + //JMenuItem2 (ABRIR ARQUIVO) + _abrir = new OpenFile(jMenuItem2); + //jMenuItem4 , jMenuItem3 SAVE E SAVE AS + SaveSaveAs _save = new SaveSaveAs(jMenuItem4, jMenuItem3); + //MENU DESABILITADO + //setting_menu.setDisabledTop(enabled_menu); + + //ABRE A PRIMEIRA TAB + tab.addTab("Olá mundo", "", algoritmo_dafault); + + //DRAG AND DROP DE ARQUIVOS + FileDrop dropScrollPane = new FileDrop(jTab, _drop); + FileDrop dropEditorPane = new FileDrop(tab.getEditorPane(), _drop); + + //INICIA AS MENSAGENS + msg = new Menssage(label_msg); + } + + FileDrop.Listener _drop = new FileDrop.Listener() { + @Override + public void filesDropped(java.io.File[] files) { + for (File file : files) { + String extensao = getFileExtension(file); + if (".alg".equals(extensao) || ".txt".equals(extensao)) { + if (!files_opens.isExistingOpen(file.getAbsoluteFile().toString())) { + try { + tab.addTab(file.getName(), file.getAbsoluteFile().toString(), _abrir.readFile(file.toString(), Charset.defaultCharset())); + tab.getEditorPane().setCaretPosition(0); + System.out.println("Arquivo " + file.getName() + " foi aberto com sucesso."); + } catch (IOException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } + } else { + tab.setSelectedIndex(files_opens.getPositionItem(file.getAbsoluteFile().toString())); + } + } else { + JOptionPane.showMessageDialog(null, "Tipo de arquivo não suportado.", "Alerta", JOptionPane.WARNING_MESSAGE); + } + } + } + }; + + private String getFileExtension(File file) { + String name = file.getName(); + int lastIndexOf = name.lastIndexOf("."); + if (lastIndexOf == -1) { + return ""; // empty extension + } + return name.substring(lastIndexOf); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + ////GEN-BEGIN:initComponents + private void initComponents() { + + jPopupMenu_console = new javax.swing.JPopupMenu(); + jMenuItem21 = new javax.swing.JMenuItem(); + jMenuItem18 = new javax.swing.JMenuItem(); + painelTab = new javax.swing.JPanel(); + jSplitPane1 = new javax.swing.JSplitPane(); + linha_coluna_txt = new javax.swing.JLabel(); + label_msg = new javax.swing.JLabel(); + jMenuBar = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenuItem2 = new javax.swing.JMenuItem(); + jSeparator1 = new javax.swing.JPopupMenu.Separator(); + jMenuItem4 = new javax.swing.JMenuItem(); + jMenuItem3 = new javax.swing.JMenuItem(); + jSeparator2 = new javax.swing.JPopupMenu.Separator(); + jMenu6 = new javax.swing.JMenu(); + jMenuItem15 = new javax.swing.JMenuItem(); + jSeparator7 = new javax.swing.JPopupMenu.Separator(); + jMenuItem6 = new javax.swing.JMenuItem(); + jSeparator3 = new javax.swing.JPopupMenu.Separator(); + jMenuItem5 = new javax.swing.JMenuItem(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem7 = new javax.swing.JMenuItem(); + jMenuItem8 = new javax.swing.JMenuItem(); + jSeparator4 = new javax.swing.JPopupMenu.Separator(); + jMenuItem9 = new javax.swing.JMenuItem(); + jMenuItem10 = new javax.swing.JMenuItem(); + jMenuItem11 = new javax.swing.JMenuItem(); + jSeparator5 = new javax.swing.JPopupMenu.Separator(); + jMenuItem12 = new javax.swing.JMenuItem(); + jSeparator6 = new javax.swing.JPopupMenu.Separator(); + jMenuItem13 = new javax.swing.JMenuItem(); + jMenuItem14 = new javax.swing.JMenuItem(); + jMenu3 = new javax.swing.JMenu(); + jMenuItem16 = new javax.swing.JCheckBoxMenuItem(); + jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem(); + jMenu4 = new javax.swing.JMenu(); + jMenuItem17 = new javax.swing.JMenuItem(); + jMenu7 = new javax.swing.JMenu(); + jMenuItem20 = new javax.swing.JMenuItem(); + jMenu5 = new javax.swing.JMenu(); + jMenuItem19 = new javax.swing.JMenuItem(); + jMenu8 = new javax.swing.JMenu(); + + jMenuItem21.setText("Limpar console"); + jMenuItem21.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cleanConsole(evt); + } + }); + jPopupMenu_console.add(jMenuItem21); + + jMenuItem18.setText("jMenuItem18"); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Portugol Editor (v1.0.0) @alpha"); + setForeground(java.awt.Color.white); + + javax.swing.GroupLayout painelTabLayout = new javax.swing.GroupLayout(painelTab); + painelTab.setLayout(painelTabLayout); + painelTabLayout.setHorizontalGroup( + painelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 740, Short.MAX_VALUE) + ); + painelTabLayout.setVerticalGroup( + painelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 455, Short.MAX_VALUE) + ); + + jSplitPane1.setBorder(null); + jSplitPane1.setDividerSize(0); + jSplitPane1.setResizeWeight(0.5); + + linha_coluna_txt.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + linha_coluna_txt.setText("-"); + jSplitPane1.setLeftComponent(linha_coluna_txt); + + label_msg.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + label_msg.setText("-"); + jSplitPane1.setRightComponent(label_msg); + + jMenu1.setText("Arquivo"); + + jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem1.setText("Novo"); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + NewProject(evt); + } + }); + jMenu1.add(jMenuItem1); + + jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem2.setText("Abrir"); + jMenu1.add(jMenuItem2); + jMenu1.add(jSeparator1); + + jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem4.setText("Salvar"); + jMenu1.add(jMenuItem4); + + jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem3.setText("Salvar como"); + jMenu1.add(jMenuItem3); + jMenu1.add(jSeparator2); + + jMenu6.setText("Exportar como"); + + jMenuItem15.setText("PDF"); + jMenuItem15.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ExportPDF(evt); + } + }); + jMenu6.add(jMenuItem15); + + jMenu1.add(jMenu6); + jMenu1.add(jSeparator7); + + jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem6.setText("Imprimir"); + jMenuItem6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ImprirTab(evt); + } + }); + jMenu1.add(jMenuItem6); + jMenu1.add(jSeparator3); + + jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK)); + jMenuItem5.setText("Fechar"); + jMenuItem5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + fechar_program(evt); + } + }); + jMenu1.add(jMenuItem5); + + jMenuBar.add(jMenu1); + + jMenu2.setText("Editar"); + + jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem7.setText("Desfazer"); + jMenuItem7.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + undoAction(evt); + } + }); + jMenu2.add(jMenuItem7); + + jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem8.setText("Refazer"); + jMenuItem8.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + redoAction(evt); + } + }); + jMenu2.add(jMenuItem8); + jMenu2.add(jSeparator4); + + jMenuItem9.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem9.setText("Recortar"); + jMenuItem9.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + RecortarAction(evt); + } + }); + jMenu2.add(jMenuItem9); + + jMenuItem10.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem10.setText("Copiar"); + jMenuItem10.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CopiarAction(evt); + } + }); + jMenu2.add(jMenuItem10); + + jMenuItem11.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem11.setText("Colar"); + jMenuItem11.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ColarAction(evt); + } + }); + jMenu2.add(jMenuItem11); + jMenu2.add(jSeparator5); + + jMenuItem12.setText("Aplicar identação"); + jMenuItem12.setEnabled(false); + jMenu2.add(jMenuItem12); + jMenu2.add(jSeparator6); + + jMenuItem13.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem13.setText("Selecionar tudo"); + jMenuItem13.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + SelectAll(evt); + } + }); + jMenu2.add(jMenuItem13); + + jMenuItem14.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem14.setText("Localizar e substituir"); + jMenuItem14.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + LocalizarESubstituir(evt); + } + }); + jMenu2.add(jMenuItem14); + + jMenuBar.add(jMenu2); + + jMenu3.setText("Exibir"); + + jMenuItem16.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F12, 0)); + jMenuItem16.setSelected(true); + jMenuItem16.setText("Numero de linhas"); + jMenuItem16.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + NumberLineAction(evt); + } + }); + jMenu3.add(jMenuItem16); + + jCheckBoxMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F11, 0)); + jCheckBoxMenuItem1.setText("Exibir em tela cheia"); + jCheckBoxMenuItem1.setEnabled(false); + jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + toggleFullScreen(evt); + } + }); + jMenu3.add(jCheckBoxMenuItem1); + + jMenuBar.add(jMenu3); + + jMenu4.setText("Algoritmo"); + + jMenuItem17.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F9, 0)); + jMenuItem17.setText("Executar"); + jMenuItem17.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + PlayToCode(evt); + } + }); + jMenu4.add(jMenuItem17); + + jMenuBar.add(jMenu4); + + jMenu7.setText("Ferramentas"); + + jMenuItem20.setText("Opções"); + jMenuItem20.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + showOpcoes(evt); + } + }); + jMenu7.add(jMenuItem20); + + jMenuBar.add(jMenu7); + + jMenu5.setText("Ajuda"); + + jMenuItem19.setText("Sobre"); + jMenuItem19.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + sobre(evt); + } + }); + jMenu5.add(jMenuItem19); + + jMenuBar.add(jMenu5); + + jMenu8.setText("Relatar bug"); + jMenu8.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + relatarBug(evt); + } + }); + + jMenuBar.add(Box.createHorizontalGlue()); + + jMenuBar.add(jMenu8); + + setJMenuBar(jMenuBar); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(painelTab, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jSplitPane1) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(painelTab, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void NewProject(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewProject + /* NEW PROJECT */ + String print_name = (tab.tabs_criadas != 0) ? "" + tab.tabs_criadas : ""; + tab.addTab("semnome" + print_name, "", algoritmo_dafault); + }//GEN-LAST:event_NewProject + + private void fechar_program(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fechar_program + // TODO add your handling code here: + System.exit(0); + }//GEN-LAST:event_fechar_program + + private void ImprirTab(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImprirTab + // TODO add your handling code here: + boolean done; + try { + done = tab.getEditorPane().print(); + } catch (PrinterException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_ImprirTab + + private void ExportPDF(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportPDF + ExportPDF e = new ExportPDF(jMenuItem15); + }//GEN-LAST:event_ExportPDF + + private void undoAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undoAction + // TODO add your handling code here: + de.sciss.syntaxpane.SyntaxDocument t = ((de.sciss.syntaxpane.SyntaxDocument) tab.getEditorPane().getDocument()); + if (t.canUndo()) { + t.doUndo(); + } + //jMenuItem7.setEnabled(t.canUndo()); + }//GEN-LAST:event_undoAction + + private void redoAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redoAction + // TODO add your handling code here: + de.sciss.syntaxpane.SyntaxDocument t = ((de.sciss.syntaxpane.SyntaxDocument) tab.getEditorPane().getDocument()); + if (t.canRedo()) { + t.doRedo(); + } + //jMenuItem8.setEnabled(t.canUndo()); + }//GEN-LAST:event_redoAction + + private void RecortarAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RecortarAction + // TODO add your handling code here: + tab.getEditorPane().cut(); + }//GEN-LAST:event_RecortarAction + + private void CopiarAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CopiarAction + // TODO add your handling code here: + tab.getEditorPane().copy(); + }//GEN-LAST:event_CopiarAction + + private void ColarAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ColarAction + // TODO add your handling code here: + tab.getEditorPane().paste(); + }//GEN-LAST:event_ColarAction + + private void SelectAll(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectAll + // TODO add your handling code here: + tab.getEditorPane().selectAll(); + }//GEN-LAST:event_SelectAll + + private void LocalizarESubstituir(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LocalizarESubstituir + // TODO add your handling code here: + DocumentSearchData dsd = DocumentSearchData.getFromEditor(tab.getEditorPane()); + dsd.showReplaceDialog(tab.getEditorPane()); + }//GEN-LAST:event_LocalizarESubstituir + + private void cleanConsole(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cleanConsole + // TODO add your handling code here: + //jconsole.setText(null); + }//GEN-LAST:event_cleanConsole + + + private void NumberLineAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NumberLineAction + // TODO add your handling code here: + DefaultSyntaxKit kit = (DefaultSyntaxKit) tab.getEditorPane().getEditorKit(); + boolean selected = jMenuItem16.getModel().isSelected(); + + if (selected) { + if (!kit.isComponentInstalled(tab.getEditorPane(), LineNumbersRuler.class.getName())) { + kit.installComponent(tab.getEditorPane(), LineNumbersRuler.class.getName()); + } + line_number = true; + } else { + if (kit.isComponentInstalled(tab.getEditorPane(), LineNumbersRuler.class.getName())) { + kit.deinstallComponent(tab.getEditorPane(), LineNumbersRuler.class.getName()); + } + line_number = false; + } + }//GEN-LAST:event_NumberLineAction + + private void PlayToCode(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PlayToCode + // TODO add your handling code here: + ExecCompilador compilar = new ExecCompilador(); + }//GEN-LAST:event_PlayToCode + + private void sobre(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sobre + // TODO add your handling code here: + Sobre about = new Sobre(this, true); + about.setLocation((tela.width - about.getSize().width) / 2, (tela.height - about.getSize().height) / 2); + about.setVisible(true); + }//GEN-LAST:event_sobre + + + private void showOpcoes(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showOpcoes + // TODO add your handling code here: + Opcoes setting = new Opcoes(this, true); + setting.setLocation((tela.width - setting.getSize().width) / 2, (tela.height - setting.getSize().height) / 2); + setting.setVisible(true); + }//GEN-LAST:event_showOpcoes + + private void toggleFullScreen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toggleFullScreen + // TODO add your handling code here: + boolean selected = jCheckBoxMenuItem1.getModel().isSelected(); + + if (selected) { + setFullscreen(true); + } else { + setFullscreen(false); + } + }//GEN-LAST:event_toggleFullScreen + + private void relatarBug(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_relatarBug + // TODO add your handling code here: + RelatarBug bug = new RelatarBug(this, true); + bug.setLocation((tela.width - bug.getSize().width) / 2, (tela.height - bug.getSize().height) / 2); + bug.setVisible(true); + }//GEN-LAST:event_relatarBug + + /** + * Method allows changing whether this window is displayed in fullscreen or + * windowed mode. + * + * @param fullscreen true = change to fullscreen, false = change to windowed + * http://stackoverflow.com/questions/4462454/java-full-screen-program-swing-tab-alt-f4 + */ + public void setFullscreen(boolean fullscreen) { + //get a reference to the device. + GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + DisplayMode dispMode = device.getDisplayMode(); + //save the old display mode before changing it. + dispModeOld = device.getDisplayMode(); + + if (!fullscreen) { + //change to windowed mode. + //set the display mode back to the what it was when + //the program was launched. + device.setDisplayMode(dispModeOld); + //hide the frame so we can change it. + setVisible(false); + //remove the frame from being displayable. + dispose(); + //put the borders back on the frame. + setUndecorated(false); + //needed to unset this window as the fullscreen window. + device.setFullScreenWindow(null); + //recenter window + setLocationRelativeTo(null); + setResizable(true); + + //reset the display mode to what it was before + //we changed it. + setVisible(true); + + } else { //change to fullscreen. + //hide everything + setVisible(false); + //remove the frame from being displayable. + dispose(); + //remove borders around the frame + setUndecorated(true); + //make the window fullscreen. + device.setFullScreenWindow(this); + //attempt to change the screen resolution. + device.setDisplayMode(dispMode); + setResizable(false); + setAlwaysOnTop(false); + //show the frame + setVisible(true); + } + //make sure that the screen is refreshed. + repaint(); + } + + + /* + * CHANGE TABS COM O CTRL+TAB + */ + private static void setupTabTraversalKeys(JTabbedPane tabbedPane) { + KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB"); + KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB"); + + // Remove ctrl-tab from normal focus traversal + SetforwardKeys = new HashSet<>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); + forwardKeys.remove(ctrlTab); + tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys); + + // Remove ctrl-shift-tab from normal focus traversal + Set backwardKeys = new HashSet<>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); + backwardKeys.remove(ctrlShiftTab); + tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys); + + // Add keys to the tab's input map + InputMap inputMap = tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + inputMap.put(ctrlTab, "navigateNext"); + inputMap.put(ctrlShiftTab, "navigatePrevious"); + } + + public static void main(String arg[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + + DefaultSyntaxKit.initKit(); + + //try { + //WebLookAndFeel.install(); + //if (System.getProperty("os.name").toLowerCase().contains("win")) { + //UIManager.put("Synthetica.window.decoration", Boolean.FALSE); + //} else { + // UIManager.put("Synthetica.window.decoration", Boolean.FALSE); + //} + //UIManager.put("Synthetica.focus.textComponents.enabled", Boolean.FALSE); + /*try { + UIManager.setLookAndFeel(new SyntheticaWhiteVisionLookAndFeel()); + } catch (ParseException | UnsupportedLookAndFeelException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + }*/ + /* UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceNebulaLookAndFeel"); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + }*/ + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } + + //UIManager.put("Synthetica.window.opaque", false); + //UIManager.put("Synthetica.window.shape", ""); + Editor Editor = new Editor(); + Editor.setLocation((tela.width - Editor.getSize().width) / 2, (tela.height - Editor.getSize().height) / 2); + Editor.setExtendedState(Editor.MAXIMIZED_BOTH); + Editor.setVisible(true); + + } + }); + + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; + private javax.swing.JMenu jMenu5; + private javax.swing.JMenu jMenu6; + private javax.swing.JMenu jMenu7; + private javax.swing.JMenu jMenu8; + private javax.swing.JMenuBar jMenuBar; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem10; + private javax.swing.JMenuItem jMenuItem11; + private javax.swing.JMenuItem jMenuItem12; + private javax.swing.JMenuItem jMenuItem13; + private javax.swing.JMenuItem jMenuItem14; + private javax.swing.JMenuItem jMenuItem15; + private javax.swing.JCheckBoxMenuItem jMenuItem16; + private javax.swing.JMenuItem jMenuItem17; + private javax.swing.JMenuItem jMenuItem18; + private javax.swing.JMenuItem jMenuItem19; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JMenuItem jMenuItem20; + private javax.swing.JMenuItem jMenuItem21; + private javax.swing.JMenuItem jMenuItem3; + private javax.swing.JMenuItem jMenuItem4; + private javax.swing.JMenuItem jMenuItem5; + private javax.swing.JMenuItem jMenuItem6; + private javax.swing.JMenuItem jMenuItem7; + private javax.swing.JMenuItem jMenuItem8; + private javax.swing.JMenuItem jMenuItem9; + private javax.swing.JPopupMenu jPopupMenu_console; + private javax.swing.JPopupMenu.Separator jSeparator1; + private javax.swing.JPopupMenu.Separator jSeparator2; + private javax.swing.JPopupMenu.Separator jSeparator3; + private javax.swing.JPopupMenu.Separator jSeparator4; + private javax.swing.JPopupMenu.Separator jSeparator5; + private javax.swing.JPopupMenu.Separator jSeparator6; + private javax.swing.JPopupMenu.Separator jSeparator7; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JLabel label_msg; + public static javax.swing.JLabel linha_coluna_txt; + private javax.swing.JPanel painelTab; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/forms/LocalizarSubstituir.form b/src/com/forms/LocalizarSubstituir.form new file mode 100644 index 0000000..4e0e780 --- /dev/null +++ b/src/com/forms/LocalizarSubstituir.form @@ -0,0 +1,215 @@ + + + diff --git a/src/com/forms/LocalizarSubstituir.java b/src/com/forms/LocalizarSubstituir.java new file mode 100644 index 0000000..e553bba --- /dev/null +++ b/src/com/forms/LocalizarSubstituir.java @@ -0,0 +1,358 @@ +package com.forms; + +import static com.forms.Editor.tab; +import java.awt.HeadlessException; +import java.awt.Rectangle; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.JOptionPane; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author SIMONETO-2 + */ +public class LocalizarSubstituir extends javax.swing.JFrame { + + private int pos = 0; + private int pos_reg = 0; + private String tmp_search = ""; + private boolean search = false; + private boolean replaceAllResult = true; + + /** + * Creates new form LocalizarSubstituir + */ + public LocalizarSubstituir() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + find_txt = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + replace_txt = new javax.swing.JTextArea(); + btn_buscar = new javax.swing.JButton(); + btn_replace = new javax.swing.JButton(); + btn_replaceAll = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + jCheckBox1 = new javax.swing.JCheckBox(); + jCheckBox2 = new javax.swing.JCheckBox(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Localizar e substituir"); + setResizable(false); + + jLabel1.setText("Encontrar:"); + + find_txt.setColumns(20); + find_txt.setRows(2); + find_txt.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + TabFocus1(evt); + } + }); + jScrollPane1.setViewportView(find_txt); + + jLabel2.setText("Substituir:"); + + replace_txt.setColumns(20); + replace_txt.setRows(2); + replace_txt.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + TabFocus2(evt); + } + }); + jScrollPane2.setViewportView(replace_txt); + + btn_buscar.setText("Buscar"); + btn_buscar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + FindAction(evt); + } + }); + + btn_replace.setText("Substituir"); + btn_replace.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ReplaceAction(evt); + } + }); + + btn_replaceAll.setText("Substituir todos"); + btn_replaceAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + replaceAllAction(evt); + } + }); + + jLabel3.setText("Opções:"); + + jCheckBox1.setSelected(true); + jCheckBox1.setText("Usar expressão regular"); + + jCheckBox2.setText("Diferenciar maiuscula de minuscula"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jCheckBox2) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jCheckBox1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) + .addComponent(jScrollPane2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(btn_replaceAll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) + .addComponent(btn_replace, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btn_buscar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addContainerGap()))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(btn_buscar) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btn_replace) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btn_replaceAll))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jCheckBox1) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCheckBox2) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void TabFocus1(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TabFocus1 + // TODO add your handling code here: + if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_TAB) { + replace_txt.requestFocus(); + evt.consume(); + } + }//GEN-LAST:event_TabFocus1 + + private void TabFocus2(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TabFocus2 + // TODO add your handling code here: + if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_TAB) { + btn_buscar.requestFocus(); + evt.consume(); + } + }//GEN-LAST:event_TabFocus2 + + private void FindAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindAction + // TODO add your handling code here: + find_text(find_txt.getText()); + }//GEN-LAST:event_FindAction + + private void ReplaceAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReplaceAction + // TODO add your handling code here: + if (search == false) { + find_text(find_txt.getText()); + } + replace_text(replace_txt.getText()); + }//GEN-LAST:event_ReplaceAction + + private void replaceAllAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceAllAction + // TODO add your handling code here: + while(replaceAllResult){ + if (search == false) { + find_text(find_txt.getText()); + } + replace_text(replace_txt.getText()); + } + }//GEN-LAST:event_replaceAllAction + + public void replace_text(String replace) { + if (replace != null && replace.length() > 0) { + if (search != false) { + System.out.println("[Sistema~] > Texto \"" + find_txt.getText() + "\" foi substituído por \"" + replace + "\"."); + tab.getEditorPane().replaceSelection(replace); + search = false; + } + } + } + + public void find_text(String find) { + + search = false; + + String texto = find; + + if (jCheckBox2.isSelected() == false) { + texto = texto.toLowerCase(); + } + + if (texto != null && texto.length() > 0) { + Document document = tab.getEditorPane().getDocument(); + int findLength = texto.length(); + + if (!tmp_search.equals(texto)) { + pos = 0; + tmp_search = ""; + } + + try { + boolean found = false; + // Rest the search position if we're at the end of the document + tmp_search = texto; + + if (!jCheckBox1.isSelected()) { + if (pos + findLength > document.getLength()) { + pos = 0; + } + // While we haven't reached the end... + // "<=" Correction + while (pos + findLength <= document.getLength()) { + // Extract the text from teh docuemnt + String match = null; + if (jCheckBox2.isSelected() == false) { + match = document.getText(pos, findLength).toLowerCase(); + + } else { + match = document.getText(pos, findLength); + } + + // Check to see if it matches or request + if (match.equals(texto)) { + found = true; + break; + } + pos++; + } + } else { + + String match = document.getText(0, document.getLength()); + + Pattern p = null; + if (!jCheckBox2.isSelected()) { + p = Pattern.compile(find, Pattern.CASE_INSENSITIVE); + } else { + p = Pattern.compile(find); + } + + Matcher m = p.matcher(match); + + int count = 0; + while (m.find()) { + count++; + } + + if (pos_reg >= count) { + pos = 0; + pos_reg = 0; + } + + if (m.find(pos)) { + pos = m.start(0); + findLength = m.group(0).length(); + pos_reg++; + found = true; + } + } + + // Did we find something... + if (found) { + // Get the rectangle of the where the text would be visible... + Rectangle viewRect = tab.getEditorPane().modelToView(pos); + // Scroll to make the rectangle visible + tab.getEditorPane().scrollRectToVisible(viewRect); + // Highlight the text + tab.getEditorPane().setCaretPosition(pos + findLength); + tab.getEditorPane().moveCaretPosition(pos); + // Move the search position beyond the current match + + pos += findLength; + + search = true; + } else { + //JOptionPane.showMessageDialog(null, "Nenhuma ocorrência foi encontrada", "Alerta", JOptionPane.WARNING_MESSAGE); + replaceAllResult = false; + } + + } catch (BadLocationException | HeadlessException exp) { + } + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btn_buscar; + private javax.swing.JButton btn_replace; + private javax.swing.JButton btn_replaceAll; + private javax.swing.JTextArea find_txt; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JCheckBox jCheckBox2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTextArea replace_txt; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/forms/Opcoes.form b/src/com/forms/Opcoes.form new file mode 100644 index 0000000..98e85d7 --- /dev/null +++ b/src/com/forms/Opcoes.form @@ -0,0 +1,296 @@ + + + diff --git a/src/com/forms/Opcoes.java b/src/com/forms/Opcoes.java new file mode 100644 index 0000000..2aa073b --- /dev/null +++ b/src/com/forms/Opcoes.java @@ -0,0 +1,817 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.forms; + +import com.classes.util.JFontChooser; +import com.editor.syntax.PortugolSyntaxKit; +import static com.forms.Editor.file_setting; +import static com.forms.Editor.tab; +import de.sciss.syntaxpane.DefaultSyntaxKit; +import de.sciss.syntaxpane.components.LineNumbersRuler; +import de.sciss.syntaxpane.util.Configuration; +import de.sciss.syntaxpane.util.JarServiceProvider; +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JSlider; +import javax.swing.JSpinner; +import javax.swing.colorchooser.AbstractColorChooserPanel; + +/** + * + * @author SIMONETO-2 + */ +public class Opcoes extends javax.swing.JDialog { + + //CRIANDO A CLASS PARA LEITURA DO KIT + private PortugolSyntaxKit kit = null; + + //ESTANCIANDO OS CHOOSER + private final JFontChooser fc = new JFontChooser(); + private final JColorChooser cc = new JColorChooser(); + + //ARRAY COM AS KEYS DE CORES + private final String key[] = {"Style.IDENTIFIER", "Style.KEYWORD", "Style.KEYWORD2", "Style.TYPE", "Style.STRING", "Style.NUMBER", "Style.OPERATOR"}; + + //ONDE SERA ARMAZENADO AS CONFIGURACOES JA PRE-CARREGADAS + private final ArrayListconfiguracoes_originais = new ArrayList<>(); + + //ONDE SERA ARMAZENADO AS CONFIGURACOES DA CLASSE INTERNA + private final ArrayList configuracoes_originais_internas = new ArrayList<>(); + + //CRIADO NO QUAL SERA ARMAZENADO AS MODIFICACOES + private final ArrayList modificacoes = new ArrayList<>(); + + //PARA A CONFIGURACAO DA FONTE + private Font fonte_padrao = null; + private boolean font_editada = false; + + //ALGORITMO DE EXEMPLO + private final String txt_amostra = "/*\n" + + "* ALGORITMO DE AMOSTRA\n" + + "*/\n" + + "algoritmo \"Loop - tipo enquanto\"\n" + + "\n" + + "var loop : inteiro\n" + + "\n" + + "inicio\n" + + " loop <- 1\n" + + " enquanto loop <= 10 faca\n" + + " escreval(loop)\n" + + " espere(1000)\n" + + " loop <- loop + 1\n" + + " fimenquanto\n" + + "fimalgoritmo"; + + /** + * Creates new form Opcoes + * + * @param parent + * @param modal + */ + public Opcoes(java.awt.Frame parent, boolean modal) { + super(parent, modal); + + initComponents(); + + //PEGANDO AS CONFIGURACOES DA CLASS INTERNA + String url = "com/editor/syntax/propriedades/config"; + Properties p = JarServiceProvider.readProperties(url); + for (String retorno : key) { + configuracoes_originais_internas.add(retorno.replaceAll("\\s+", "") + "," + p.getProperty(retorno).replaceAll("\\s+", "")); + } + + //SETANDO ESTILO DO EDITOR + editor_amostra.setContentType("text/portugol"); + + //PEGANDO OS ESTILOS PRE-CARREGADOS + kit = (PortugolSyntaxKit) editor_amostra.getEditorKit(); + kit.deinstallComponent(editor_amostra, LineNumbersRuler.class.getName()); + + //SETANDO O ALGORITMO DE EXEMPLO + editor_amostra.setText(txt_amostra); + + //LENDO CONFIGURACOES DO KIT + getDataKit(); + + /* + * FONT LOAD + */ + getDataFontKit(); + + //DANDO O REQUEST FOCUS NA LISTAGEM DE CORES PARA EVITAR O BUG DE SELECAO DE COLERES SEM A LISTAGEM ESTAR SELECIONADA + list_categoria.requestFocus(); + //SELECIONANDO O PRIMEIRO + list_categoria.setSelectedIndex(0); + } + + private void getDataKit() { + System.out.println("Configuracoes padrão:"); + int i = 0; + for (String retorno : key) { + configuracoes_originais.add(retorno.replaceAll("\\s+", "") + "," + kit.getProperty(retorno).replaceAll("\\s+", "")); + System.out.println("Indice (" + i + "): " + retorno + "," + kit.getProperty(retorno)); + i++; + } + } + + private void getDataFontKit() { + //PEGANDO AS CONFIGURACOES LIDAS + String font[] = kit.getProperty("DefaultFont").split("\\s"); + //SETANDO NO TEXTO DE FONTE + font_txt.setText(font[0] + ", " + font[1]); + //CRIANDO A FONTE + Font t = new Font(font[0], 0, new Integer(font[1])); + fonte_padrao = t; + //DEIXANDO A FONTE SELECIONADA NO CHOOSER + fc.setSelectedFont(t); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + font_txt = new javax.swing.JTextField(); + jButton2 = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + list_categoria = new javax.swing.JList(); + btn_chooserColor = new javax.swing.JButton(); + panel_cor = new javax.swing.JPanel(); + jCheckBox1 = new javax.swing.JCheckBox(); + jCheckBox2 = new javax.swing.JCheckBox(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane3 = new javax.swing.JScrollPane(); + editor_amostra = new javax.swing.JEditorPane(); + jButton3 = new javax.swing.JButton(); + btn_ok = new javax.swing.JButton(); + btn_aplicar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setTitle("Opções"); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + windowsClosing(evt); + } + }); + + jLabel1.setText("Fonte do editor:"); + + font_txt.setDisabledTextColor(new java.awt.Color(51, 51, 51)); + font_txt.setEnabled(false); + + jButton2.setText("..."); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + openFontChooser(evt); + } + }); + + jLabel2.setText("Categoria:"); + + list_categoria.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Padrão", "Palavra-chave 1 (estrutural)", "Palavra-chave 2 (funções)", "Declaração de variáveis", "String e caracteres", "Numeros", "Operações" }; + public int getSize() { return strings.length; } + public Object getElementAt(int i) { return strings[i]; } + }); + list_categoria.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + actionSelect(evt); + } + }); + jScrollPane2.setViewportView(list_categoria); + + btn_chooserColor.setText("Redefinir cor"); + btn_chooserColor.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + colorChooser(evt); + } + }); + + javax.swing.GroupLayout panel_corLayout = new javax.swing.GroupLayout(panel_cor); + panel_cor.setLayout(panel_corLayout); + panel_corLayout.setHorizontalGroup( + panel_corLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 172, Short.MAX_VALUE) + ); + panel_corLayout.setVerticalGroup( + panel_corLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + + jCheckBox1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N + jCheckBox1.setText("Negrito"); + jCheckBox1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + updateBold(evt); + } + }); + + jCheckBox2.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N + jCheckBox2.setText("Itáilico"); + jCheckBox2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + updateItalic(evt); + } + }); + + jLabel3.setText("Amostra:"); + + editor_amostra.setEditable(false); + jScrollPane3.setViewportView(editor_amostra); + + jButton3.setText("Cancelar"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cancelAction(evt); + } + }); + + btn_ok.setText("Ok"); + btn_ok.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + brn_okAction(evt); + } + }); + + btn_aplicar.setText("Aplicar"); + btn_aplicar.setEnabled(false); + btn_aplicar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + aplicarAcao(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jCheckBox2) + .addComponent(jCheckBox1) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(panel_cor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btn_chooserColor)) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup() + .addComponent(font_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton2)) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel3) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(btn_ok) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btn_aplicar) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton3))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(font_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(btn_chooserColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panel_cor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCheckBox1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCheckBox2) + .addGap(0, 20, Short.MAX_VALUE)) + .addComponent(jScrollPane3)) + .addGap(44, 44, 44)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton3) + .addComponent(btn_aplicar) + .addComponent(btn_ok)) + .addContainerGap()) + ); + + jTabbedPane1.addTab("Editor", jPanel2); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTabbedPane1) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTabbedPane1) + ); + + pack(); + }// //GEN-END:initComponents + + //ABRINDO O FONTE CHOOSER + private void openFontChooser(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openFontChooser + // TODO add your handling code here: + int result = fc.showDialog(null); + if (result == JFontChooser.OK_OPTION) { + Font font = fc.getSelectedFont(); + + font_txt.setText(font.getName() + ", " + font.getSize()); + kit.setProperty("DefaultFont", font.getName() + " " + font.getSize()); + editor_amostra.setFont(font); + System.out.println("Fonte alterada: " + fonte_padrao.getName() + " " + fonte_padrao.getSize() + " -> (" + font.getName() + " " + font.getSize() + ")"); + + if (!fonte_padrao.getName().equals(font.getName()) || fonte_padrao.getSize() != font.getSize()) { + font_editada = true; + } else { + font_editada = false; + } + } + //PARA ATUALIZAR O BOTAO DE APLICAR + checkBtnAplicar(); + }//GEN-LAST:event_openFontChooser + + //ABRINDO O COLOR CHOOSER + private void colorChooser(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooser + // TODO add your handling code here: + String tmp[] = formatPropertiesColors(kit.getProperty(key[list_categoria.getSelectedIndex()])); + Color color_tmp = Color.decode(tmp[0]); + + cc.setColor(color_tmp); + final AbstractColorChooserPanel[] panels = cc.getChooserPanels(); + for (final AbstractColorChooserPanel accp : panels) { + if (!accp.getDisplayName().equals("RGB")) { + cc.removeChooserPanel(accp); + } + } + + try { + removeTransparencySlider(cc); + } catch (Exception ex) { + Logger.getLogger(Opcoes.class.getName()).log(Level.SEVERE, null, ex); + } + + Action setColorAction = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent evt) { + panel_cor.setOpaque(true); + panel_cor.setBackground(cc.getColor()); + updateProperties(key[list_categoria.getSelectedIndex()], "0x" + String.format("%06x", cc.getColor().getRGB() & 0x00FFFFFF), getCheckbox()); + } + }; + + JColorChooser.createDialog(null, "Redefinição de cor", true, cc, setColorAction, null).setVisible(true); + }//GEN-LAST:event_colorChooser + + //PINTANDO O PAINEL DA COR ESPECIFICA DA TOKEN + private void actionSelect(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_actionSelect + // TODO add your handling code here: + /* + * COLOR KEYS + */ + + String tmp[] = formatPropertiesColors(kit.getProperty(key[list_categoria.getSelectedIndex()])); + panel_cor.setOpaque(true); + Color color_tmp = Color.decode(tmp[0]); + panel_cor.setBackground(color_tmp); + + jCheckBox1.setSelected(false); + jCheckBox2.setSelected(false); + + switch (tmp[1]) { + case "1": + jCheckBox1.setSelected(true); + break; + case "2": + jCheckBox2.setSelected(true); + break; + case "3": + jCheckBox1.setSelected(true); + jCheckBox2.setSelected(true); + break; + } + }//GEN-LAST:event_actionSelect + + //UPDATE FONT AO CLICAR NO CHECKBOX + private void updateBold(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateBold + // TODO add your handling code here: + String color = formatPropertiesColors(kit.getProperty(key[list_categoria.getSelectedIndex()]))[0]; + updateProperties(key[list_categoria.getSelectedIndex()], color, getCheckbox()); + }//GEN-LAST:event_updateBold + + //UPDATE FONT AO CLICAR NO CHECKBOX + private void updateItalic(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateItalic + // TODO add your handling code here: + String color = formatPropertiesColors(kit.getProperty(key[list_categoria.getSelectedIndex()]))[0]; + updateProperties(key[list_categoria.getSelectedIndex()], color, getCheckbox()); + }//GEN-LAST:event_updateItalic + + //BOTAO DE CANCELAR AS ACOES + private void cancelAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelAction + // TODO add your handling code here: + closed(); + }//GEN-LAST:event_cancelAction + + //CLOSE WINDOWS + private void windowsClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowsClosing + // TODO add your handling code here: + closed(); + }//GEN-LAST:event_windowsClosing + + //ACAO DO BOTAO APLICAR + private void aplicarAcao(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aplicarAcao + // TODO add your handling code here: + aplicar(); + }//GEN-LAST:event_aplicarAcao + + //ACAO DO BOTAO OK + private void brn_okAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_brn_okAction + if(btn_aplicar.isEnabled()){ + aplicar(); + } + dispose(); + }//GEN-LAST:event_brn_okAction + + //PEGAR UM ESTILO JA MODIFICADO NA ARRAY + // FORMATO [KEY,COLOR,FONTSTYLE] + private String[] getConfiguracaoOriginal(String key) { + String r[] = null; + int i = 0; + if (!configuracoes_originais.isEmpty()) { + while (i < configuracoes_originais.size() && !configuracoes_originais.get(i).split(",")[0].equals(key)) { + i++; + } + r = configuracoes_originais.get(i).split(","); + } + return r; + } + + //FUNCAO RESPONSAVEL POR ATUALIZAR A ARRAY MODIFICACOES + private void updateProperties(String key, String color, String font) { + //PEGANDO A COR E O ESTILO DE FONTE E ARMAZENANDO NA ARRAY + String comparacao[] = getConfiguracaoOriginal(key); + + //FAZ O UPDATE NAS PROPRIEDADES + kit.setProperty(key, color + "," + font); + + //FAZ O UPDATE NA ARRAY MODIFICACOES + updateArrayModificacoes(key, color, font); + + System.out.println("Modifição em " + key + " : " + comparacao[1] + " , " + comparacao[2] + " -> (" + color + " , " + font + ")"); + editor_amostra.updateUI(); + editor_amostra.revalidate(); + editor_amostra.validate(); + + if (comparacao[1].equals(color) && comparacao[2].equals(font)) { + //VERIFICANDO SE A ARRAY NAO ESTA VAZIA + for (int i = 0; i < modificacoes.size(); i++) { + if (modificacoes.get(i).split(",")[0].equals(key)) { + modificacoes.remove(i); + break; + } + } + } + //PARA ATUALIZAR O BOTAO DE APLICAR + checkBtnAplicar(); + + } + + //RESPONSAVEL POR FORMATAR A SETRING E RETORNAR O VALOR SEPARADO + // FORMATO [COLOR,FONTSTYLE] + private String[] formatPropertiesColors(String key) { + String retorno[] = null; + String pattern = "(.*)\\,[ \\t]*(.*)"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(key); + while (m.find()) { + String add[] = {m.group(1).replaceAll("\\s+", ""), m.group(2).replaceAll("\\s+", "")}; + retorno = add; + } + return retorno; + } + + //REPONSAVEL POR ATUALIZAR A ARRAY MODIFICACOES COMPARADO OS VALOR PRE EXISTENTES + private void updateArrayModificacoes(String key, String color, String font) { + if (!modificacoes.isEmpty()) { + int i = 0; + while (i < modificacoes.size() && !modificacoes.get(i).split(",")[0].equals(key)) { + i++; + } + if (i < modificacoes.size()) { + modificacoes.set(i, key + "," + color + "," + font); + } else { + modificacoes.add(key + "," + color + "," + font); + } + } else { + modificacoes.add(key + "," + color + "," + font); + } + } + + //VERIFICANDO OS CHECKBOX + private String getCheckbox() { + String r = null; + boolean strong = jCheckBox1.isSelected(); + boolean italic = jCheckBox2.isSelected(); + + if (strong && italic) { + r = "3"; + } else if (strong && !italic) { + r = "1"; + } else if (!strong && italic) { + r = "2"; + } else { + r = "0"; + } + return r; + } + + //ACAO PARA FECHAMENTO + private void closed() { + if (!modificacoes.isEmpty() || font_editada == true) { + int result = JOptionPane.showConfirmDialog(null, "Deseja salvar as configurações modificadas ?", "Alerta", JOptionPane.YES_NO_OPTION); + if (result == JOptionPane.YES_OPTION) { + aplicar(); + } else { + //RESETA AS CONFIGURACOES (PARTE INTERNA) + Configuration conf = DefaultSyntaxKit.getConfig(PortugolSyntaxKit.class); + String url = "com/editor/syntax/propriedades/config"; + Properties p = JarServiceProvider.readProperties(url); + conf.putAll(p); + + // INCLUI AS CONFIGURACOES (PARTE EXTERNA) + if (file_setting.exists()) { + InputStream leitura = null; + try { + leitura = new FileInputStream(file_setting); + Properties prop = new Properties(); + prop.load(leitura); + conf.putAll(prop); + } catch (FileNotFoundException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IOException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } finally { + try { + leitura.close(); + } catch (IOException ex) { + Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + } + } + dispose(); + } + + //BRN APLICAR (SETAGEM DE ENABLE E DISABLE) + private void checkBtnAplicar() { + if (!modificacoes.isEmpty() || font_editada == true) { + btn_aplicar.setEnabled(true); + } else { + btn_aplicar.setEnabled(false); + } + } + + private void aplicar() { + ArrayListwrite = new ArrayList<>(); + + if (font_editada == true) { + write.add(kit.getProperty("DefaultFont")); + } + + if (!modificacoes.isEmpty()) { + boolean controlWrite = true; + for (String retorno : modificacoes) { + String tmp[] = retorno.split(","); + + //VERIFICANDO SE EXISTE NAS CONFIGURACOES ORIGINIAS INTERNAS + for (String original : configuracoes_originais_internas) { + String comparacao[] = original.split(","); + + if (comparacao[0].equals(tmp[0]) && comparacao[1].equals(tmp[1]) && comparacao[2].equals(tmp[2])) { + controlWrite = false; + break; + } else { + controlWrite = true; + } + } + + if (controlWrite) { + write.add(tmp[0] + "=" + tmp[1] + "," + tmp[2]); + } + } + } + + if (!file_setting.delete()) { + //APAGAR CONTEU DO ARQUIVO + PrintWriter clean = null; + try { + clean = new PrintWriter(file_setting); + clean.print(""); + + } catch (FileNotFoundException ex) { + Logger.getLogger(Opcoes.class.getName()).log(Level.SEVERE, null, ex); + } finally { + clean.close(); + } + } + + if (!write.isEmpty()) { + //PREPARA PARA SALVAR O ARQUIVO + PrintWriter print = null; + try { + print = new PrintWriter(file_setting); + + for (String line : write) { + print.println(line); + } + + } catch (FileNotFoundException ex) { + Logger.getLogger(Opcoes.class.getName()).log(Level.SEVERE, null, ex); + } finally { + print.close(); + } + } + + modificacoes.clear(); + configuracoes_originais.clear(); + + getDataKit(); + getDataFontKit(); + + font_editada = false; + btn_aplicar.setEnabled(false); + + //FAZ O UPDATE NO EDITOR + updateStyleText(); + + System.out.println("Modificações aplicadas com sucesso."); + } + + public void updateStyleText() { + for(int i = 0 ; i < tab.getTabCount();i++){ + tab.getJEditorPaneAt(i).updateUI(); + tab.getJEditorPaneAt(i).revalidate(); + tab.getJEditorPaneAt(i).validate(); + } + } + + //REMOVER ALGUMAS CONFIGURACOES DO COLOR CHOOSER + private static void removeTransparencySlider(JColorChooser jc) throws Exception { + + final AbstractColorChooserPanel[] colorPanels = jc.getChooserPanels(); + final AbstractColorChooserPanel cp = colorPanels[0]; + + Field f = null; + try { + f = cp.getClass().getDeclaredField("panel"); + } catch (NoSuchFieldException | SecurityException e) { + } + f.setAccessible(true); + + Object colorPanel = null; + try { + colorPanel = f.get(cp); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + + Field f2 = null; + try { + f2 = colorPanel.getClass().getDeclaredField("spinners"); + } catch (NoSuchFieldException | SecurityException e4) { + } + f2.setAccessible(true); + Object rows = null; + try { + rows = f2.get(colorPanel); + } catch (IllegalArgumentException | IllegalAccessException e3) { + } + + final Object transpSlispinner = Array.get(rows, 3); + Field f3 = null; + try { + f3 = transpSlispinner.getClass().getDeclaredField("slider"); + } catch (NoSuchFieldException | SecurityException e) { + } + f3.setAccessible(true); + JSlider slider = null; + try { + slider = (JSlider) f3.get(transpSlispinner); + } catch (IllegalArgumentException | IllegalAccessException e2) { + } + slider.setVisible(false); + Field f4 = null; + try { + f4 = transpSlispinner.getClass().getDeclaredField("spinner"); + } catch (NoSuchFieldException | SecurityException e1) { + } + f4.setAccessible(true); + JSpinner spinner = null; + try { + spinner = (JSpinner) f4.get(transpSlispinner); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + spinner.setVisible(false); + Field f5 = null; + try { + f5 = transpSlispinner.getClass().getDeclaredField("label"); + } catch (NoSuchFieldException | SecurityException e1) { + } + f5.setAccessible(true); + JLabel label = null; + try { + label = (JLabel) f5.get(transpSlispinner); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + label.setVisible(false); + + Field f6 = null; + try { + f6 = transpSlispinner.getClass().getDeclaredField("value"); + } catch (NoSuchFieldException | SecurityException e1) { + } + f6.setAccessible(true); + float value = 0; + try { + value = (float) f6.get(transpSlispinner); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btn_aplicar; + private javax.swing.JButton btn_chooserColor; + private javax.swing.JButton btn_ok; + private javax.swing.JEditorPane editor_amostra; + private javax.swing.JTextField font_txt; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JCheckBox jCheckBox2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JList list_categoria; + private javax.swing.JPanel panel_cor; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/forms/RelatarBug.form b/src/com/forms/RelatarBug.form new file mode 100644 index 0000000..b2c7c09 --- /dev/null +++ b/src/com/forms/RelatarBug.form @@ -0,0 +1,129 @@ + + + diff --git a/src/com/forms/RelatarBug.java b/src/com/forms/RelatarBug.java new file mode 100644 index 0000000..43936bc --- /dev/null +++ b/src/com/forms/RelatarBug.java @@ -0,0 +1,184 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.forms; + +import java.awt.Cursor; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import javax.swing.JOptionPane; + +/** + * + * @author Andrew + */ +public class RelatarBug extends javax.swing.JDialog { + + private final String USER_AGENT = "Mozilla/5.0"; + + /** + * Creates new form RelatarBug + */ + public RelatarBug(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + categoria = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + detalhe_bug = new javax.swing.JTextPane(); + jButton1 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Relatar bug"); + setResizable(false); + + jLabel1.setText("Local de ocorrencia:"); + + categoria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Editor", "Configurações do editor", "Menu de ações", "Interpretador", "Console", "Outros" })); + + jLabel2.setText("Detalhes do bug:"); + + jScrollPane1.setViewportView(detalhe_bug); + + jButton1.setText("Enviar"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + sendPost(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(categoria, 0, 288, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jButton1))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(categoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// //GEN-END:initComponents + + private void sendPost(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendPost + int length = detalhe_bug.getDocument().getLength(); + if (length != 0) { + try { + sendPost(); + } catch (Exception ex) { + JOptionPane.showMessageDialog(null, "Houve algum problema na comunicação com o servidor.", "Alerta", JOptionPane.ERROR_MESSAGE); + } + } else { + JOptionPane.showMessageDialog(null, "Favor preencher o detalhe do bug que está acontecendo.", "Alerta", JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_sendPost + +// HTTP POST request + private void sendPost() throws Exception { + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + String url = "http://pgeditor.com.br/Relatar-bug"; + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + //add reuqest header + con.setRequestMethod("POST"); + con.setRequestProperty("User-Agent", USER_AGENT); + con.setRequestProperty("Accept-Language", "pt-BR,en;q=0.5"); + + String urlParameters = "categoria=" + categoria.getSelectedIndex() + "&detalhe=" + URLEncoder.encode(detalhe_bug.getText(), "UTF-8"); + + // Send post request + con.setDoOutput(true); + try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { + wr.writeBytes(urlParameters); + wr.flush(); + } + + int responseCode = con.getResponseCode(); + System.out.println("\nSending 'POST' request to URL : " + url); + System.out.println("Post parameters : " + urlParameters); + System.out.println("Response Code : " + responseCode); + + StringBuilder response; + try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { + String inputLine; + response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } + + //print result + JOptionPane.showMessageDialog(null, response.toString(), "Alerta", JOptionPane.WARNING_MESSAGE); + + categoria.setSelectedIndex(0); + detalhe_bug.setText(""); + setCursor(Cursor.getDefaultCursor()); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox categoria; + private javax.swing.JTextPane detalhe_bug; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/forms/Sobre.form b/src/com/forms/Sobre.form new file mode 100644 index 0000000..b8435c1 --- /dev/null +++ b/src/com/forms/Sobre.form @@ -0,0 +1,159 @@ + + + diff --git a/src/com/forms/Sobre.java b/src/com/forms/Sobre.java new file mode 100644 index 0000000..3ff3b3b --- /dev/null +++ b/src/com/forms/Sobre.java @@ -0,0 +1,181 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.forms; + +import java.awt.Desktop; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author SIMONETO-2 + */ +public class Sobre extends javax.swing.JDialog { + + /** + * Creates new form Sobre + * + * @param parent + * @param modal + */ + public Sobre(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + ////GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextPane1 = new javax.swing.JTextPane(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Sobre"); + setResizable(false); + + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/logo.png"))); // NOI18N + + jLabel2.setText("Portugol Editor (1.0.0) ALPHA"); + + jLabel3.setText("Desenvolvido por Andrew Neto"); + + jTextPane1.setEditable(false); + jTextPane1.setBackground(new java.awt.Color(240, 240, 240)); + jTextPane1.setText("Editor e interpretador de Portugol. Produzido com o intuito de facilitar e otimizar a introdução de novos programadores."); + jScrollPane1.setViewportView(jTextPane1); + + jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/facebook.png"))); // NOI18N + jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + jLabel4.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(java.awt.event.MouseEvent evt) { + openFacebook(evt); + } + }); + + jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/email.png"))); // NOI18N + jLabel5.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + jLabel5.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(java.awt.event.MouseEvent evt) { + openMail(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel3)) + .addGap(0, 37, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3)) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5) + .addComponent(jLabel4)) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void openFacebook(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_openFacebook + try { + openWebpage(new URL("https://www.facebook.com/endroca")); + } catch (MalformedURLException ex) { + Logger.getLogger(Sobre.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_openFacebook + + private void openMail(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_openMail + try { + openWebpage(new URL("http://andrewneto.com/contato")); + } catch (MalformedURLException ex) { + Logger.getLogger(Sobre.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_openMail + public static void openWebpage(URI uri) { + Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; + if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { + try { + desktop.browse(uri); + } catch (Exception e) { + } + } + } + + public static void openWebpage(URL url) { + try { + openWebpage(url.toURI()); + } catch (URISyntaxException e) { + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextPane jTextPane1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/images/Thumbs.db b/src/com/images/Thumbs.db new file mode 100644 index 0000000..7a5e91c Binary files /dev/null and b/src/com/images/Thumbs.db differ diff --git a/src/com/images/email.png b/src/com/images/email.png new file mode 100644 index 0000000..c103b7d Binary files /dev/null and b/src/com/images/email.png differ diff --git a/src/com/images/facebook.png b/src/com/images/facebook.png new file mode 100644 index 0000000..c31accc Binary files /dev/null and b/src/com/images/facebook.png differ diff --git a/src/com/images/logo.png b/src/com/images/logo.png new file mode 100644 index 0000000..d008bad Binary files /dev/null and b/src/com/images/logo.png differ diff --git a/src/com/images/logo_editor.png b/src/com/images/logo_editor.png new file mode 100644 index 0000000..291d243 Binary files /dev/null and b/src/com/images/logo_editor.png differ diff --git a/src/com/images/logo_icon.png b/src/com/images/logo_icon.png new file mode 100644 index 0000000..2da323b Binary files /dev/null and b/src/com/images/logo_icon.png differ diff --git a/src/com/images/pgeditor.png b/src/com/images/pgeditor.png new file mode 100644 index 0000000..392bc7a Binary files /dev/null and b/src/com/images/pgeditor.png differ diff --git a/src/com/system/CaretConsole.java b/src/com/system/CaretConsole.java new file mode 100644 index 0000000..3ed929a --- /dev/null +++ b/src/com/system/CaretConsole.java @@ -0,0 +1,89 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.system; + +/** + * + * @author SIMONETO-2 + */ +// CornerCaret.java +// A custom caret class. +// +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultCaret; +import javax.swing.text.JTextComponent; + +public class CaretConsole extends DefaultCaret { + + private JTextComponent comp; + + //private String mark = "<"; + public CaretConsole() { + setBlinkRate(500); + } + + @Override + protected synchronized void damage(Rectangle r) { + if (r == null) { + return; + } + + comp = getComponent(); + FontMetrics fm = comp.getFontMetrics(comp.getFont()); + int textWidth = fm.stringWidth(">"); + int textHeight = fm.getHeight(); + x = r.x; + y = r.y; + width = textWidth; + height = textHeight; + repaint(); // calls getComponent().repaint(x, y, width, height) + } + + @Override + public void paint(Graphics g) { + JTextComponent comp = getComponent(); + if (comp == null) { + return; + } + + int dot = getDot(); + Rectangle r = null; + try { + r = comp.modelToView(dot); + } catch (BadLocationException e) { + return; + } + if (r == null) { + return; + } + + if ((x != r.x) || (y != r.y)) { + repaint(); // erase previous location of caret + damage(r); + } + + if (isVisible()) { + g.setColor(comp.getCaretColor()); + g.fillRect(r.x, r.y, 8, r.height); + } + } + + @Override + public void mousePressed(MouseEvent evt) { + comp.requestFocus(); + evt.consume(); + } + + @Override + public void mouseDragged(MouseEvent e) { + e.consume(); + } + +} diff --git a/src/com/system/ConsoleIO.java b/src/com/system/ConsoleIO.java new file mode 100644 index 0000000..08cb090 --- /dev/null +++ b/src/com/system/ConsoleIO.java @@ -0,0 +1,311 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.system; + +import static com.forms.Editor.Threadcode; +import java.awt.Color; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import static java.awt.event.KeyEvent.VK_BACK_SPACE; +import static java.awt.event.KeyEvent.VK_DOWN; +import static java.awt.event.KeyEvent.VK_LEFT; +import static java.awt.event.KeyEvent.VK_UP; +import java.awt.event.KeyListener; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JTextPane; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; + +/** + * + * @author SIMONETO-2 + */ +public class ConsoleIO implements KeyListener { + + private String retorno_string = ""; + private JTextPane console; + private Document doc; + + private boolean isInterrupt = false; + + private int caret_min_position = -1; + + private boolean key_enter = true; + private boolean block = true; + private boolean write = false; + private boolean write_tipo_int = false; + private boolean write_tipo_float = false; + private boolean write_tipo_char = false; + + public ConsoleIO(JTextPane console) { + this.console = console; + doc = this.console.getDocument(); + console.addKeyListener(this); + console.setCaretColor(Color.decode("#999999")); + console.setCaret(new CaretConsole()); + } + + private int textLength() { + return doc.getLength(); + } + + public void print(int position, Object t, SimpleAttributeSet style) { + try { + doc.insertString(position, "" + t, style); + console.setCaretPosition(textLength()); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void print(Object t) { + print(textLength(), t, null); + } + + public void print(Object t, SimpleAttributeSet style) { + print(textLength(), t + "\n", style); + } + + public void println(Object t) { + print(textLength(), t + "\n", null); + } + + public void println(Object t, SimpleAttributeSet style) { + print(textLength(), t + "\n", style); + } + + public String writeString() { + + write(); + + lock(); + + try { + retorno_string = doc.getText(caret_min_position, textLength() - caret_min_position); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + write = false; + print("\n"); + + return retorno_string; + } + + public int writeInt() { + + write(); + + write_tipo_int = true; + int retorno = 0; + + lock(); + + try { + retorno_string = doc.getText(caret_min_position, textLength() - caret_min_position); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + retorno = new Integer(retorno_string); + + write = false; + write_tipo_int = false; + print("\n"); + + return retorno; + } + + public float writeFloat() { + + write(); + + write_tipo_float = true; + float retorno = 0; + + lock(); + + try { + retorno_string = doc.getText(caret_min_position, textLength() - caret_min_position); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + retorno = new Float(retorno_string); + + write = false; + write_tipo_float = false; + print("\n"); + + return retorno; + } + + public char writeChar() { + + write(); + + write_tipo_char = true; + char retorno; + + lock(); + + try { + retorno_string = doc.getText(caret_min_position, textLength() - caret_min_position); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + retorno = retorno_string.charAt(0); + + write = false; + write_tipo_char = false; + print("\n"); + + return retorno; + } + + private void write() { + write = true; + console.requestFocus(); + int tmp_length = textLength(); + console.setCaretPosition(tmp_length); + caret_min_position = tmp_length; + + } + + public void finalizacao() { + console.setCaretPosition(textLength()); + } + + public synchronized void lock() { + while (block) { + try { + wait(); + } catch (InterruptedException ex) { + //Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + //System.out.println("Error de interrupção::::"); + } + } + block = true; + interrupt_code(); + } + + public synchronized void unlock() { + block = false; + notify(); + } + + public synchronized void interrupt() { + if (write) { + isInterrupt = true; + unlock(); + } else { + isInterrupt = true; + interrupt_code(); + } + + } + + private void interrupt_code() { + if (isInterrupt) { + if (Threadcode.isAlive()) { + Threadcode.interrupt(); + } + } + } + + @Override + public void keyTyped(KeyEvent e) { + if (write) { + type(e); + } else { + e.consume(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + if (write) { + type(e); + key_enter = false; + } else { + e.consume(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + if (write) { + key_enter = true; + type(e); + } else { + e.consume(); + } + } + + private synchronized void type(KeyEvent e) { + switch (e.getKeyCode()) { + case (KeyEvent.VK_ENTER): + if (e.getID() == KeyEvent.KEY_PRESSED) { + if (key_enter) { + int r = 0; + try { + r = doc.getText(caret_min_position, textLength() - caret_min_position).length(); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + if (r != 0) { + unlock(); + } + + e.consume(); + console.repaint(); + } + } + break; + case (VK_DOWN): + case (VK_UP): + break; + case (VK_LEFT): + case (VK_BACK_SPACE): + if (caret_min_position == console.getCaretPosition()) { + e.consume(); + Toolkit.getDefaultToolkit().beep(); + } + break; + default: + char key = e.getKeyChar(); + + if (write_tipo_int) { + String caracteres = "-0123456789"; + if (!caracteres.contains(key + "")) { + e.consume(); + } + } else if (write_tipo_float) { + String caracteres = "-0123456789."; + if (!caracteres.contains(key + "")) { + e.consume(); + } + } else if (write_tipo_char) { + int r = 0; + try { + r = doc.getText(caret_min_position, textLength() - caret_min_position).length(); + } catch (BadLocationException ex) { + Logger.getLogger(ConsoleIO.class.getName()).log(Level.SEVERE, null, ex); + } + + if (r > 0) { + e.consume(); + } + + } + break; + } + } +} diff --git a/src/com/system/LinePainter.java b/src/com/system/LinePainter.java new file mode 100644 index 0000000..ef34e91 --- /dev/null +++ b/src/com/system/LinePainter.java @@ -0,0 +1,124 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.system; + +/** + * + * @author SIMONETO-2 + */ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.text.*; +import de.sciss.syntaxpane.actions.ActionUtils; + +/* + * Track the movement of the Caret by painting a background line at the + * current caret position. + */ +public class LinePainter implements Highlighter.HighlightPainter { + + private JTextComponent component; + + private Color color; + + private Rectangle lastView; + + /* + * The line color will be calculated automatically by attempting + * to make the current selection lighter by a factor of 1.2. + * + * @param component text component that requires background line painting + */ + public LinePainter(JTextComponent component) { + this(component, null); + setLighter(component.getSelectionColor()); + } + + /* + * Manually control the line color + * + * @param component text component that requires background line painting + * @param color the color of the background line + */ + public LinePainter(JTextComponent component, Color color) { + this.component = component; + setColor(color); + + // Turn highlighting on by adding a dummy highlight + try { + component.getHighlighter().addHighlight(0, 0, this); + } catch (BadLocationException ble) { + } + } + + public void marker(int line) { + setLineNumber(line); + //resetHighlight(); + } + + public void setColor(Color color) { + this.color = color; + } + + public void setLighter(Color color) { + int red = Math.min(255, (int) (color.getRed() * 1.2)); + int green = Math.min(255, (int) (color.getGreen() * 1.2)); + int blue = Math.min(255, (int) (color.getBlue() * 1.2)); + setColor(new Color(red, green, blue)); + } + + private void setLineNumber(int line) { + Element map = component.getDocument().getDefaultRootElement(); + if (line < 0) { + } else if (line >= map.getElementCount()) { + } else { + Element lineElem = map.getElement(line); + component.setCaretPosition(lineElem.getStartOffset()); + } + } + + @Override + public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { + try { + Rectangle r = c.modelToView(c.getCaretPosition()); + g.setColor(color); + g.fillRect(0, r.y, c.getWidth(), r.height); + + if (lastView == null) { + lastView = r; + } + } catch (BadLocationException ble) { + System.out.println(ble); + } + } + + /* + * Caret position has changed, remove the highlight + */ + private void resetHighlight() { + // Use invokeLater to make sure updates to the Document are completed, + // otherwise Undo processing causes the modelToView method to loop. + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + int offset = component.getCaretPosition(); + Rectangle currentView = component.modelToView(offset); + + // Remove the highlighting from the previously highlighted line + if (lastView.y != currentView.y) { + component.repaint(0, lastView.y, component.getWidth(), lastView.height); + lastView = currentView; + } + } catch (BadLocationException ble) { + } + } + }); + } +} diff --git a/src/com/system/ResourceWaitQueue.java b/src/com/system/ResourceWaitQueue.java new file mode 100644 index 0000000..7204a61 --- /dev/null +++ b/src/com/system/ResourceWaitQueue.java @@ -0,0 +1,62 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.system; + +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.Level; +import java.util.logging.Logger; + + +public class ResourceWaitQueue { + + private final ReentrantLock lock = new ReentrantLock(true); // use a FIFO lock. + + private final Condition goodtogo = lock.newCondition(); + private int releasecount = 0; // how many threads should be released. + + public final void await() throws InterruptedException { + lock.lock(); + try { + while (releasecount == 0) { + goodtogo.await(); + } + // releasecount > 0 and we were signalled. + if (--releasecount > 0) { + // reduce the releasdecount, but there's still another + // thread that should be released. + goodtogo.signal(); + // when that other thread releases, if there's still more + // to be released, it can do that for us. + }; + } finally { + lock.unlock(); + } + } + + public final void release() { + lock.lock(); + try { + // indicate there is work to do + releasecount++; + // signal the condition is true.... (only signal, not signalAll()) + goodtogo.signal(); + } finally { + lock.unlock(); + } + } + + + public void interrupt(){ + try { + lock.lockInterruptibly(); + } catch (InterruptedException ex) { + Logger.getLogger(ResourceWaitQueue.class.getName()).log(Level.SEVERE, null, ex); + } + } + + +} \ No newline at end of file diff --git a/src/com/system/TableVariables.java b/src/com/system/TableVariables.java new file mode 100644 index 0000000..7faae98 --- /dev/null +++ b/src/com/system/TableVariables.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.system; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author SIMONETO-2 + */ +public class TableVariables { + + private JTable table = null; + private DefaultTableModel model; + + public TableVariables(JTable t) { + table = t; + model = (DefaultTableModel) table.getModel(); + } + + public void add(Object name, Object type, Object value) { + Object[] rowData = {name, type, value}; + model.addRow(rowData); + } + + public void update(Object name, Object value) { + for (int i = 0; i < model.getRowCount(); i++) { + if (model.getValueAt(i, 0).equals(name)) { + model.setValueAt(value, i, 2); + } + } + } + +} diff --git a/src/com/system/Teste.form b/src/com/system/Teste.form new file mode 100644 index 0000000..fd64ca9 --- /dev/null +++ b/src/com/system/Teste.form @@ -0,0 +1,72 @@ + + + diff --git a/src/com/system/Teste.java b/src/com/system/Teste.java new file mode 100644 index 0000000..a03eb6a --- /dev/null +++ b/src/com/system/Teste.java @@ -0,0 +1,135 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.system; + +import java.awt.Rectangle; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.text.BadLocationException; +import javax.swing.text.Utilities; + +/** + * + * @author SIMONETO-2 + */ +public class Teste extends javax.swing.JFrame { + LinePainter line_painter; + /** + * Creates new form Teste + */ + public Teste() { + initComponents(); + line_painter = new LinePainter(jEditorPane1); + + + + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + ////GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + jToggleButton1 = new javax.swing.JToggleButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jEditorPane1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + teste(evt); + } + }); + jScrollPane1.setViewportView(jEditorPane1); + + jToggleButton1.setText("jToggleButton1"); + jToggleButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) + .addComponent(jToggleButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jToggleButton1) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void teste(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_teste + + + }//GEN-LAST:event_teste + + private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed + // TODO add your handling code here: + line_painter.marker(3); + }//GEN-LAST:event_jToggleButton1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + //+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(Teste.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(Teste.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(Teste.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(Teste.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new Teste().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JEditorPane jEditorPane1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JToggleButton jToggleButton1; + // End of variables declaration//GEN-END:variables +}