Comments (1)
Closing this issue because it is useful when debugging to see where function execution begins and ends. I use the defer function with my go-elog package. There is most likely a performance penalty due to the overhead of the defer function, but for now I need a way to quickly debug the lexer and parser. Maybe someday Go will have a proper debugger and these defer functions can be removed.
Most of the lexing functions contain this block of code:
log.Debugln("START lexing inline literal...")
log.SetIndent(log.Indent() + 1)
defer func() {
log.SetIndent(log.Indent() - 1)
log.Debugln("END")
}()
Which makes it possible to produce output like:
=== RUN TestLexInlineLiteralGood0600
[DEBUG] WithFlagsf#387: Test Path: /home/demizer/src/github.com/demizer/go-rst/testdata/test-inline-markup/03-literal-good/06.00-literal-with-tex-quotes
[DEBUG] WithFlagsf#387: Test Input:
-----------
``literal ``TeX quotes'' & \backslash`` but not "``" or ``
-----------
[DEBUG] newLexer#252: mark: U+0060 '`', index: 0, line: 1
[DEBUG] lexStart#803: START
[DEBUG] |...lexStart#820: l.mark: '`', l.index: 0, l.width: 1, l.line: 1
[DEBUG] |...isComment#582: START Checking for comment...
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...peek#364: peek() found '`' at index 1
[DEBUG] |...|...isComment#598: Comment not found!
[DEBUG] |...func·006#586: END
[DEBUG] |...isBulletList#625: START Checking for bullet...
[DEBUG] |...|...isBulletList#637: A bullet was not found
[DEBUG] |...func·007#629: END
[DEBUG] |...isSection#493: START Checking for section...
[DEBUG] |...|...isTransition#558: START Checking for transition...
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...|...next#405: mark: U+006C 'l', start: 0, index: 2, line: 1
[DEBUG] |...|...|...next#405: mark: U+0069 'i', start: 0, index: 3, line: 1
[DEBUG] |...|...|...next#405: mark: U+0074 't', start: 0, index: 4, line: 1
[DEBUG] |...|...|...peek#364: peek() found 't' at index 4
[DEBUG] |...|...|...isTransition#565: Transition not found
[DEBUG] |...|...func·005#562: END
[DEBUG] |...|...isSection#528: Checking current line
[DEBUG] |...|...func·004#515: Section not found
[DEBUG] |...|...isSection#534: Checking next line
[DEBUG] |...|...isSection#543: Section not found
[DEBUG] |...func·003#497: END
[DEBUG] |...backup#345: l.mark backed up to: '`'
[DEBUG] |...isSection#493: START Checking for section...
[DEBUG] |...|...isTransition#558: START Checking for transition...
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...|...next#405: mark: U+006C 'l', start: 0, index: 2, line: 1
[DEBUG] |...|...|...next#405: mark: U+0069 'i', start: 0, index: 3, line: 1
[DEBUG] |...|...|...next#405: mark: U+0074 't', start: 0, index: 4, line: 1
[DEBUG] |...|...|...peek#364: peek() found 't' at index 4
[DEBUG] |...|...|...isTransition#565: Transition not found
[DEBUG] |...|...func·005#562: END
[DEBUG] |...|...isSection#528: Checking current line
[DEBUG] |...|...func·004#515: Section not found
[DEBUG] |...|...isSection#534: Checking next line
[DEBUG] |...|...isSection#543: Section not found
[DEBUG] |...func·003#497: END
[DEBUG] |...isTransition#558: START Checking for transition...
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...next#405: mark: U+006C 'l', start: 0, index: 2, line: 1
[DEBUG] |...|...next#405: mark: U+0069 'i', start: 0, index: 3, line: 1
[DEBUG] |...|...next#405: mark: U+0074 't', start: 0, index: 4, line: 1
[DEBUG] |...|...peek#364: peek() found 't' at index 4
[DEBUG] |...|...isTransition#565: Transition not found
[DEBUG] |...func·005#562: END
[DEBUG] |...isDefinitionTerm#656: sCount = 0
[DEBUG] |...isDefinitionTerm#661: Did not find definition term.
[DEBUG] func·013#807: END
[DEBUG] lexParagraph#979: START lexing paragraph
[DEBUG] |...isInlineMarkup#717: START Checking for inline markup
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...peek#364: peek() found '`' at index 1
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...next#405: mark: U+006C 'l', start: 0, index: 2, line: 1
[DEBUG] |...|...peek#364: peek() found 'l' at index 2
[DEBUG] |...|...isInlineMarkup#737: Found inline markup!
[DEBUG] |...func·010#721: END
[DEBUG] |...lexInlineMarkup#1088: l.mark: '`' l.start: 0 l.index: 0 l.width: 1 l.line: 1
[DEBUG] |...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...peek#364: peek() found '`' at index 1
[DEBUG] |...lexInlineLiteral#1192: START lexing inline literal...
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 0, index: 1, line: 1
[DEBUG] |...|...next#405: mark: U+006C 'l', start: 0, index: 2, line: 1
[INFO] |...|...emit#297: [ID: 1]: itemInlineLiteralOpen: "``" l.start: 0 (1) l.index: 2 (3) line: 1
[INFO] |...|...emit#315: Position after EMIT: l.mark: 'l', l.start: 2 (3) l.index: 2 (3) line: 1
[DEBUG] |...|...next#405: mark: U+0069 'i', start: 2, index: 3, line: 1
[DEBUG] |...|...next#405: mark: U+0074 't', start: 2, index: 4, line: 1
[DEBUG] |...|...next#405: mark: U+0065 'e', start: 2, index: 5, line: 1
[DEBUG] |...|...next#405: mark: U+0072 'r', start: 2, index: 6, line: 1
[DEBUG] |...|...next#405: mark: U+0061 'a', start: 2, index: 7, line: 1
[DEBUG] |...|...next#405: mark: U+006C 'l', start: 2, index: 8, line: 1
[DEBUG] |...|...next#405: mark: U+0020 ' ', start: 2, index: 9, line: 1
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 2, index: 10, line: 1
[DEBUG] |...|...isInlineMarkupClosed#745: START Checking for closed inline markup
[DEBUG] |...|...|...backup#345: l.mark backed up to: ' '
[DEBUG] |...|...|...peekBack#383: peekBack found " " at index 9
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 11, line: 1
[DEBUG] |...|...|...peek#364: peek() found '`' at index 11
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 11, line: 1
[DEBUG] |...|...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...|...peek#364: peek() found 'T' at index 12
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 11, line: 1
[DEBUG] |...|...|...peek#364: peek() found '`' at index 11
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 11, line: 1
[DEBUG] |...|...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...|...peek#364: peek() found 'T' at index 12
[DEBUG] |...|...|...isInlineMarkupClosed#787: Inline markup close not found
[DEBUG] |...|...func·011#749: END
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 2, index: 11, line: 1
[DEBUG] |...|...isInlineMarkupClosed#745: START Checking for closed inline markup
[DEBUG] |...|...|...backup#345: l.mark backed up to: '`'
[DEBUG] |...|...|...peekBack#383: peekBack found "`" at index 10
[DEBUG] |...|...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...|...peek#364: peek() found 'T' at index 12
[DEBUG] |...|...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...|...next#405: mark: U+0065 'e', start: 2, index: 13, line: 1
[DEBUG] |...|...|...peek#364: peek() found 'e' at index 13
[DEBUG] |...|...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...|...peek#364: peek() found 'T' at index 12
[DEBUG] |...|...|...isInlineMarkupClosed#787: Inline markup close not found
[DEBUG] |...|...func·011#749: END
[DEBUG] |...|...next#405: mark: U+0054 'T', start: 2, index: 12, line: 1
[DEBUG] |...|...next#405: mark: U+0065 'e', start: 2, index: 13, line: 1
[DEBUG] |...|...next#405: mark: U+0058 'X', start: 2, index: 14, line: 1
[DEBUG] |...|...next#405: mark: U+0020 ' ', start: 2, index: 15, line: 1
[DEBUG] |...|...next#405: mark: U+0071 'q', start: 2, index: 16, line: 1
[DEBUG] |...|...next#405: mark: U+0075 'u', start: 2, index: 17, line: 1
[DEBUG] |...|...next#405: mark: U+006F 'o', start: 2, index: 18, line: 1
[DEBUG] |...|...next#405: mark: U+0074 't', start: 2, index: 19, line: 1
[DEBUG] |...|...next#405: mark: U+0065 'e', start: 2, index: 20, line: 1
[DEBUG] |...|...next#405: mark: U+0073 's', start: 2, index: 21, line: 1
[DEBUG] |...|...next#405: mark: U+0027 ''', start: 2, index: 22, line: 1
[DEBUG] |...|...next#405: mark: U+0027 ''', start: 2, index: 23, line: 1
[DEBUG] |...|...next#405: mark: U+0020 ' ', start: 2, index: 24, line: 1
[DEBUG] |...|...next#405: mark: U+0026 '&', start: 2, index: 25, line: 1
[DEBUG] |...|...next#405: mark: U+0020 ' ', start: 2, index: 26, line: 1
[DEBUG] |...|...next#405: mark: U+005C '\', start: 2, index: 27, line: 1
[DEBUG] |...|...next#405: mark: U+0062 'b', start: 2, index: 28, line: 1
[DEBUG] |...|...next#405: mark: U+0061 'a', start: 2, index: 29, line: 1
[DEBUG] |...|...next#405: mark: U+0063 'c', start: 2, index: 30, line: 1
[DEBUG] |...|...next#405: mark: U+006B 'k', start: 2, index: 31, line: 1
[DEBUG] |...|...next#405: mark: U+0073 's', start: 2, index: 32, line: 1
[DEBUG] |...|...next#405: mark: U+006C 'l', start: 2, index: 33, line: 1
[DEBUG] |...|...next#405: mark: U+0061 'a', start: 2, index: 34, line: 1
[DEBUG] |...|...next#405: mark: U+0073 's', start: 2, index: 35, line: 1
[DEBUG] |...|...next#405: mark: U+0068 'h', start: 2, index: 36, line: 1
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 2, index: 37, line: 1
[DEBUG] |...|...isInlineMarkupClosed#745: START Checking for closed inline markup
[DEBUG] |...|...|...backup#345: l.mark backed up to: 'h'
[DEBUG] |...|...|...peekBack#383: peekBack found "h" at index 36
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 38, line: 1
[DEBUG] |...|...|...peek#364: peek() found '`' at index 38
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 38, line: 1
[DEBUG] |...|...|...next#405: mark: U+0020 ' ', start: 2, index: 39, line: 1
[DEBUG] |...|...|...peek#364: peek() found ' ' at index 39
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 38, line: 1
[DEBUG] |...|...|...peek#364: peek() found '`' at index 38
[DEBUG] |...|...|...next#405: mark: U+0060 '`', start: 2, index: 38, line: 1
[DEBUG] |...|...|...next#405: mark: U+0020 ' ', start: 2, index: 39, line: 1
[DEBUG] |...|...|...peek#364: peek() found ' ' at index 39
[DEBUG] |...|...|...isInlineMarkupClosed#783: Found inline markup close
[DEBUG] |...|...func·011#749: END
[DEBUG] |...|...lexInlineLiteral#1204: Found literal close
[INFO] |...|...emit#297: [ID: 2]: itemInlineLiteral: "literal ``TeX quotes'' & \\backslash" l.start: 2 (3) l.index: 37 (38) line: 1
[INFO] |...|...emit#315: Position after EMIT: l.mark: '`', l.start: 37 (38) l.index: 37 (38) line: 1
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 37, index: 38, line: 1
[DEBUG] |...|...next#405: mark: U+0020 ' ', start: 37, index: 39, line: 1
[INFO] |...|...emit#297: [ID: 3]: itemInlineLiteralClose: "``" l.start: 37 (38) l.index: 39 (40) line: 1
[INFO] |...|...emit#315: Position after EMIT: l.mark: ' ', l.start: 39 (40) l.index: 39 (40) line: 1
[DEBUG] |...func·022#1196: END
[DEBUG] |...next#405: mark: U+0062 'b', start: 39, index: 40, line: 1
[DEBUG] |...next#405: mark: U+0075 'u', start: 39, index: 41, line: 1
[DEBUG] |...next#405: mark: U+0074 't', start: 39, index: 42, line: 1
[DEBUG] |...next#405: mark: U+0020 ' ', start: 39, index: 43, line: 1
[DEBUG] |...next#405: mark: U+006E 'n', start: 39, index: 44, line: 1
[DEBUG] |...next#405: mark: U+006F 'o', start: 39, index: 45, line: 1
[DEBUG] |...next#405: mark: U+0074 't', start: 39, index: 46, line: 1
[DEBUG] |...next#405: mark: U+0020 ' ', start: 39, index: 47, line: 1
[DEBUG] |...next#405: mark: U+0022 '"', start: 39, index: 48, line: 1
[DEBUG] |...next#405: mark: U+0060 '`', start: 39, index: 49, line: 1
[DEBUG] |...isInlineMarkup#717: START Checking for inline markup
[DEBUG] |...|...backup#345: l.mark backed up to: '"'
[DEBUG] |...|...peekBack#383: peekBack found "\"" at index 48
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 39, index: 50, line: 1
[DEBUG] |...|...peek#364: peek() found '`' at index 50
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 39, index: 50, line: 1
[DEBUG] |...|...next#405: mark: U+0022 '"', start: 39, index: 51, line: 1
[DEBUG] |...|...peek#364: peek() found '"' at index 51
[DEBUG] |...func·010#721: END
[DEBUG] |...next#405: mark: U+0060 '`', start: 39, index: 50, line: 1
[DEBUG] |...isInlineMarkup#717: START Checking for inline markup
[DEBUG] |...|...backup#345: l.mark backed up to: '`'
[DEBUG] |...|...peekBack#383: peekBack found "`" at index 49
[DEBUG] |...|...backup#345: l.mark backed up to: '`'
[DEBUG] |...|...backup#345: l.mark backed up to: '"'
[DEBUG] |...|...peekBack#383: peekBack found "\"" at index 48
[DEBUG] |...|...next#405: mark: U+0022 '"', start: 39, index: 51, line: 1
[DEBUG] |...|...peek#364: peek() found '"' at index 51
[DEBUG] |...func·010#721: END
[DEBUG] |...next#405: mark: U+0022 '"', start: 39, index: 51, line: 1
[DEBUG] |...next#405: mark: U+0020 ' ', start: 39, index: 52, line: 1
[DEBUG] |...next#405: mark: U+006F 'o', start: 39, index: 53, line: 1
[DEBUG] |...next#405: mark: U+0072 'r', start: 39, index: 54, line: 1
[DEBUG] |...next#405: mark: U+0020 ' ', start: 39, index: 55, line: 1
[DEBUG] |...next#405: mark: U+0060 '`', start: 39, index: 56, line: 1
[DEBUG] |...isInlineMarkup#717: START Checking for inline markup
[DEBUG] |...|...backup#345: l.mark backed up to: ' '
[DEBUG] |...|...peekBack#383: peekBack found " " at index 55
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 39, index: 57, line: 1
[DEBUG] |...|...peek#364: peek() found '`' at index 57
[DEBUG] |...|...next#405: mark: U+0060 '`', start: 39, index: 57, line: 1
[DEBUG] |...|...next#405: mark: U+FFFD '�', start: 39, index: 58, line: 1
[DEBUG] |...|...peek#364: peek() found '�' at index 58
[DEBUG] |...func·010#721: END
[DEBUG] |...next#405: mark: U+0060 '`', start: 39, index: 57, line: 1
[DEBUG] |...isInlineMarkup#717: START Checking for inline markup
[DEBUG] |...|...backup#345: l.mark backed up to: '`'
[DEBUG] |...|...peekBack#383: peekBack found "`" at index 56
[DEBUG] |...|...backup#345: l.mark backed up to: '`'
[DEBUG] |...|...backup#345: l.mark backed up to: ' '
[DEBUG] |...|...peekBack#383: peekBack found " " at index 55
[DEBUG] |...|...next#405: mark: U+FFFD '�', start: 39, index: 58, line: 1
[DEBUG] |...|...peek#364: peek() found '�' at index 58
[DEBUG] |...func·010#721: END
[DEBUG] |...next#405: mark: U+FFFD '�', start: 39, index: 58, line: 1
[INFO] |...emit#297: [ID: 4]: itemParagraph: " but not \"``\" or ``" l.start: 39 (40) l.index: 58 (59) line: 1
[INFO] |...emit#315: Position after EMIT: l.mark: '�', l.start: 58 (59) l.index: 58 (59) line: 1
[DEBUG] func·016#983: END
[DEBUG] lexStart#803: START
[DEBUG] |...lexStart#841: isEndOfLine == true
[DEBUG] |...lexStart#850: Found end of last line
[INFO] |...emit#297: [ID: 5]: itemEOF: "" l.start: 58 (59) l.index: 58 (59) line: 1
[INFO] |...emit#315: Position after EMIT: l.mark: '�', l.start: 58 (59) l.index: 58 (59) line: 1
[DEBUG] func·013#807: END
--- PASS: TestLexInlineLiteralGood0600 (0.01s)
PASS
ok github.com/demizer/go-rst/parse 0.011s
from go-rst.
Related Issues (20)
- Allow arbitrary insertion into the token ring buffer
- DRY: Lexing a token of the current line HOT 1
- The checkField function in parse_test.go is getting long HOT 1
- Fix node count on critical error for mismatched nodes HOT 1
- Lexer tests should run first HOT 1
- Provide tests for lexer function
- Remove the giant table from the main Readme HOT 1
- Lex/Parse Strong Inline Markup
- Lex/Parse Emphasis Inline Markup
- Lex/Parse Literal Inline Markup
- Lex/Parse Basic Interpreted Text Inline Markup
- Lex/Parse Hyperlink References Inline Markup
- Lex/Parse Embedded URIs Inline Markup
- Lex/Parse Embedded Aliases Inline Markup
- Lex/Parse Literal Blocks
- Lex/Parse Directives
- Use GB HOT 1
- rst2ansi support
- Want to integrate on github.com/go-gitea/gitea, but lack of features HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-rst.