|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprovided.token.tokenizer.StringTokenizer
provided.token.tokenizer.ABCTokenizer
public class ABCTokenizer
Tokenizer for the abc music language. getNextToken() returns next Token in
stream. Does not recognize all possible language constructs and symbols
(returned as "?" token). Tokens are the atomic psemantic pieces of a language,
such as Note, repeat start, measure, chord, etc. The token ids (names) returned are:
EOF - end of file
"|:" - repeat start
":|" - repeat end
"|1" - first repeat start
"[1" - alternative first repeat start
"|2" - second repeat start
"[2" - alternative second repeat start
"[|" - thick-thin double bar line
"|]" - thin-thick double bar line
":|2" - alternative second repeat start
"||" - double measure bar
"::" - short hand for repeat end-start ":||:"
"|" - Measure bar
"[") - Chord start
"]" - Chord end
"-" - tie
">" - the previous note is dotted, the next note halved
"<" - the previous note is halved, the next dotted
"{" - Grace begin
"}" - Grace end
"%" - Comment
"[Header ID]" - where [Header ID] is a single letter from {ABCDEFGHIKLMNOPQRSTWXZ}
"Note" - a single note whose lexeme contains the name, accidentals, octave and duration
"Tuplet" - the lexeme is the number of subsequent Notes comprise this tuplet.
"Quote" - lexeme is the quoted text
"?" - unknown language construct.
References:
java.util.regex.Pattern for regex guide
ASCII table for codes
abc music standard 1.6
Field Summary | |
---|---|
static java.lang.String |
ACCIDENTALS
Allowable note accidentals |
private java.util.Map<java.lang.String,java.lang.String> |
keywords1
maps regex to their ASCII string counterparts. |
private java.util.Map<java.lang.String,java.lang.String> |
keywords2
keywords2 is searched second |
private java.util.Vector<java.util.Map<java.lang.String,java.lang.String>> |
keywordsVector
Ordered sets of keywords to check. |
private java.util.Stack<Token> |
stack
Push-back stack for tokens. |
private ITokenFactory |
tokFac
Factory for the tokens |
Fields inherited from class provided.token.tokenizer.StringTokenizer |
---|
_fileReader, _st |
Constructor Summary | |
---|---|
ABCTokenizer(java.lang.String inputFileName)
Constructor for the class |
Method Summary | |
---|---|
Token |
getNextToken()
Return the next token, either from the stream or the last token if it was pushed back |
private Token |
makeNextToken()
Parse the strings down from the getNextStringToken further, separating out the abc keywords into tokens. |
private java.lang.String |
parseNote(java.lang.String sTok)
Returns the first note string in the given string. |
private java.lang.String |
parseQuote(java.lang.String acc,
java.lang.String sTok)
Returns the rest of a string, incl. |
void |
putBack(Token t)
Push token back into the stream |
Methods inherited from class provided.token.tokenizer.StringTokenizer |
---|
getNextStringToken, putStringBack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map<java.lang.String,java.lang.String> keywords1
private java.util.Map<java.lang.String,java.lang.String> keywords2
private java.util.Vector<java.util.Map<java.lang.String,java.lang.String>> keywordsVector
private ITokenFactory tokFac
private java.util.Stack<Token> stack
public static final java.lang.String ACCIDENTALS
Constructor Detail |
---|
public ABCTokenizer(java.lang.String inputFileName) throws java.io.FileNotFoundException
inputFileName
- File to tokenize
java.io.FileNotFoundException
Method Detail |
---|
public Token getNextToken()
getNextToken
in interface ITokenizer
public void putBack(Token t)
putBack
in interface ITokenizer
t
- the Token you need to put back in the stream.private Token makeNextToken()
private java.lang.String parseNote(java.lang.String sTok)
sTok
- The string to parse
private java.lang.String parseQuote(java.lang.String acc, java.lang.String sTok)
acc
- Accumulated result stringsTok
- the current string token
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |