package flexgen import . "src.eruta.nl/beoran/ll1/grammar" import "src.eruta.nl/beoran/ll1/parser" func MakeFlexerGrammar() *Grammar { g := NewGrammar() dot := g.Term("dot", FlexgenKindDot) terminal := g.Term("terminal", FlexgenKindTerminal) arrow := g.Term("arrow", FlexgenKindArrow) action := g.Term("action", FlexgenKindAction) keyword := g.Term("keyword", FlexgenKindKeyword) keywordsRef := g.Ref("keywordsRef", "keywords") keywords := g.Opt("keywords", "", And(keyword, keywordsRef)) literalString := g.Term("literalString", FlexgenKindLiteralString) literalRaw := g.Term("literalRaw", FlexgenKindLiteralRaw) literalChar := g.Term("literalChar", FlexgenKindLiteralChar) pattern := g.Alt("pattern", "", literalString, literalRaw, literalChar) optAction := g.Opt("optAction", "", action) lexeme := g.Seq("lexeme", "", terminal, arrow, pattern, keywords, optAction, dot) lexemesRef := g.Ref("lexemesRef", "lexemes") lexemes := g.Opt("lexemes", "", And(lexeme, lexemesRef)) top := g.Seq("top", "", lexemes, End()) g.Top = top return g } /* Parser for the flexer lexer . */ func MakeFlexerParser() *parser.Parser { p := &parser.Parser{} p.TokenMapper = parser.DefaultMapper{} p.Grammar = *MakeFlexerGrammar() return p }