grammatica-users
[
Top
][
All Lists
]
Advanced
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
]
Re: [Grammatica-users] Negation in production rules
From
:
Oliver Gramberg
Subject
:
Re: [Grammatica-users] Negation in production rules
Date
:
Tue, 4 May 2010 12:34:43 +0200
Hello Andrew,
try this (header omitted, output at the end):
---------------------------------------------------------------------
%tokens%
colon = ':'
equals = '='
lbracket = '['
rbracket = ']'
string_literal = <<"[^"]*">>
integer_literal = <<[0-9]+>>
real_literal = <<-?[0-9]+\.[0-9]+>>
identifier = <<[A-Z][A-Z0-9_]*>>
whitespace = <<[ \t]+>> %ignore%
newline = <<[\n\r]+>>
%productions%
start = line+ ;
line = contents? newline ;
contents = key '=' values? | values ;
key = identifier ( ':' identifier )? ( '[' integer_literal ']' )? ;
values = value+ ;
value = string_literal | integer_literal | real_literal | identifier ;
---------------------------------------------------------------------
Feel free to come back with questions!
Regards
Oliver
---------------------------------------------------------------------
Parse tree from notakey.sample:
start(2001)
line(2002)
contents(2003)
key(2004)
identifier(1008): "DATE", line: 1, col: 1
equals(1002): "=", line: 1, col: 5
values(2005)
value(2006)
string_literal(1005): ""Thu Apr 22 20:41:15 2010"", line: 1, col: 6
newline(1010): "(...)", line: 1, col: 32
line(2002)
contents(2003)
key(2004)
identifier(1008): "METHOD", line: 3, col: 1
equals(1002): "=", line: 3, col: 7
values(2005)
value(2006)
identifier(1008): "AM1", line: 3, col: 8
newline(1010): "(...)", line: 3, col: 11
line(2002)
contents(2003)
key(2004)
identifier(1008): "TITLE", line: 5, col: 1
equals(1002): "=", line: 5, col: 6
values(2005)
value(2006)
string_literal(1005): ""Untitled-1"", line: 5, col: 7
newline(1010): "(...)", line: 5, col: 19
line(2002)
contents(2003)
key(2004)
identifier(1008): "KEYWORDS", line: 7, col: 1
equals(1002): "=", line: 7, col: 9
values(2005)
value(2006)
string_literal(1005): "" AUX AM1 ALLVEC CHARGE=0 (...)", line: 7, col: 10
newline(1010): "(...)", line: 7, col: 93
line(2002)
contents(2003)
key(2004)
identifier(1008): "COMMENTS", line: 9, col: 1
equals(1002): "=", line: 9, col: 9
values(2005)
value(2006)
string_literal(1005): """", line: 9, col: 10
newline(1010): "(...)", line: 9, col: 12
line(2002)
contents(2003)
key(2004)
identifier(1008): "ATOM_EL", line: 11, col: 1
key(2)(3002)
lbracket(1003): "[", line: 11, col: 8
integer_literal(1006): "0008", line: 11, col: 9
rbracket(1004): "]", line: 11, col: 13
equals(1002): "=", line: 11, col: 14
newline(1010): "(...)", line: 11, col: 15
line(2002)
contents(2003)
values(2005)
value(2006)
identifier(1008): "C", line: 13, col: 1
value(2006)
identifier(1008): "C", line: 13, col: 3
value(2006)
identifier(1008): "H", line: 13, col: 5
value(2006)
identifier(1008): "H", line: 13, col: 7
value(2006)
identifier(1008): "H", line: 13, col: 9
value(2006)
identifier(1008): "H", line: 13, col: 11
value(2006)
identifier(1008): "H", line: 13, col: 13
value(2006)
identifier(1008): "H", line: 13, col: 15
newline(1010): "(...)", line: 13, col: 16
line(2002)
contents(2003)
key(2004)
identifier(1008): "ATOM_CORE", line: 15, col: 1
key(2)(3002)
lbracket(1003): "[", line: 15, col: 10
integer_literal(1006): "0008", line: 15, col: 11
rbracket(1004): "]", line: 15, col: 15
equals(1002): "=", line: 15, col: 16
newline(1010): "(...)", line: 15, col: 17
line(2002)
contents(2003)
values(2005)
value(2006)
integer_literal(1006): "4", line: 17, col: 1
value(2006)
integer_literal(1006): "4", line: 17, col: 3
value(2006)
integer_literal(1006): "1", line: 17, col: 5
value(2006)
integer_literal(1006): "1", line: 17, col: 7
value(2006)
integer_literal(1006): "1", line: 17, col: 9
value(2006)
integer_literal(1006): "1", line: 17, col: 11
value(2006)
integer_literal(1006): "1", line: 17, col: 13
value(2006)
integer_literal(1006): "1", line: 17, col: 15
newline(1010): "(...)", line: 17, col: 16
line(2002)
contents(2003)
key(2004)
identifier(1008): "ATOM_X", line: 19, col: 1
key(1)(3001)
colon(1001): ":", line: 19, col: 7
identifier(1008): "ANGSTROMS", line: 19, col: 8
key(2)(3002)
lbracket(1003): "[", line: 19, col: 17
integer_literal(1006): "0024", line: 19, col: 18
rbracket(1004): "]", line: 19, col: 22
equals(1002): "=", line: 19, col: 23
newline(1010): "(...)", line: 19, col: 24
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "-0.3893", line: 21, col: 1
value(2006)
real_literal(1007): "0.6545", line: 21, col: 9
value(2006)
real_literal(1007): "0.0000", line: 21, col: 16
newline(1010): "(...)", line: 21, col: 22
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "0.3893", line: 23, col: 1
value(2006)
real_literal(1007): "-0.6545", line: 23, col: 8
value(2006)
real_literal(1007): "0.0000", line: 23, col: 16
newline(1010): "(...)", line: 23, col: 22
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "0.3150", line: 25, col: 1
value(2006)
real_literal(1007): "1.5163", line: 25, col: 8
value(2006)
real_literal(1007): "0.0000", line: 25, col: 15
newline(1010): "(...)", line: 25, col: 21
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "-1.0344", line: 27, col: 1
value(2006)
real_literal(1007): "0.7137", line: 27, col: 9
value(2006)
real_literal(1007): "0.9050", line: 27, col: 16
newline(1010): "(...)", line: 27, col: 22
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "-1.0344", line: 29, col: 1
value(2006)
real_literal(1007): "0.7137", line: 29, col: 9
value(2006)
real_literal(1007): "-0.9050", line: 29, col: 16
newline(1010): "(...)", line: 29, col: 23
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "-0.3150", line: 31, col: 1
value(2006)
real_literal(1007): "-1.5163", line: 31, col: 9
value(2006)
real_literal(1007): "0.0000", line: 31, col: 17
newline(1010): "(...)", line: 31, col: 23
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "1.0344", line: 33, col: 1
value(2006)
real_literal(1007): "-0.7137", line: 33, col: 8
value(2006)
real_literal(1007): "0.9050", line: 33, col: 16
newline(1010): "(...)", line: 33, col: 22
line(2002)
contents(2003)
values(2005)
value(2006)
real_literal(1007): "1.0344", line: 35, col: 1
value(2006)
real_literal(1007): "-0.7137", line: 35, col: 8
value(2006)
real_literal(1007): "-0.9050", line: 35, col: 16
newline(1010): "(...)", line: 35, col: 23
line(2002)
contents(2003)
key(2004)
identifier(1008): "AO_ATOMINDEX", line: 37, col: 1
key(2)(3002)
lbracket(1003): "[", line: 37, col: 13
integer_literal(1006): "0014", line: 37, col: 14
rbracket(1004): "]", line: 37, col: 18
equals(1002): "=", line: 37, col: 19
newline(1010): "(...)", line: 37, col: 20
line(2002)
contents(2003)
values(2005)
value(2006)
integer_literal(1006): "1", line: 39, col: 1
value(2006)
integer_literal(1006): "1", line: 39, col: 3
value(2006)
integer_literal(1006): "1", line: 39, col: 5
value(2006)
integer_literal(1006): "1", line: 39, col: 7
value(2006)
integer_literal(1006): "2", line: 39, col: 9
value(2006)
integer_literal(1006): "2", line: 39, col: 11
value(2006)
integer_literal(1006): "2", line: 39, col: 13
value(2006)
integer_literal(1006): "2", line: 39, col: 15
value(2006)
integer_literal(1006): "3", line: 39, col: 17
value(2006)
integer_literal(1006): "4", line: 39, col: 19
value(2006)
integer_literal(1006): "5", line: 39, col: 21
value(2006)
integer_literal(1006): "6", line: 39, col: 23
value(2006)
integer_literal(1006): "7", line: 39, col: 25
value(2006)
integer_literal(1006): "8", line: 39, col: 27
newline(1010): "(...)", line: 39, col: 28
...
---------------------------------------------------------------------
reply via email to
[
Prev in Thread
]
Current Thread
[
Next in Thread
]
[Grammatica-users] Negation in production rules
,
Andrew Smellie
,
2010/05/03
Re: [Grammatica-users] Negation in production rules
,
Per Cederberg
,
2010/05/03
Re: [Grammatica-users] Negation in production rules
,
Oliver Gramberg
<=
RE: [Grammatica-users] Negation in production rules
,
Andrew Smellie
,
2010/05/04
Prev by Date:
Re: [Grammatica-users] Negation in production rules
Next by Date:
RE: [Grammatica-users] Negation in production rules
Previous by thread:
Re: [Grammatica-users] Negation in production rules
Next by thread:
RE: [Grammatica-users] Negation in production rules
Index(es):
Date
Thread