Started to add special function to inline code (issue #6).

This commit is contained in:
Marvin Blum
2015-10-28 17:59:38 +01:00
parent bba215cd8d
commit 1cbcda4261
5 changed files with 24 additions and 5 deletions

View File

@@ -45,7 +45,8 @@ var keywords = []string{
"try",
"catch",
"exitwith",
"waituntil"}
"waituntil",
"code"}
var whitespace = []byte{' ', '\n', '\t', '\r'}
var identifier = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"

View File

@@ -77,6 +77,14 @@ func TestTokenizerIdentifier(t *testing.T) {
compareTokens(t, &got, &want)
}
func TestTokenizerInlineCode(t *testing.T) {
got := getTokens(t, "test/tokenizer_code.asl")
want := []string{"var", "x", "=", "code", "(", "\"var x = 5;\"", ")", ";"}
compareLength(t, &got, &want)
compareTokens(t, &got, &want)
}
func compareLength(t *testing.T, got *[]Token, want *[]string) {
if len(*got) != len(*want) {
t.Error("Length of tokens got and expected tokens not equal, was:")