Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [asciidoc-lang-dev] Whitespace handling



On Tue, 9 Mar 2021 at 19:30, Sylvain Leroux <sylvain@xxxxxxxxxxx> wrote:
On 09/03/2021 01:20, Lex Trotman wrote:
> Ahh yes another extension I did was that all non-terminals and tokens
> can return a numeric value (if they match) and I added a simple syntax
> for assigning that value if its needed, and comparing it to the
> parameter passed to the non-terminal.  Tokens return a count of relevant
> characters that varies from token to token but is effectively the level
> for section/list tokens or length of delimiter for block delimiters. 
> The (simplified) syntax  for a "section" would be:
>
> Section(level) ::= token_level = <start_line_equals>
> (:token_level==level:) Markup_text_line Section_contents *Section(level+1)
>
> where <line_start_equals> is the token from the lexer, (:_expression_:) is
> a test that will fail the non-terminal if it fails, and name= assigns
> the value to name. These have the obvious implementation in code.
>
Yes, that's a problem for a PEG-based _implementation_. For the specs, I
suppose we can add such guard clauses without causing too much harm.


On thinking about it some more, I guess "can count" is true for any recursive language, if you recurse on each character of a block delimiter then return on each character of the next you should be back where you started, otherwise its not a matching delimiter. But testing of section and list depth is trickier. Its the way some functional languages do looping (and C++ Template Metaprogramming).  But that sort of recursion isn't really the sort of thing I would try using in a specification, only full Computer Scientists would understand, and we want the specification to be clear to writers checking edge cases of their documents I would think.

Cheers
Lex
 

_______________________________________________
asciidoc-lang-dev mailing list
asciidoc-lang-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/asciidoc-lang-dev

Back to the top