BNF IDE

advertisement
Uni IDE
Stephen Walter
Revised 2/13/08
Uni IDE
Description:
Uni IDE stands for Unverisal Integrated Development Environment. This is a
program idea built around the Back—Naur Form (BNF) which provides a code editor to
any computer language. Most highend IDEs are built specific to one or few standard
languages, so this software fills in that gap using only the BNF language definition.
There are some similar editors that handle multiple languages, but they lack the features
from the more prestige editors. Uni-IDE supports these features, including tools to
markup keywords of other languages, and parsing required for checking for all grammar.
The target audience is for any small size programming group that uses a non-standard
language for a specific problem. It will help cut development time wasted on bad
compiles as well as nitpicking through code.
The software will act as a tool for writing code for any language provided it is
given a Backus—Naur Form grammar in the form of a text file. The software will use
the BNF to construct the language’s grammar. This will then be applied to the code to
scan for mistakes while the user is typing it out. It should also be to identify user created
variables and the type associated with it. The IDE can act as a strongly typed parser,
even if the language does not support strongly typed objects. The grammar should also
support auto completion feature that provides matches that will fit the grammar and type.
Image of how the editor looks
Features:
- Multitab editor
At the very heart, Uni IDE is your coding editor. It comes with all the standard
word processing features. A multi-tab window for all code files is at the center of the
program. This allows quick access between several files without having to deal with
cluttered windows across the screen. All tabs may be quickly closed and saved at once.
In addition, Uni IDE remembers which files were last open and will launch them the next
time you run the program. The frames may also be used in a split view to allow viewing
of a single code file in two positions.
- Abstract grammar
BNF grammar is the main feature of Uni IDE. Using just a simple text document,
Uni IDE understands the grammar of the language. This allows the program to scan
through code files to ensure that code follows proper grammar. When any illegal
definition is found, Uni IDE will mark the line with red to indicate that the code will not
compile at that point. By mousing over the area, a tool tip provides reasoning for the
error. A full scale grammar view of the code may be accessed by menu, which will
remove the user defined text and display in a tree fashion.
- User defined values
By studying the user written code with its grammar, Uni IDE may also pick up
user-defined functions and variables. This enables the editor to show a list of the
currently declared functions and variables in a side panel. The program tracks the types
that objects are declared as. The editor may then issue warnings about incorrect usage of
these values. For languages with weak type, Uni IDE attempts to determine the first use
of the variable where the operation is limited to a particular class.
- Autocompletion
While writing code, Uni IDE can produce a list of possible auto completions.
These auto completions use the grammar and user variables to determine what code could
possibly fill out the end of the line of code. This feature is offered in a menu that appears
on the side, as to not block view of the code.
Example from part of the language Lua’s BNF:
chunk ::= {stat [`;´]} [laststat [`;´]]
block ::= chunk
stat ::=
varlist `=´ explist |
functioncall |
do block end |
while exp do block end |
repeat block until exp |
if exp then block {elseif exp then block} [else block]
end |
for Name `=´ exp `,´ exp [`,´ exp] do block end |
for namelist in explist do block end |
function funcname funcbody |
local function Name funcbody |
local namelist [`=´ explist]
laststat ::= return [explist] | break
funcname ::= Name {`.´ Name} [`:´ Name]
varlist ::= var {`,´ var}
var ::=
Name | prefixexp `[´ exp `]´ | prefixexp `.´ Name
namelist ::= Name {`,´ Name}
explist ::= {exp `,´} exp
exp ::=
nil | false | true | Number | String | `...´ | function
|
prefixexp | tableconstructor | exp binop exp | unop exp
binop ::= `+´ | `-´ | `*´ | `/´ | `^´ | `%´ | `..´ |
`<´ | `<=´ | `>´ | `>=´ | `==´ | `~=´ |
and | or
unop ::= `-´ | not | `#´
Source: Lua 5.1 Reference Manual Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes.
2008. <http://www.lua.org/manual/5.1/manual.html>
Implementation:
The program is written using Java, using several of the pre-existing classes to
handle the GUI elements for Uni IDE. The program is structured according to the
Model-View-Controller (MVC).
- Model
There are three elements in the model of the program. The first is the BNF
document. The user provides a text file using the standard context-free-grammar to
describe with the first definition as the starting root of the language. The BNF stored in a
class object containing its name, definition(s), and connection to other definitions. The
second model holds the actual code documents that the user will be editing. This object
is mostly handled through java API for reading and writing to a buffered file. The final
object is the parsing of the user code. This stores a tree of the grammar names, which
definition was used, variables local in the branch, and a reference to all the other names it
used.
- View
The view puts into the java GUI into its working format. The core frame of the
GUI consists of its menu bar on top, the multi-tab editing frame in the center, variable
and functions as a list on the sidebar, and a lower text status area for the responses. The
menu consists of standard bars like File, Edit, View, and Options. File will open, save,
close, and print files. Also includes save all, close all, and open recent. Edit will host the
cut, copy, paste, find, and replace features. View will aid in selecting tabs and showing
the abstract tree of the code. Options will allow the change of visual preferences, such as
font, and allow the loading languages.
The editor frame is a mutli-tab frame. The tab contains the file name and a close
button, whereas the interior holds the stylized text window. The text window uses the
Java API for tracking undoes and formatting. File size and cursor position are shown in
labels at the bottom of the frame. Variable list to the left sidebar is a simple list structure
in a frame. The bottom area for status is a simple multi-line text box.
- Event
The event class handles all the gui events. The menu commands to their relative
file operations, as well as the text editing changes to the documents in the edit frame.
The edit events parse through the code of user document (either fully or partially) and
attempt to create the model of the code. Any failure will prompt for a stylized text
modification to show the error and print the results on the status bar below.
Project Budget:
The budget will require spending on a computer and its own developing tools,
which should come out to around 9000. The office space for a small place at around $20
per square foot should come to about 2000 per month. Salaries for a single developer
using an 40 hour week at $87 per hour comes to 14000 a month. Utilities to cover
electric, plumping, and internet should be around 300.
Project Budget for 3 months
9000
Equipment
6000
Office
42000
Salaries
300
Utilities
57300
Total
Timeline:
Week 1: Design development with working basic text editor
Week 2: BNF parser
Week 3-4: Editor parser for BNF data
Week 5: UI development and formatting of text editor
Week 6: Variable/function tracking, strong type support
Week 7-8: Testing and twinking
Download