You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

theuserbl

Intermediate

  • "theuserbl" started this thread

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

1

Sunday, November 6th 2011, 6:06pm

Small fast Lexer for Jabaco files

If you need for any purpose an small and fast Lexer for Jabaco-code, here is one:
[ JbaLexer.jar ]
and the Sourcecode:
[ JbaLexer-src.zip ]

The Jar-file, which includes additional an example program - is only 3082 bytes small.


To use the test program:
Be use, that in your choosen directory are *.jsrc files.
You can either start it with

Source code

1
java -jar JbaLexer.jar file1.jsrc file2.jsrc file3.jsrc

or simple write

Source code

1
java -jar JbaLexer.jar *


It creates files with the extrension *.split".

For example from an simple Module1.jsrc like

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="ISO-8859-1"?>
<SourceFile><Source><![CDATA[
Public frmMain As New frmMain

Public Sub main(ByJava args() As String)
   Dim myArgs() As String
   myArgs = args
   frmMain.SetDefaultClose()
   frmMain.show()
End Sub
]]></Source><Param Name="(Name)" Value="Module1"/><Param Name="(SuperClass)" Value="java/lang/Object"/><Param Name="(NameSpace)" Value=""/><Param Name="(Type)" Value="Module"/><Param Name="(Access)" Value="Public"/></SourceFile>


it creates a Module1.split file, which looks like

Jabaco Source

1
2
3
4
5
6
7
8
»Public« »frmMain« »As« »New« »frmMain« 

»Public« »Sub« »main« »(« »ByJava« »args« »(« »)« »As« »String« »)« 
»Dim« »myArgs« »(« »)« »As« »String« 
»myArgs« »=« »args« 
»frmMain.SetDefaultClose« »(« »)« 
»frmMain.show« »(« »)« 
»End« »Sub«


Thats it. I know, that for the most people here, it makes not much sense, but if you need such a library here is it.

To use it in Jabaco:
- Go over the menu to "Project" -> "References (Classpath) ..." or simple press your "F1"-key
- Press on "Add Jar Archive..."
- Choosing "JbaLexer.jar" in your directory and open it.
- Navigate in the tree under JbaLexer.jar to the file "JbaLexer.class" and mark it.
- Press then the "Close"-Button of the "Imports"-Dialog.

Now you can use it. For example you can add to a Form a TextBox, CommandButton and ListBox.
Then write for your Form:

Jabaco Source

1
2
3
4
5
6
7
8
Public Sub Command1_Click()
   List1.Clear
   Dim myStrings() As String
   myStrings() = JbaLexer.split(Text1.Text)
   For i = 0 To Ubound(myStrings)
     List1.AddItem(New ListCellData(myStrings(i), Nothing, False))
   Next i
End Sub

If you write now a line of Jabaco-code in the Text-Box and press the CommandButton, then in the ListBox in every line is one Token of the Lexer.

And it have the same bugs like Jabaco.
If you write "Dim A;B As Integer", then "A;B" is one Token.

If you don't know it before, thats right. ";" is for Jabaco a normal letter like "g", "T" or so.
So the program

Jabaco Source

1
2
3
Dim a;b As Integer = 17
a;b = a;b * 3
MsgBox(a;b)
works in Jabaco without errors.

Greatings
theuserbl

Rate this thread
WoltLab Burning Board