File: foolisp.g

package info (click to toggle)
kdevelop-pg-qt 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,284 kB
  • sloc: cpp: 22,743; lex: 928; ansic: 716; yacc: 615; ruby: 68; sh: 14; lisp: 10; fortran: 6; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,769 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%token_stream Lexer ;

%token LPAREN, RPAREN, FOO, BAR, BAZ, NUMBER, SHEBANG, STRING, IDENTIFIER ;
%lexer_bits_header "QDebug"
%parser_bits_header "QDebug"
%input_encoding "utf32"
-- %table_lexer
%input_stream "KDevPG::QUtf8ToUcs4Iterator"

%lexer ->
     
  "("                           LPAREN ;
  ")"                           RPAREN ;
  foo                           FOO ;
  bar                           BAR ;
  baz                           BAZ ;
  qux                           FOO ;
  quux                          BAR ;
  corge                         BAZ ;
  grault                        FOO ;
  garply                        BAR ;
  waldo                         BAZ ;
  fred                          FOO ;
  plugh                         BAR ;
  xyzzy                         BAZ ;
  thud                          FOO ;
  FOOBAR                        FOO ;

--   "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9" -> digit ; -- Should be predefined with unicode character classes
  "0" | ( {digit}&{basic_latin}^"0" ) {digit}*    NUMBER ;

(([({alphabetic}&{basic_latin}){greek_and_coptic}]^[a-z \x3b1-\x3b3])&{basic_latin})+        IDENTIFIER ; -- kinda exotic limitations for identifiers ;)


  "#!foolisp"                   SHEBANG ;
  [\ \n\t]+                     [: /* blank */ :] ;
  \" [.(\\.)^\"]* \"             STRING ;
  ;

   ?SHEBANG sexp=sexp -> start ;
  
   LPAREN #sexp=sexp* RPAREN
 | foo=FOO | bar=BAR | baz=BAZ | number=NUMBER | string=STRING | identifier=IDENTIFIER
-> sexp ;

[:
void FooLisp::Parser::expectedSymbol(int /*expectedSymbol*/, const QString& name)
{
  qDebug() << "Expected: " << name;
}
void FooLisp::Parser::expectedToken(int /*expected*/, qint64 /*where*/, const QString& name)
{
  qDebug() << "Expected token: " << name;
}
:]