Skip to content

Commit

Permalink
BIG MOVING IN, all the v2 is now in the lexer directory. PTGLK
Browse files Browse the repository at this point in the history
  • Loading branch information
Llelepipede committed Feb 28, 2024
1 parent cc54bfa commit 9040f50
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 2,319 deletions.
2 changes: 1 addition & 1 deletion lexer/v2/IToken.go → lexer/IToken.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type ITokenType interface {
// Resolve use the actual l *TLexer to create a new Token. the lexer is ready for the next step when the resolve end
Expand Down
11 changes: 4 additions & 7 deletions lexer/v2/Lexer.go → lexer/Lexer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

import "strconv"

Expand Down Expand Up @@ -207,12 +207,9 @@ func LexerR(sentence string) []Token {
Lex.Step()
Lex.tempVal = Lex.sentence[Lex.prevIndex:Lex.index]
if Lex.tempVal != "" {
if Lex.TriggerBy != "" {
//findNameInEveryTokenType(Lex.TriggerBy, Every).Resolve(Lex)
Lex.AddToken(Lex.TriggerBy + " FIN")
} else {
Lex.AddToken(TEXT)
}

Lex.AddToken(TEXT)

Lex.tempVal = ""
}
Lex.AddToken(EOF)
Expand Down
2 changes: 1 addition & 1 deletion lexer/v2/TokenTypeBase.go → lexer/TokenTypeBase.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type TokenTypeBaseBehavior struct {
Name string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type TokenTypeCompositeBehavior struct {
Name string
Expand Down
7 changes: 5 additions & 2 deletions lexer/v2/TokenTypeMerger.go → lexer/TokenTypeMerger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type TokenTypeMergerBehavior struct {
Name string
Expand Down Expand Up @@ -36,7 +36,10 @@ func (t *TokenTypeMergerBehavior) Resolve(l *TLexer) {
(*l).isSpaces = false
}
if index == -1 {
if l.sizeOfTokenReversed != -1 {
if l.index >= len(l.sentence) {
l.AddToken(t.Result[0].Name)
l.prevIndex = l.index
} else if l.sizeOfTokenReversed != -1 {
identified := l.tempVal[len(l.tempVal)-l.sizeOfTokenReversed:]
indexOfClose := t.IsClosedBySyntaxe(identified)
if indexOfClose != -1 {
Expand Down
4 changes: 2 additions & 2 deletions lexer/v2/TokenTypeSpaces.go → lexer/TokenTypeSpaces.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type TokenTypeSpacesBehavior struct {
Name string
Expand All @@ -19,7 +19,7 @@ func (t *TokenTypeSpacesBehavior) Resolve(l *TLexer) {
}
if t.Name == "\n" {
(*l).line++
(*l).position = 0
(*l).position = 1
}

l.prevIndex = l.index
Expand Down
15 changes: 9 additions & 6 deletions lexer/v2/TokenTypeTrigger.go → lexer/TokenTypeTrigger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v2
package lexer

type TokenTypeTriggerBehavior struct {
Name string
Expand All @@ -18,7 +18,10 @@ func (t *TokenTypeTriggerBehavior) Resolve(l *TLexer) {
(*l).AddToken(t.Name)
l.prevIndex = l.index
} else {
if l.sizeOfTokenReversed != -1 {
if l.index >= len(l.sentence) {
l.AddToken(t.Result[0].Name)
l.prevIndex = l.index
} else if l.sizeOfTokenReversed != -1 {
identified := l.tempVal[len(l.tempVal)-l.sizeOfTokenReversed:]
indexOfClose := t.IsClosedBySyntaxe(identified)
if indexOfClose != -1 {
Expand Down Expand Up @@ -78,10 +81,10 @@ var (
"\"",
},
CloseBy: []ITokenType{
&SELF,
&SELF, &RETURN,
},
Result: []TokenTypeCompositeBehavior{
CSTRING,
CSTRING, CSTRING,
},
}
TSQUOTE = TokenTypeTriggerBehavior{
Expand All @@ -90,10 +93,10 @@ var (
"'",
},
CloseBy: []ITokenType{
&SELF,
&SELF, &RETURN,
},
Result: []TokenTypeCompositeBehavior{
CCHAR,
CCHAR, CCHAR,
},
}
)
Loading

0 comments on commit 9040f50

Please sign in to comment.