To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 139
  regular expressions for DAT file subpart lines
 
Hey Perl fans, What's your favorite regular expression for a subpart line (or any other line, for that matter) in an LDraw DAT file? Here's my entry; $linein is a single line from the DAT file, may or may not be padded with whitespace at the (...) (25 years ago, 22-Jun-99, to lugnet.off-topic.geek)
 
  Re: regular expressions for DAT file subpart lines
 
(...) Whoops! I need to account for floating point values within the matrix. m/ ^ \s*1 # indicates a subpart \s+([0-9]+) # color (?:\s+[+-]?[0-9]+(?:...-9]+)?){3} # coordinates (?:\s+[+-]?[0-9]+(?:...-9]+)?){9} # 3 x 3 transform matrix \s+(\S+) # (...) (25 years ago, 22-Jun-99, to lugnet.off-topic.geek)
 
  Re: regular expressions for DAT file subpart lines
 
(...) You sure do. Can your code handle the following: 1 4E0 0 0 0 1E0 0 0 0 1E0 0 0 0 1E0 3001.dat Steve (...) (25 years ago, 23-Jun-99, to lugnet.off-topic.geek)
 
  Re: regular expressions for DAT file subpart lines
 
(...) Arg. Is this allowed? I guess it should be; the original parser was implemented using Pascal... Yes, ugly getting it is, hmmm? :-, if( $linein =~ m/ ^ \s*1 # indicates a subpart \s+([0-9]+) # color (?:\s+[+-]?[0-9]+(?:...-9+])?){3} # (...) (25 years ago, 23-Jun-99, to lugnet.off-topic.geek)
 
  Re: regular expressions for DAT file subpart lines
 
Oops, I forgot a few other odd things. I *think* your expression allows these, but I'm not sure: .1 -.1 0. -0. 001 1E BTW, the color-code can be in scientific notation. The line-type can't, at least, it can't in LDLite. I'm betting LDraw would (...) (25 years ago, 23-Jun-99, to lugnet.off-topic.geek)
 
  "Well-Formed" LDraw (Was: regular expressions for DAT file subpart lines)
 
(...) Nope, won't take a fraction w/o the integer part; gotta fix that (...) Nope, same reason as above (...) Nope, won't take a fraction w/o the fraction part, gotta fix that (...) Nope, same reason as above (...) Yep! Woo-Hoo!!! :-, (...) Nope, I (...) (25 years ago, 23-Jun-99, to lugnet.off-topic.geek, lugnet.cad.dev)
 
  Re: "Well-Formed" LDraw (Was: regular expressions for DAT file subpart lines)
 
(...) Both of the above are common output from LDAO code. (...) Well, I was just throwing stuff out. I don't know if LDraw would take that one, or not. (...) Darned context-sensitive constructions. (...) I didn't say they made sense. Just that they (...) (25 years ago, 24-Jun-99, to lugnet.off-topic.geek, lugnet.cad.dev)
 
  Re: "Well-Formed" LDraw (Was: regular expressions for DAT file subpart lines)
 
Hey now, that's beginning to look like the yacc grammer for LDRAW in the LDLite source code. If you want to get precise in the language spec, grab the LDLite lex and yacc files and either take them as the defacto standard or modify them to handle (...) (25 years ago, 25-Jun-99, to lugnet.off-topic.geek, lugnet.cad.dev)
 
  Re: "Well-Formed" LDraw (Was: regular expressions for DAT file subpart lines)
 
(...) Oh, good. Then I wrote something close to correct. :) (...) That's probably a good idea. Most people will just scratch their heads at them, but some people would find it useful. Steve (25 years ago, 25-Jun-99, to lugnet.off-topic.geek, lugnet.cad.dev)

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR