Re: Lexer

From: anton <averbit....at.yandex.ru>
Date: Wed, 15 Jun 2011 03:36:09 -0700 (PDT)

The main problem is that if I do something wrong in a module, TA
(well, Lua) gives a meaningful
error message. If I do something wrong in a lexer TA simply crashes.

First try: only to lex "\command[word" or even simply "[word"
(this doesn't work)

-- already defined
local operator = token(l.OPERATOR, S('$&%#{}'))

local preprocessor = #operator* P('[')* token(l.PREPROCESSOR, l.word)

-- local preprocessor = #P('[') * token(l.PREPROCESSOR, l.word)

_rules = {
  { 'whitespace', ws },
  { 'comment', comment },
  { 'string', string },
  { 'keyword', command },
  { 'operator', operator },
  { 'preprocessor', preprocessor },
  { 'any_char', l.any_char },
}

The thing I most confused about is the mixture of strings and LPeg
patterns
like S('letters'), P('string') like this
local block_comment = '\\begin{comment}' * (l.any - '\
\end{comment}')^0 *
                      P('\\end{comment}')^-1
thanks,
anton

On 15 Jun., 00:09, mitchell <c....at.caladbolg.net> wrote:
> Hi Anton,
>
> On Tue, 14 Jun 2011, anton wrote:
> > Hi all,
>
> > I want to do the following thing.
> > In Latex commands look like this
> > \commandname or \commandname{variable}
> > but some of them can have parameters, i.e.
> > \commandname[parameters]{variable}
> > The classical example is
> > \documentclass[12pt,a4paper, oneside,ngerman]{scrbook}.
>
> > Can someone help me with lexing of parameters?
> > I've tried # operator but without success.
>
> Can you post what you have tried?
>
Received on Wed 15 Jun 2011 - 06:36:09 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:10:49 EST