question about Android compatibility

68 views
Skip to first unread message

iubito

unread,
Nov 27, 2010, 9:44:54 AM11/27/10
to abc4j
Hi Android users and developers!

I'm planing to replace the current parser by a more powerful (I hope)
and certainly easier to maintain.
I don't know Android, from what I read on the web (Android javadocs),
it's based on Java5 (or more). It accepts varargs, syntax Map<K, V>
and @Annotations
All my java sources are old school 1.4 compatible and I never studied
and used theses syntaxes.

The parser I want to write relies on parboiled package which
extensively use these syntaxes
https://github.com/sirthias/parboiled/wiki/

So at the first sight parboiled seems to be compatible with Android,
but to be sure I asked on their forum, and here.
If someone coding for Android can tell me if parboiled examples works,
it'll greatly helps!
I've not yet started to code the new parser, I'd like to be sure it'll
not break android compatibility.

iubito

unread,
Jan 6, 2011, 3:08:24 AM1/6/11
to abc4j
I answer to myself, I exchanged a lot of mail with Jonas, android user
on this list.
The parboiled "as is" is not compatible with Android, but for simple
cases (like the abc grammar) and with some fine tweaking, I can avoid
the non-compatible part of parboiled.
And now I have a great parser which transform an ABC file into a
structure of nodes/values.
The ABC grammar is complete and will be easy to maintain, need to be
tested against a lot of ABC files bogus or not.
I have to write the "node-structure to Tune" which is not hard but
need time.
Informations that don't have a abc.notation.* object will be ignored.

I try to keep as much as possible the same syntax new
TuneParser().parse(abcString) and listeners system,
but there will be some changes!

Be patient, I don't have a lot of time, but I'm confident.

Happy new year! :)


On 27 nov 2010, 15:44, iubito <iub...@gmail.com> wrote:
> Hi Android users and developers!
>
> I'm planing to replace the current parser by a more powerful (I hope)
> and certainly easier to maintain.
> I don't know Android, from what I read on the web (Android javadocs),
> it's based on Java5 (or more). It accepts varargs, syntax Map<K, V>
> and @Annotations
> All my java sources are old school 1.4 compatible and I never studied
> and used theses syntaxes.
>
> The parser I want to write relies on parboiled package which
> extensively use these syntaxeshttps://github.com/sirthias/parboiled/wiki/

iubito

unread,
Jan 13, 2011, 7:25:36 AM1/13/11
to abc4j
Node structure to Tune/Music objects is done, and it's fast, I'm in
huge test phase, to check as most as possible.
Syntax colour in TuneEditorPane is OK too, and really really fast,
still some things to adjust.
TuneParser listeners will be more simple, tuneBegin(), tuneEnd(), and
noTune()... no more invalidToken and validToken.
At the tuneEnd, there are 2 parameters, the parsed Tune object, and
the root of nodes made by the parser. The node is easy to browse, to
see in which branch/childs there are errors. The best example is
TuneEditorPane.


On 6 jan, 09:08, iubito <iub...@gmail.com> wrote:
> <...>

Lionel Gueganton

unread,
Jan 13, 2011, 3:42:14 PM1/13/11
to abc4j
Happy new year and congratulations ! ;)
Just one thing : is the new parser able to recover from abc syntax
errors ? I think this is the trickiest but also usefull part in the
current parser.
Cheers
Lionel.

iubito

unread,
Jan 14, 2011, 3:55:47 AM1/14/11
to abc4j
Yes
the parser marks the erroneous node with error, and each node has a
position (CharStreamPosition was extended a little)
and it continues to next recognized element.

iubito

unread,
Jan 22, 2011, 4:20:49 AM1/22/11
to abc4j
How things work...

step #1 : parboiled parse the source ABC string into a node structure
I convert into my own node structure (called AbcNode) which has more
useful methods

For example, the beginning of an ABC file :
X:1
T:Bu\vcimi\vs
Z:Tous aux Balkans !
F:http://www.tousauxbalkans.net/Bucimis
O:Bulgarie
Q:1/4=104
P:AABCDEFGAB
M:15/16
L:1/16
%%MIDI gchord f2czf2c2fzcfzcz
K:Bm
P:A
|: "Bm"B2(ef) (fB)(fB) (Pf2e) ({f}edef) | .d2.c2 .d2Pc2 (A^GA)
PB2(BF) :|

the resulting AbcNode structure : http://www.tousauxbalkans.net/files/nodestructure.txt
(19KB)
This first step is complete. I checked the grammar against a lot of
ABC files, still some tests to do.

If you want to quickly retrieve informations in ABC file, you can stop
at this step, and pick out the nodes you need, e.g.
myAbcRootNode.getChildsInAllGeneration("FieldTitle/TexText") will
return all TexText node which are child of a FieldTitle node... in
other word, all values of these nodes are the titles and subtitles of
the ABC tune. Powerful, isn't it?


step #2 :
The AbcParserAbstract converts the node structure into Tune, Parts,
Voices, Music, Notes, Barlines, KeySignature...
Excepted Voice, meta-command, userdefined symbols, lyrics..., this
step is mostly complete.
e.g. When abc.notation.* will handle lyrics, it'll be easy to convert
lyrics node to abc.notation.* classes. In the grammar, lyrics are
already prepared as syllable, syllable-break, hold, skip-note, next-
bar.

TuneParserListeners are used during step #2 but as step #2 does less
things than the old parse (equivalent of #1 + #2), some listener
method are no more used.
e.g. no need to keep a track of errors during parsing. at tuneEnd()
you have the parsed Tune and the AbcNode structure of step #1 where
you can read errors.
The TuneEditorPane was simplified.

Before commiting to SVN, I have to work on
- TuneBook parser, a abc.notation.TuneBook object ?
- the abcynth package to apply the listener changes.


step #3 - rendering :
Once you have a abc.notation.Tune object, you can generate midi,
graphical output.
This has not changed a lot. Some bugfix in graphical output (e.g. more
barline types).
Reply all
Reply to author
Forward
0 new messages